JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 27.07.2016, 01:23
botmtl botmtl is offline
DSL User
 
Join Date: Apr 2015
Location: Montreal
Posts: 39
Default Rename action regular expression bug



(this is in linkgrabber but I think the same bug is in download section too?(not 100% sure))

this is a simple example, where the spaces that were _ were not caught (somehow) by the re.replace, but it can get more complicated. sometimes I have to do that right-click rename action multiple times to get all the packages and filenames to finally comply with the regex.

I usually use [^A-Za-z0-9\.-] as I had had the best results with dupe detection with that regular expression.
Reply With Quote
  #2  
Old 27.07.2016, 02:23
ds1508's Avatar
ds1508 ds1508 is offline
DSL User
 
Join Date: Jul 2016
Location: Germany, NRW
Posts: 38
Default

I dont understand where the problem is.
The only thing I see is, that you forgot the \ for the - at the end.
[^A-Za-z0-9\.\-]
__________________
--
In special cases you may contact me on Discord: http://bit.ly/dsDisco
Reply With Quote
  #3  
Old 27.07.2016, 02:35
botmtl botmtl is offline
DSL User
 
Join Date: Apr 2015
Location: Montreal
Posts: 39
Default

Parts overlined are wrong (I know you must have guessed that, but just in case). You don't need to escape the last "-" sign because re will understand with "]" following it.

The problem is with any character (spaces in this case) that didnt get zapped by the rename (since \s wasnt part of the character set).
Reply With Quote
  #4  
Old 27.07.2016, 03:01
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,659
Default

please email us support@jdownloader.org the package customiser rules (export them) you use with online example links.

raztoki
__________________
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 27.07.2016, 03:36
botmtl botmtl is offline
DSL User
 
Join Date: Apr 2015
Location: Montreal
Posts: 39
Default

Packagizer rule
**External links are only visible to Support Staff****External links are only visible to Support Staff**

Copy - Paste those line in JD
All I Believe, Firsts and ForeverPackage
Link;All_I_Believe__Firsts_and_Forever.z01;**External links are only visible to Support Staff****External links are only visible to Support Staff**
Link;All I Believe, Firsts and Forever.z01;**External links are only visible to Support Staff****External links are only visible to Support Staff**
Link;All I Believe, Firsts and Forever.zip;**External links are only visible to Support Staff****External links are only visible to Support Staff**
Link;All_I_Believe__Firsts_and_Forever.zip;**External links are only visible to Support Staff****External links are only visible to Support Staff**
One Giant Leap - Kay SimonePackage
Link;One Giant Leap - Kay Simone.mobi;**External links are only visible to Support Staff****External links are only visible to Support Staff**
Link;One Giant Leap - Kay Simone.mobi;**External links are only visible to Support Staff****External links are only visible to Support Staff**
Worth the WaitPackage
Link;Worth the Wait.rar;**External links are only visible to Support Staff****External links are only visible to Support Staff**
Link;Worth_the_Wait.rar;**External links are only visible to Support Staff****External links are only visible to Support Staff**

At this point you should have 3 groups (exactly like the likes that you just copied - I used the copy-information context menu to get those out of JD).

Now select the 3 packages and links - 12 objects selected total.

Context-menu rename ==> [^A-Za-z0-9\.-] replace with (empty).

You should end up with something like this.


Funilly enough, this time it decided to rename my packages and not my links (last example was the other way around - the packages weren't renamed with the re.replace but the links were). So normally now I would bring up rename again and do it again. I think there are situations were you have to do it 3 times for the rename to do its thing - but I cant reproduce right now.
Reply With Quote
  #6  
Old 27.07.2016, 07:27
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,659
Default

Sorry I thought you where doing manual renaming of filenames via package customiser rules, but the provided exported packagiser rules are just defaults. So maybe not? So that leaves JD plugins returning filenames... and core doing a little processing in respects to sorting ?

err i see now you mentioned context menu rename with regex.. works fine in my tests (I clicked preview button).

first example works as intended, as you've stripped all chars not in that given pattern (including spaces)
seems also that if you have - without escaping and a char after it, it will complain.. though in true sense you only need to NOT escape - char when its between grouping like a-z, 0-9, A-Z.

personally I would use two rules, along the lines of [^A-Za-z0-9\.\-]+ and replace with " "
as first can have multiple spaces generated, which then still don't match as direct filename mirrors
and second rule to remove multiple spaces for single \s+ replace with " ";

by the way we do have code in our core and plugins which can treat particular characters as wildcard. We have this because some file hosters rename chars and then mirroring can fail (rapidshare did, and also does uploaded.to). So this can be done when we know which chars are renamed by hosters... We can't account for people who upload different filenames to different hosters or even harder again is when people use multi-uploaders services which are also known to rename chars.


raztoki
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]

Last edited by raztoki; 27.07.2016 at 07:46.
Reply With Quote
  #7  
Old 27.07.2016, 09:49
ds1508's Avatar
ds1508 ds1508 is offline
DSL User
 
Join Date: Jul 2016
Location: Germany, NRW
Posts: 38
Default

Quote:
Originally Posted by botmtl View Post
Parts overlined are wrong
Ups. Sry. I looked at the files only. Didn't see the packagenames.
I do most rename actions from my filemanager and tool app.
__________________
--
In special cases you may contact me on Discord: http://bit.ly/dsDisco
Reply With Quote
  #8  
Old 27.07.2016, 15:18
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

@botmtl

The packages and file names are not renamed at the same time. What gets renamed depends on where the cursor was positioned in the selection. If it was over a package, the packages in the selection are renamed, it if was over a file name, the file names in the selection are renamed. Earlier there was a option [check box] to enable/disable 'rename packages'. Now it is intuitive. So I guess you have repeat the action twice to rename both.

You can also consider using event scripter to auto rename files/packages when they are added to the list.
Reply With Quote
  #9  
Old 27.07.2016, 16:07
ds1508's Avatar
ds1508 ds1508 is offline
DSL User
 
Join Date: Jul 2016
Location: Germany, NRW
Posts: 38
Default

Quote:
Originally Posted by mgpai View Post
You can also consider using event scripter to auto rename files/packages when they are added to the list.
This is my preference. I made a button in the linkgrabber bottom bar. Works perfect for me. Because I can do many operations at once with 1 click.
__________________
--
In special cases you may contact me on Discord: http://bit.ly/dsDisco
Reply With Quote
  #10  
Old 28.07.2016, 10:49
botmtl botmtl is offline
DSL User
 
Join Date: Apr 2015
Location: Montreal
Posts: 39
Default

Quote:
Originally Posted by ds1508 View Post
Ups. Sry. I looked at the files only. Didn't see the packagenames.
I do most rename actions from my filemanager and tool app.
Ha! I thought at I might get a very curt reply saying that "yes I know that a highlighter is commonly used to bring attention to something)."

I'm glad the comment was actually useful to someone.
Reply With Quote
  #11  
Old 28.07.2016, 11:01
botmtl botmtl is offline
DSL User
 
Join Date: Apr 2015
Location: Montreal
Posts: 39
Default

Quote:
Originally Posted by raztoki View Post
personally I would use two rules, along the lines of [^A-Za-z0-9\.\-]+ and replace with " " as first can have multiple spaces generated, which then still don't match as direct filename mirrors
and second rule to remove multiple spaces for single \s+ replace with " "; raztoki
I did the code for a linkgrabber button that does the 2 replace but i'm strugling with the equivalent packagizer rule (it would be best done there).

Here is what I tried:
Filename contains ([^A-Za-z0-9\.\-]) then set Filename:<jd:orgfilename:1> works great but the replace multiple spaces by one space has got me confused. I think this means to weed out blocks of two spaces ([^(\s{2,})]) but I don't know how to tell it to replace by 1 space.

(rest not interesting for you raz)

My filename and packagename cleaner custom event (button in linkgrabber). It cleans out all linkgrabber links, selected or not - and there is no ctrl-z or preview so use with some care.

Code for button (for users reading this thread)
Code:
//Add your script here. Feel free to use the available api properties and methods
var regex1 = /[^A-Za-z0-9\.\-]/g;
var regex2 = /\s+/g;

//for all packages in linkGrabber
var packs = getAllCrawledPackages();
var newName = "";
for (var j = 0; j < packs.length; j++) {
    var links = packs[j].getDownloadLinks();
    for (var i = 0; i < links.length; i++) {
        newName = links[i].getName().replace(regex1, " ");
        newName = newName.replace(regex2, " ");
        links[i].setName(newName);
    }
    packs[j].setName(/(.*)\./g.exec(newName));
}
Reply With Quote
  #12  
Old 28.07.2016, 11:31
ds1508's Avatar
ds1508 ds1508 is offline
DSL User
 
Join Date: Jul 2016
Location: Germany, NRW
Posts: 38
Default

I'm a little bit confused again. Shouldn't the last regex set the packagename from the filename without extension. Shouldn't it be then /(.*)\..*$/
Oh, and as backup for safety I store the original name as comment (if no comment). So I can copy it back.
__________________
--
In special cases you may contact me on Discord: http://bit.ly/dsDisco
Reply With Quote
  #13  
Old 28.07.2016, 15:09
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,340
Default

@botmtl: This is the IMPORTANT part

Quote:
Originally Posted by mgpai View Post
@botmtl
The packages and file names are not renamed at the same time. What gets renamed depends on where the cursor was positioned in the selection. If it was over a package, the packages in the selection are renamed, it if was over a file name, the file names in the selection are renamed.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #14  
Old 29.07.2016, 09:00
botmtl botmtl is offline
DSL User
 
Join Date: Apr 2015
Location: Montreal
Posts: 39
Default

-- redacted, sorry if I offended anyone.

Last edited by botmtl; 30.07.2016 at 08:20.
Reply With Quote
  #15  
Old 29.07.2016, 10:39
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,659
Default

What push back exactly? I haven't perceived any advice given here as negative, or even a push back against you. People have just told you how features are designed to work within JD interface at this given time.

I don't see doing task with package customiser working well. It hasn't been implemented as a standard replace function and has epic flaws because of it. It only works well for known strings, just not the unknown. Eg. It does work for 'somename here - tag here' you can easily use filename contains pattern '(.*?) - tag here' and then set... filename: <jd:orgfilename:1>. With the unknown Strings you can't event do it within the current frame work..

raztoki
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
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 10:31.
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 - 2024, Jelsoft Enterprises Ltd.