Added option to dump raw metadata blocks

git-svn-id: http://comictagger.googlecode.com/svn/trunk@63 6c5673fe-1810-88d6-992b-cd32ca31540c
This commit is contained in:
beville@gmail.com 2012-11-19 20:28:19 +00:00
parent 1501e3f89c
commit 00e4f30c60
5 changed files with 37 additions and 17 deletions

View File

@ -489,17 +489,20 @@ class ComicArchive:
return len( self.getPageNameList( sort_list=False ) )
def readCBI( self ):
if ( not self.hasCBI() ):
raw_cbi = self.readRawCBI()
if raw_cbi is None:
return GenericMetadata()
cbi_string = self.archiver.getArchiveComment()
metadata = ComicBookInfo().metadataFromString( cbi_string )
return metadata
return ComicBookInfo().metadataFromString( raw_cbi )
def readRawCBI( self ):
if ( not self.hasCBI() ):
return None
return self.archiver.getArchiveComment()
def writeCBI( self, metadata ):
cbi_string = ComicBookInfo().stringFromMetadata( metadata )
self.archiver.setArchiveComment( cbi_string )
@ -507,16 +510,19 @@ class ComicArchive:
self.archiver.setArchiveComment( "" )
def readCIX( self ):
raw_cix = self.readRawCIX()
if raw_cix is None:
return GenericMetadata()
return ComicInfoXml().metadataFromString( raw_cix )
def readRawCIX( self ):
if not self.hasCIX():
print self.path, "doesn't has ComicInfo.xml data!"
return GenericMetadata()
return None
cix_string = self.archiver.readArchiveFile( self.ci_xml_filename )
return self.archiver.readArchiveFile( self.ci_xml_filename )
metadata = ComicInfoXml().metadataFromString( cix_string )
return metadata
def writeCIX(self, metadata):
if metadata is not None:

View File

@ -199,7 +199,8 @@ class GenericMetadata:
add_attr_string( "webLink" )
add_attr_string( "format" )
add_attr_string( "manga" )
add_attr_string( "blackAndWhite" )
if self.blackAndWhite:
add_attr_string( "blackAndWhite" )
add_attr_string( "maturityRating" )
add_attr_string( "storyArc" )
add_attr_string( "seriesGroup" )

View File

@ -85,6 +85,7 @@ If no options are given, {0} will run in windowed mode
self.dryrun = False
self.save_tags = False
self.parse_filename = False
self.raw = False
self.rename_file = False
self.file_list = []
@ -148,7 +149,7 @@ If no options are given, {0} will run in windowed mode
try:
opts, args = getopt.getopt(sys.argv[1:],
"hpdt:fm:vonsr",
[ "help", "print", "delete", "type=", "parsefilename", "metadata=", "verbose", "online", "dryrun", "save", "rename" ])
[ "help", "print", "delete", "type=", "parsefilename", "metadata=", "verbose", "online", "dryrun", "save", "rename" , "raw" ])
except getopt.GetoptError as err:
self.display_help_and_quit( str(err), 2 )
@ -175,6 +176,8 @@ If no options are given, {0} will run in windowed mode
self.rename_file = True
if o in ("-f", "--parsefilename"):
self.parse_filename = True
if o in ("--raw"):
self.raw = True
if o in ("-t", "--type"):
if a.lower() == "cr":
self.data_style = MetaDataStyle.CIX

View File

@ -25,6 +25,8 @@ import signal
import os
import traceback
import time
from pprint import pprint
import json
from PyQt4 import QtCore, QtGui
@ -95,12 +97,18 @@ def process_file_cli( filename, opts, settings ):
if opts.data_style is None or opts.data_style == MetaDataStyle.CIX:
if cix:
print "------ComicRack tags--------"
print u"{0}".format(ca.readCIX()).encode("utf-8")
if opts.raw:
print u"{0}".format(ca.readRawCIX()).encode("utf-8")
else:
print u"{0}".format(ca.readCIX()).encode("utf-8")
if opts.data_style is None or opts.data_style == MetaDataStyle.CBI:
if cbi:
print "------ComicBookLover tags--------"
print u"{0}".format(ca.readCBI()).encode("utf-8")
if opts.raw:
pprint(json.loads(ca.readRawCBI()))
else:
print u"{0}".format(ca.readCBI()).encode("utf-8")
elif opts.delete_tags:

View File

@ -33,6 +33,8 @@ Bugs
----------------
Unicode errors when piping or redirecting stdout
Broke windows installer graphics somehow
Windows zip and rar: set proper path for writing to archive
SERIOUS BUG: rebuilding zips!