JDownloader Community - Appwork GmbH
 

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #22  
Old 25.04.2016, 12:06
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 612
Default

Define maximum length for file (and package) name using event scripter.
Code:
/*
Script: Tumblr workaround
Trigger:"Packagizer Hook"
*/

var tumblr = /.*\.tumblr.com\/post\/.*/.test(link.getSourceUrls().join());

if (tumblr) {
    var fileName = link.name.replace(/(.+)\..+$/, "$1");
    var fileType = link.name.replace(/.+(\..+$)/, "$1");
    var packageName = link.packageName !== null ? link.packageName : "Unknown";
    var maxLength = 65; // set maximum allowed length for file name (maxLength - 20 will be used for package name)
    var newFileName = fileName.substring(0, maxLength).substr(0, Math.min(fileName.substring(0, maxLength).length, fileName.substring(0, maxLength).lastIndexOf(" ")));
    var newPackageName = packageName.substring(0, maxLength - 20).substr(0, Math.min(packageName.substring(0, maxLength - 20).length, packageName.substring(0, maxLength - 20).lastIndexOf(" ")));
    var user = link.getSourceUrls().join().replace(/.*http:\/\/([^.]+)[^/]+\/post\/.*/, "$1");
    var description = link.name.replace(/\d+\s+-\s+\d+\s+\-\s(.+)\..+$/, "$1");

    link.setName(user + " - " + newFileName + fileType); // filename with prefix (Easier to identify single files in "Various Files" package)
    link.setPackageName(user + " - " + newPackageName); // packageName with prefix

    //link.setName(newFileName + fileType); // filename without prefix
    //link.setPackageName(newPackageName); // packageName without prefix
    //link.setComment(description); // Set the original filename as comment
}
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 23:01.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.