Script updates
git-svn-id: http://comictagger.googlecode.com/svn/trunk@505 6c5673fe-1810-88d6-992b-cd32ca31540c
This commit is contained in:
parent
a9ee7c463b
commit
71ccf1eea8
@ -7,7 +7,7 @@ the setup.py file.
|
||||
|
||||
To run via the ComicTagger app, invoke:
|
||||
|
||||
# ComicTagger -S script.py [script args]
|
||||
# comictagger.py -S script.py [script args]
|
||||
|
||||
(This will work also for binary distributions on Mac and Windows. No need for
|
||||
an extra python install.)
|
||||
|
@ -18,7 +18,7 @@ def main():
|
||||
style = MetaDataStyle.CIX
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "usage: {0} comic_folder ".format(sys.argv[0])
|
||||
print >> sys.stderr, "usage: {0} comic_folder ".format(sys.argv[0])
|
||||
return
|
||||
|
||||
filelist = utils.get_recursive_filelist( sys.argv[1:] )
|
||||
@ -31,13 +31,15 @@ def main():
|
||||
ca = ComicArchive(filename, settings )
|
||||
if ca.seemsToBeAComicArchive() and ca.hasMetadata( style ):
|
||||
fmt_str = u"{{0:{0}}}".format(max_name_len)
|
||||
print fmt_str.format( filename ) + "\r",
|
||||
sys.stdout.flush()
|
||||
print >> sys.stderr, fmt_str.format( filename ) + "\r",
|
||||
sys.stderr.flush()
|
||||
comic_list.append((filename, ca.readMetadata( style )))
|
||||
max_name_len = max ( max_name_len, len(filename))
|
||||
|
||||
print fmt_str.format( "" ) + "\r",
|
||||
print "Found {0} tagged comics.".format( len(comic_list))
|
||||
print >> sys.stderr, fmt_str.format( "" ) + "\r",
|
||||
print "-----------------------------------------------"
|
||||
print "Found {0} comics with {1} tags".format( len(comic_list), MetaDataStyle.name[style])
|
||||
print "-----------------------------------------------"
|
||||
|
||||
#sort the list by series+issue+year, to put all the dupes together
|
||||
def makeKey(x):
|
||||
@ -49,8 +51,8 @@ def main():
|
||||
dupe_set = list()
|
||||
prev_key = ""
|
||||
for filename, md in comic_list:
|
||||
print fmt_str.format( filename ) + "\r",
|
||||
sys.stdout.flush()
|
||||
print >> sys.stderr, fmt_str.format( filename ) + "\r",
|
||||
sys.stderr.flush()
|
||||
|
||||
new_key = makeKey((filename, md))
|
||||
|
||||
@ -68,7 +70,7 @@ def main():
|
||||
|
||||
prev_key = new_key
|
||||
|
||||
print fmt_str.format( "" ) + "\r",
|
||||
print >> sys.stderr, fmt_str.format( "" ) + "\r",
|
||||
print "Found {0} duplicate sets".format( len(dupe_set_list))
|
||||
|
||||
for dupe_set in dupe_set_list:
|
||||
|
@ -1,6 +1,22 @@
|
||||
#!/usr/bin/python
|
||||
"""
|
||||
An example script using the comictagger library
|
||||
Print out a line-by-line list of basic tag info from all comics
|
||||
"""
|
||||
|
||||
"""
|
||||
Copyright 2012 Anthony Beville
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
import sys
|
||||
@ -18,7 +34,7 @@ def main():
|
||||
style = MetaDataStyle.CIX
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "usage: {0} comic_folder ".format(sys.argv[0])
|
||||
print >> sys.stderr, "usage: {0} comic_folder ".format(sys.argv[0])
|
||||
return
|
||||
|
||||
filelist = utils.get_recursive_filelist( sys.argv[1:] )
|
||||
@ -28,15 +44,16 @@ def main():
|
||||
max_name_len = 2
|
||||
for filename in filelist:
|
||||
ca = ComicArchive(filename, settings )
|
||||
#make a list of paired filenames and metadata objects
|
||||
metadata_list.append((filename, ca.readMetadata( style )))
|
||||
if ca.hasMetadata( style ):
|
||||
#make a list of paired filenames and metadata objects
|
||||
metadata_list.append((filename, ca.readMetadata( style )))
|
||||
|
||||
fmt_str = u"{{0:{0}}}".format(max_name_len)
|
||||
print >> sys.stderr, fmt_str.format( filename ) + "\r",
|
||||
sys.stderr.flush()
|
||||
max_name_len = max ( max_name_len, len(filename))
|
||||
|
||||
fmt_str = u"{{0:{0}}}".format(max_name_len)
|
||||
print fmt_str.format( filename ) + "\r",
|
||||
sys.stdout.flush()
|
||||
max_name_len = max ( max_name_len, len(filename))
|
||||
|
||||
print fmt_str.format( "" ) + "\r",
|
||||
print >> sys.stderr, fmt_str.format( "" ) + "\r",
|
||||
print "-----------------------------------------------"
|
||||
print "Found {0} comics with {1} tags".format( len(metadata_list), MetaDataStyle.name[style])
|
||||
print "-----------------------------------------------"
|
||||
@ -54,7 +71,7 @@ def main():
|
||||
# build a format string
|
||||
fmt_str = u"{0:" + str(w0) + "} {1:" + str(w1) + "} #{2:6} ({3})"
|
||||
|
||||
# now sort the list by series, and then issue
|
||||
# now sort the list by issue, and then series
|
||||
metadata_list.sort(key=lambda x: IssueString(x[1].issue).asString(3), reverse=False)
|
||||
metadata_list.sort(key=lambda x: unicode(x[1].series).lower()+str(x[1].year), reverse=False)
|
||||
|
||||
|
@ -1,10 +1,28 @@
|
||||
#!/usr/bin/python
|
||||
"""
|
||||
find all duplicate comics
|
||||
make some tree structures and symbolic links to comic files based on metadata
|
||||
oragnizing by date and series, in different trees
|
||||
"""
|
||||
|
||||
"""
|
||||
Copyright 2012 Anthony Beville
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import platform
|
||||
|
||||
from comictaggerlib.comicarchive import *
|
||||
from comictaggerlib.settings import *
|
||||
@ -27,10 +45,13 @@ def main():
|
||||
utils.fix_output_encoding()
|
||||
settings = ComicTaggerSettings()
|
||||
|
||||
style = MetaDataStyle.CBI
|
||||
|
||||
style = MetaDataStyle.CIX
|
||||
|
||||
if platform.system() == "Windows":
|
||||
print >> sys.stderr, "Sorry, this script works only on UNIX systems"
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print "usage: {0} comic_root link_root".format(sys.argv[0])
|
||||
print >> sys.stderr, "usage: {0} comic_root link_root".format(sys.argv[0])
|
||||
return
|
||||
|
||||
comic_root = sys.argv[1]
|
||||
@ -51,17 +72,17 @@ def main():
|
||||
comic_list.append((filename, ca.readMetadata( style )))
|
||||
|
||||
fmt_str = u"{{0:{0}}}".format(max_name_len)
|
||||
print fmt_str.format( filename ) + "\r",
|
||||
sys.stdout.flush()
|
||||
print >> sys.stderr, fmt_str.format( filename ) + "\r",
|
||||
sys.stderr.flush()
|
||||
max_name_len = max ( max_name_len, len(filename))
|
||||
|
||||
print fmt_str.format( "" )
|
||||
print >> sys.stderr, fmt_str.format( "" )
|
||||
print "Found {0} tagged comics.".format( len(comic_list))
|
||||
|
||||
# walk through the comic list and add subdirs and links for each one
|
||||
for filename, md in comic_list:
|
||||
print fmt_str.format( filename ) + "\r",
|
||||
sys.stdout.flush()
|
||||
print >> sys.stderr, fmt_str.format( filename ) + "\r",
|
||||
sys.stderr.flush()
|
||||
|
||||
#do date organizing:
|
||||
if md.month is not None:
|
||||
|
@ -5,13 +5,28 @@ and deleted. Walks recursivly through the given folders. Originals
|
||||
are kept in a subfolder at the level of the original
|
||||
"""
|
||||
|
||||
"""
|
||||
Copyright 2013 Anthony Beville
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import tempfile
|
||||
import zipfile
|
||||
import shutil
|
||||
|
||||
|
||||
from comictaggerlib.comicarchive import *
|
||||
from comictaggerlib.settings import *
|
||||
import comictagger.utils
|
||||
@ -19,13 +34,17 @@ import comictagger.utils
|
||||
subfolder_name = "PRE_AD_REMOVAL"
|
||||
unwanted_types = [ 'Deleted', 'Advertisment' ]
|
||||
|
||||
|
||||
def main():
|
||||
utils.fix_output_encoding()
|
||||
settings = ComicTaggerSettings()
|
||||
|
||||
# this can only work with files with ComicRack tags
|
||||
style = MetaDataStyle.CIX
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print >> sys.stderr, "usage: {0} comic_folder ".format(sys.argv[0])
|
||||
return
|
||||
|
||||
filelist = utils.get_recursive_filelist( sys.argv[1:] )
|
||||
|
||||
#first read in CIX metadata from all files, make a list of candidates
|
||||
@ -51,7 +70,7 @@ def main():
|
||||
#skip any of our generated subfolders...
|
||||
if os.path.basename(curr_folder) == subfolder_name:
|
||||
continue
|
||||
sys.stdout.write("Removing unwanted pages from " + filename)
|
||||
sys.out.write("Removing unwanted pages from " + filename)
|
||||
|
||||
# verify that we can write to current folder
|
||||
if not os.access(filename, os.W_OK):
|
||||
|
@ -2,8 +2,24 @@
|
||||
"""
|
||||
test archive cover against comicvine for a given issue ID
|
||||
"""
|
||||
|
||||
"""
|
||||
Copyright 2013 Anthony Beville
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
import sys
|
||||
sys.path.append("..")
|
||||
import os
|
||||
|
||||
import comictaggerlib.utils
|
||||
@ -18,19 +34,19 @@ def main():
|
||||
settings = ComicTaggerSettings()
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print "usage: {0} comicfile issueid".format(sys.argv[0])
|
||||
print >> sys.stderr, "usage: {0} comicfile issueid".format(sys.argv[0])
|
||||
return
|
||||
|
||||
filename = sys.argv[1]
|
||||
issue_id = sys.argv[2]
|
||||
|
||||
if not os.path.exists(filename):
|
||||
print opts.filename + ": not found!"
|
||||
print >> sys.stderr, opts.filename + ": not found!"
|
||||
return
|
||||
|
||||
ca = ComicArchive(filename, settings )
|
||||
if not ca.seemsToBeAComicArchive():
|
||||
print "Sorry, but "+ opts.filename + " is not a comic archive!"
|
||||
print >> sys.stderr, "Sorry, but "+ opts.filename + " is not a comic archive!"
|
||||
return
|
||||
|
||||
ii = IssueIdentifier( ca, settings )
|
||||
|
Loading…
Reference in New Issue
Block a user