Welcome, Guest
Python Scripts for ComicRack

TOPIC: malor89's ComicRack Scripts

Re: malor89's ComicRack Scripts 4 years 7 months ago #33364

  • Madmatx
  • Madmatx's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 457
  • Thank you received: 63
  • Karma: 19
OK I hate spam but this is my one and only spam in this forum Since you all are currently active; check out our Comic Book Reading Club and weigh in on the conversation.

oh and ..,.

[quote="laxarus" post=33362Let's say, you have 2 predefined publishers in your list:"Light" and "Blue Light"and a filename: [Blue Light] XXXXXX.rarWhen you run the script on this file, you get "Light" as your publisher instead of "Blue Light"Is there anyway to fix this?[/quote]
Same question since I bumped it to a new page.
Last Edit: 4 years 7 months ago by Madmatx.
The administrator has disabled public write access.

Re: malor89's ComicRack Scripts 4 years 7 months ago #33376

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
Replace:
m = re.search('(?i)\([^\)]*(?<=[^a-z])'+publishers+'[^a-z](?!dcp)', name) #find publisher
with:
m = re.search('(?i)\( *'+publishers+' *\)', name) #find publisher strict
if(not m):
	m = re.search('(?i)\([^\)]*(?<=[^a-z])'+publishers+'[^a-z](?!dcp)', name) #find publisher
This works by first trying to get an exact match in brackets. If that fails it goes back to a more general match, because some times instead of (c2c) (publisher) everything is put together like (c2c, publisher, ...)
Last Edit: 4 years 7 months ago by malor89.
The administrator has disabled public write access.

Re: malor89's ComicRack Scripts 4 years 7 months ago #33382

  • laxarus
  • laxarus's Avatar
  • Offline
  • Senior Boarder
  • Posts: 66
  • Thank you received: 3
  • Karma: 0
malor89 wrote:
Replace:
m = re.search('(?i)\([^\)]*(?<=[^a-z])'+publishers+'[^a-z](?!dcp)', name) #find publisher
with:
m = re.search('(?i)\( *'+publishers+' *\)', name) #find publisher strict
if(not m):
	m = re.search('(?i)\([^\)]*(?<=[^a-z])'+publishers+'[^a-z](?!dcp)', name) #find publisher
This works by first trying to get an exact match in brackets. If that fails it goes back to a more general match, because some times instead of (c2c) (publisher) everything is put together like (c2c, publisher, ...)

This partially fixed the problem. Thanks!!! However, there are also files named like this too.

[Red Light (Amazon)] xxxxxxxxxxxxxxx.cbz

it returns "Light" as the publisher of this file instead of Red Light. How to get around that? Do i need to get rid of the author part which is in parenthesis manually?
The administrator has disabled public write access.

Re: malor89's ComicRack Scripts 4 years 7 months ago #33399

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
laxarus wrote:
This partially fixed the problem. Thanks!!! However, there are also files named like this too.

[Red Light (Amazon)] xxxxxxxxxxxxxxx.cbz

it returns "Light" as the publisher of this file instead of Red Light. How to get around that? Do i need to get rid of the author part which is in parenthesis manually?
This should catch that as well.
m = re.search('(?i)\( *'+publishers+' *[\)\(]', name) #find publisher strict
The administrator has disabled public write access.

Re: malor89's ComicRack Scripts 4 years 6 months ago #33422

  • laxarus
  • laxarus's Avatar
  • Offline
  • Senior Boarder
  • Posts: 66
  • Thank you received: 3
  • Karma: 0
Thank you so much man. It worked. I am still in the middle of processing my library so if i find any more bugs or problems, will let you know. Again, thank you.
The administrator has disabled public write access.

Re: malor89's ComicRack Scripts 4 years 6 months ago #33451

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
Glad I could help.
The administrator has disabled public write access.

Re: malor89's ComicRack Scripts 4 years 4 months ago #35821

  • laxarus
  • laxarus's Avatar
  • Offline
  • Senior Boarder
  • Posts: 66
  • Thank you received: 3
  • Karma: 0
It works really good but i found 2 minor issues where in some cases dot character escape doesn't work in the publisher list (Maybe for more special characters) and if there is a plus sign in a publisher, it doesn't write the sign

1st Ex:
publisher: ASDL.O.W
entry in the publisher list: ASDL\.O\.W

filename: [ASDL.O.W] xxxx.cbz

it writes nothing and if you remove the backslashes CR throws an error.

2nd Ex:
publisher: Anolst+
entry in the pusblisher list: Anolst\+

filename [Anolst+] xxxxx.cbz

it writes the publisher as "Anolst" with no "+" sign

and i gotta say your script saved me a lot of trouble organizing my library since the material i have cannot be scraped with comicvine
The administrator has disabled public write access.

Re: malor89's ComicRack Scripts 4 years 4 months ago #35885

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
publisher: ASDL.O.W doesn't work because the line
name = name.replace('.', ' ')
changes all the periods to spaces. You can remove or comment out that line if you don't need it.

publisher: Anolst\+ would be correct, but then the reverse lookup to make all the capitalization uniform would fail, because it would be looking for Anolst+ which wouldn't be in the list, so we need to change + to \+ and then remove the \ from the match.
if(m):
	publisher = m.group(1)
	publisher = publisher.replace('+', '\\\\\+')
	m = re.search('(?i)('+publisher+')', publishers) #find in publishers list to get proper capitalization
	fixed = m.group(1)
	fixed = fixed.replace('\\', '')
The administrator has disabled public write access.

Re: malor89's ComicRack Scripts 4 years 4 months ago #35887

  • laxarus
  • laxarus's Avatar
  • Offline
  • Senior Boarder
  • Posts: 66
  • Thank you received: 3
  • Karma: 0
malor89 wrote:
publisher: ASDL.O.W doesn't work because the line
name = name.replace('.', ' ')
changes all the periods to spaces. You can remove or comment out that line if you don't need it.
removing or commenting out the
name = name.replace('.', ' ')
line throws and error when I execute the script when the entry in the list is "ASDL\.O\.W". However when I remove the ASD at the beginning and change the filename to [L.O.W] xxx.cbz and execute the script, I get a publisher entry "loodw" which doesn't make any sense. Upon further testing I found another entry in my publisher list which is "Floodwaters" and it appears the script takes the "loodw" in it because when i remove that entry I also get an error.

malor89 wrote:
publisher: Anolst\+ would be correct, but then the reverse lookup to make all the capitalization uniform would fail, because it would be looking for Anolst+ which wouldn't be in the list, so we need to change + to \+ and then remove the \ from the match.
if(m):
	publisher = m.group(1)
	publisher = publisher.replace('+', '\\\\\+')
	m = re.search('(?i)('+publisher+')', publishers) #find in publishers list to get proper capitalization
	fixed = m.group(1)
	fixed = fixed.replace('\\', '')
I needed to change smth to make it work but yeah that worked thanks.
And as for the dot problem my search code looks like this currently.
m = re.search('(?i)\( *'+publishers+' *[\)\(]', name) #find publisher strict
			if(not m):
				m = re.search('(?i)\([^\)]*(?<=[^a-z])'+publishers+'[^a-z](?!dcp)', name) #find publisher
			if(m):
				publisher = m.group(1)
				publisher = publisher.replace('+', '\\\\\+')
				m = re.search('(?i)('+publisher+')', publishers) #find in publishers list to get proper capitalization
				fixed = m.group(1)
				fixed = fixed.replace('\\', '')
				book.Publisher = fixed
and i gotta say regexps really throws me of when reading a code, I just can't seem to get them ):

Also, i was wondering if it is possible for this script the read the publisher list from an external file like a text file or smth else with 1 line per publisher or smth similar.
Last Edit: 4 years 4 months ago by laxarus.
The administrator has disabled public write access.

Re: malor89's ComicRack Scripts 4 years 4 months ago #35899

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
I had tested "ASDL.O.W" instead of "ASDL\.O.\W", but since that could potentially generate false matches "ASDL\.O\.W" is probably better, but the .'s would need to be escaped like the + was. Just put the following line after the on for +.
publisher = publisher.replace('.', '\\\\\.')
This should let you read a list of publishers from a file:
publishers = "("
file = open("publishers.txt", "r")

line = file.readline()
while (line):
        line = re.sub ('\n$', "", line)
        publishers += line + "|"
        line = file.readline()
        
file.close()
publishers = publishers[:-1] + ")"  # remove | at the end and add );
Last Edit: 4 years 4 months ago by malor89.
The administrator has disabled public write access.
Time to create page: 0.270 seconds

Who's Online

We have 266 guests and one member online