JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 28.02.2020, 15:48
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default Rename packages with spaces

Is it possible using packagizer rules to auto-rename package names with spaces between the words with periods?, for example: word1 word2 word3 and replace with word1.word2.word3
Reply With Quote
  #2  
Old 29.02.2020, 00:59
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,183
Default

for memory the back end should remove periods and underscores automatically.
the only time it wont is if plugins are involved and property is set to prevent cleanup from happening.

do you have any example test links?
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #3  
Old 29.02.2020, 02:20
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default

Quote:
Originally Posted by raztoki View Post
for memory the back end should remove periods and underscores automatically.
the only time it wont is if plugins are involved and property is set to prevent cleanup from happening.

do you have any example test links?
**External links are only visible to Support Staff****External links are only visible to Support Staff**

I have created two other package rules that are working properly.
One that removes .www dot website dot com from all files inside package and a 2nd one to rename jpg files the same as package name, however, the third rule to substitute the spaces between the words with periods(.) is giving me some trouble. I can use .* in the condition but all combos I tried to 'set' for package name are either _._ or _. etc. I think I may need to use the 'package key pattern' for this third rule.

Last edited by RPNet-user; 29.02.2020 at 02:44.
Reply With Quote
  #4  
Old 29.02.2020, 02:59
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,183
Default

Not sure which plugin psp deleted (haven't updated workspace), but the original and newer one(not sure why dupe was created) both set package names. this is from website material.

To rename package name or filename you would need to reconstruct it from source thats correct, or you could guess and place it in, though this could take more work. Not sure if a single generic rule would work, most likely not. You would then need multiple rules for every combination you can think of. one space, two spaces, three spaces, etc
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #5  
Old 29.02.2020, 03:22
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default

Ok i finally got it working but that is a lot of asterisks and a lot of package patterns just for that package, the problem is different packages will have different amount of spaces so this rule will only work for packages that have seven spaces, hopefully there is an easier method that covers any amount of spaces like a regex.

Code:
If Package name: * * * * * * * *
Then set Package name: <jd:orgpackagename:1>.<jd:orgpackagename:2>.<jd:orgpackagename:3>.<jd:orgpackagename:4>.<jd:orgpackagename:5>.<jd:orgpackagename:6>.<jd:orgpackagename:7>.<jd:orgpackagename:8>

Last edited by RPNet-user; 29.02.2020 at 03:38.
Reply With Quote
  #6  
Old 29.02.2020, 03:44
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,183
Default

thats where a generic single rule fails. which i kinda hinted that you would need a rule for each possibility.
duplicate the rule and just remove one * listener and reference call
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #7  
Old 29.02.2020, 04:04
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default

Quote:
Originally Posted by raztoki View Post
thats where a generic single rule fails. which i kinda hinted that you would need a rule for each possibility.
duplicate the rule and just remove one * listener and reference call
Yes the 'duplicate rule' is a time saver but there are some packages that have 10+ spaces, I just tested one with 11. Its is too bad I cannot use something like this in the package field rule that would cover all rules for spaces: (/\s/g, ".")
Reply With Quote
  #8  
Old 29.02.2020, 04:15
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,183
Default

you could look at the event scripter, it would allow for more flexibility. you could just use in java .replace(" ", "."). I'm sure there is a equivalent in javascript w3schools.com/jsref/jsref_replace.asp
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #9  
Old 29.02.2020, 04:41
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default

Quote:
Originally Posted by raztoki View Post
you could look at the event scripter, it would allow for more flexibility. you could just use in java .replace(" ", "."). I'm sure there is a equivalent in javascript w3schools.com/jsref/jsref_replace.asp
Thanks raztoki, good idea, I will check it out.
Reply With Quote
  #10  
Old 29.02.2020, 06:19
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default

The script does change the entire package name by replacing all the spaces with periods immediately after it finishes, the only problem is that it only changes it in the downloads list and not the actual downloaded folder:

Code:
Event Trigger: Package Finished
package.setName(package.name.replace(/\s/g, "."))
Reply With Quote
  #11  
Old 29.02.2020, 07:21
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,183
Default

if you're using sub directory as pakagename that is set on entry into linkgrabber, which is prior to event scripter. just reset the save path after the rename.
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #12  
Old 29.02.2020, 20:54
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default

What do you mean "reset the save path"?
Reply With Quote
  #13  
Old 01.03.2020, 00:13
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,183
Default

well from you previous response & the download I assume that your using sub directory as package name. that is set at entry into linkgrabber, you alter with js the package name thus the wrong save name now, so you need to re-set it so align with your new package name
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #14  
Old 01.03.2020, 04:29
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default

My default folder path is set for C:\JD2\<jd:packagename>.
Whether I use or not use '<jd:packagename>' the results are the same.
Disabling both JD2 predefined package rules of 'create subfolder by packagname' and 'adopt folder structure' did not make any difference. Other than this, I have no idea how/where to 'reset' this path/packagename.
Reply With Quote
  #15  
Old 01.03.2020, 04:37
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,183
Default

you do this in javascript, along wiht your renaming function
as save path is set at the time into linkgrabber, since you are altering the packagename after it adds (previous save path is of the original name) you then need to reset the save path to reflect you changes.
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #16  
Old 01.03.2020, 07:51
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 919
Default

Quote:
Originally Posted by RPNet-user View Post
Is it possible using packagizer rules to auto-rename package names with spaces between the words with periods?
Use a script with "Packagizer Hook" trigger.
Reply With Quote
  #17  
Old 01.03.2020, 09:36
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default

I think that what I'm trying to accomplish may be too complex:

I'm trying to:
1. Rename the packages by replacing spaces with periods
2. Remove the .**External links are only visible to Support Staff**www.website.com appended to video files within the package
3. Rename the jpg file with same name as the video files including the periods between words

Using packagizer rules only I have been able to accomplish only two of three in different scenarios:

Scenario-1
1. Able to rename package by replacing spaces with periods
2. Able to remove all .**External links are only visible to Support Staff**www.website.com from all video files
3. Unable to rename jpg with the same name as video files and include the periods between words(same as video files)

Scenario-2
1. Able to remove all .**External links are only visible to Support Staff**www.website.com from all video files
2. Able to Rename jpg file with same name as the video files from packagename except for the periods between words
3. Unable to replace spaces with periods for both packagename and jpg
Reply With Quote
  #18  
Old 01.03.2020, 10:50
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 919
Default

Script:
Code:
gist.github.com/mgpai/aed241abcc28b34ea640250c84a794e1

Find me in JD Chat if you need any modifications.
Reply With Quote
  #19  
Old 03.03.2020, 09:31
RPNet-user RPNet-user is offline
JD Addict
 
Join Date: Apr 2017
Posts: 169
Default

Once again mgpai, thanks for your script and support assistance through the chat, this script does everything perfectly.
Reply With Quote
Reply

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 02:23.
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 - 2020, Jelsoft Enterprises Ltd.