mirror of
https://github.com/evilhero/mylar
synced 2025-03-12 15:02:55 +00:00
updated ComicRN.py script to allow for character replacment now
This commit is contained in:
parent
d3b6a06878
commit
d3660049cc
1 changed files with 28 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# ComicBook Renamer v.1.01a (the 'a' means 'alpha')
|
# ComicBook Renamer v1.02.a (the 'a' means 'alpha')
|
||||||
|
|
||||||
# This is an add-on script for SABnzbd
|
# This is an add-on script for SABnzbd
|
||||||
# Used in conjunction with several other scripts
|
# Used in conjunction with several other scripts
|
||||||
|
@ -41,13 +41,13 @@ comdir = '/mount/mediavg/Comics/'
|
||||||
mylaron = "yes"
|
mylaron = "yes"
|
||||||
|
|
||||||
# Replace spaces?
|
# Replace spaces?
|
||||||
repblank = "yes"
|
repblank = "no"
|
||||||
# If 'yes', what character do you want me to replace with.
|
# If 'yes', what character do you want me to replace with.
|
||||||
# - Be careful, weird characters will bugger things up and there's no
|
# - Be careful, weird characters will bugger things up and there's no
|
||||||
# also be sure to put the character inbetween single quotations.
|
# also be sure to put the character inbetween single quotations.
|
||||||
# NB. this doesn't work...currently only is set for to replace spaces
|
# NB. this doesn't work...currently only is set for to replace spaces
|
||||||
# with _
|
# with _
|
||||||
repwith = '_'
|
repwith = " "
|
||||||
|
|
||||||
# Remove crap from filename (ie. c2c, noads, rlsgroup, pxcount, etc)
|
# Remove crap from filename (ie. c2c, noads, rlsgroup, pxcount, etc)
|
||||||
# If this is set to "no", filename will not be renamed at all.
|
# If this is set to "no", filename will not be renamed at all.
|
||||||
|
@ -87,7 +87,19 @@ else:
|
||||||
filen = filen.replace('_',' ')
|
filen = filen.replace('_',' ')
|
||||||
lengthfile = len(filen) - 4
|
lengthfile = len(filen) - 4
|
||||||
#if filen[:-4] == ".cbr" or filen[:-4] == ".cbz": filen[:lengthfile]
|
#if filen[:-4] == ".cbr" or filen[:-4] == ".cbz": filen[:lengthfile]
|
||||||
print ("Mylar - ComicRenamer Script - v1.0a")
|
print ("Mylar - ComicRenamer Script - v1.02.a")
|
||||||
|
print ("settings confirmation")
|
||||||
|
print ("---------------------")
|
||||||
|
print ("Mylar enabled: " + str(mylaron))
|
||||||
|
if str(mylaron) == "yes":
|
||||||
|
print ("Append SeriesYear/ComicYear to folder/filename : " + str(comicyearopt))
|
||||||
|
print ("Comic Directory : " + str(comdir))
|
||||||
|
print ("Zero supression set to : " + str(zerosup) + " digits")
|
||||||
|
print ("Replace Spaces enabled : " + str(repblank))
|
||||||
|
if repblank == "yes":
|
||||||
|
print ("Character to replace spaces with : " + str(repwith))
|
||||||
|
print ("Remove extra stuff : " + str(remcrap))
|
||||||
|
print ("-------------------------")
|
||||||
print ("passed name from SAB: " + str(filen) )
|
print ("passed name from SAB: " + str(filen) )
|
||||||
#print ("extension of file: " + str(fullp) )
|
#print ("extension of file: " + str(fullp) )
|
||||||
#let's narrow search down - take out year (2010), (2011), etc
|
#let's narrow search down - take out year (2010), (2011), etc
|
||||||
|
@ -96,7 +108,7 @@ print ("passed name from SAB: " + str(filen) )
|
||||||
comlen = filen.find(' (')
|
comlen = filen.find(' (')
|
||||||
comsub = filen[:comlen]
|
comsub = filen[:comlen]
|
||||||
#print("first bracket occurs at position: " + str(comlen))
|
#print("first bracket occurs at position: " + str(comlen))
|
||||||
print("actual name with iss: " + str(comsub))
|
print("actual name with issue: " + str(comsub))
|
||||||
yrstart = int(comlen + 2)
|
yrstart = int(comlen + 2)
|
||||||
#print ("series year starts at position: " + str(yrstart))
|
#print ("series year starts at position: " + str(yrstart))
|
||||||
lenyear = len(filen)
|
lenyear = len(filen)
|
||||||
|
@ -159,29 +171,24 @@ else:
|
||||||
|
|
||||||
# replace section
|
# replace section
|
||||||
if remcrap == "no": compath = str(comdir) + sys.argv[3]
|
if remcrap == "no": compath = str(comdir) + sys.argv[3]
|
||||||
else:
|
if remcrap == "yes":
|
||||||
compath = str(comdir) + str(comyx)
|
compath = str(comdir) + str(comyx)
|
||||||
|
|
||||||
if comicyearopt == "yes":
|
if comicyearopt == "yes":
|
||||||
if comyear == "":
|
if comyear == "":
|
||||||
comyear = "2012"
|
comyear = "2012"
|
||||||
comyear = "(" + str(comyear) + ")"
|
comyear = "(" + str(comyear) + ")"
|
||||||
compath = str(compath) + " " + str(comyear)
|
compath = str(compath) + " " + str(comyear)
|
||||||
comicname = str(comyx) + " " + str(prettycomiss) + " " + str(issyear)
|
comicname = str(comyx) + " " + str(prettycomiss) + " " + str(issyear)
|
||||||
else:
|
if comicyearopt == "no":
|
||||||
comicname = str(comyx) + " " + str(prettycomiss)
|
comicname = str(comyx) + " " + str(prettycomiss)
|
||||||
|
|
||||||
if repblank == "yes":
|
if repblank == "yes":
|
||||||
comyx = comyx.replace(' ', '_' )
|
comyx = comyx.replace(' ', str(repwith) )
|
||||||
filen = filen.replace(' ', '_' )
|
filen = filen.replace(' ', str(repwith) )
|
||||||
comicname = comicname.replace(' ', '_' )
|
comicname = comicname.replace(' ', str(repwith) )
|
||||||
compath = str(comdir) + str(comyx)
|
compath = str(comdir) + str(comyx)
|
||||||
if comicyearopt == "yes":
|
if comicyearopt == "yes":
|
||||||
compath = str(compath) + '_' + str(comyear)
|
compath = str(compath) + str(repwith) + str(comyear)
|
||||||
else:
|
|
||||||
compath = str(comdir) + str(comyx)
|
|
||||||
if comicyearopt == "yes":
|
|
||||||
compath = str(compath) + ' ' + str(comyear)
|
|
||||||
|
|
||||||
print ("The directory should be: " + str(compath))
|
print ("The directory should be: " + str(compath))
|
||||||
print ("filename should be: " + str(comicname) )
|
print ("filename should be: " + str(comicname) )
|
||||||
|
@ -209,12 +216,14 @@ matches = []
|
||||||
for root, dirnames, filenames in os.walk(maindir):
|
for root, dirnames, filenames in os.walk(maindir):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
if filename.lower().endswith(extensions):
|
if filename.lower().endswith(extensions):
|
||||||
confile = filename.replace(' ','_')
|
if repblank == "yes":
|
||||||
|
confile = filename.replace(' ','_')
|
||||||
|
else: confile = filename.replace('_', ' ')
|
||||||
if str(comyx).lower() in str(confile).lower():
|
if str(comyx).lower() in str(confile).lower():
|
||||||
#print ("Found: " + str(filename))
|
print ("Found: " + str(filename))
|
||||||
ext = os.path.splitext(filename)[1]
|
ext = os.path.splitext(filename)[1]
|
||||||
newf = str(comicname) + str(ext).lower()
|
newf = str(comicname) + str(ext).lower()
|
||||||
print ("New filename: " + str(newf) )
|
print ("--New filename: " + str(newf) )
|
||||||
src_file = os.path.join(maindir, filename)
|
src_file = os.path.join(maindir, filename)
|
||||||
dst_file = os.path.join(compath, newf)
|
dst_file = os.path.join(compath, newf)
|
||||||
shutil.move(src_file, dst_file)
|
shutil.move(src_file, dst_file)
|
||||||
|
|
Loading…
Add table
Reference in a new issue