-p -t -m combination

View previous topic View next topic Go down

-p -t -m combination

Post  anomander on Sat Apr 20, 2013 7:44 am

It would be useful if you could combine -m metatadata definitions with the -p switch to query specifics

e.g. comictagger.py -p -m "series #issue (year)" blah.cbz

2000 AD #1234 (2012)

or some other way that is less ugly than grep or sed of a big data set (and prone to errors)
avatar
anomander

Posts : 74
Join date : 2013-03-28

View user profile

Back to top Go down

Re: -p -t -m combination

Post  ComicTagger on Sun Apr 21, 2013 2:35 pm

I set up the output of the "-p" to make it easy to parse with things like sed and egrep. I figure anybody at the level of using CT at the command-line level can handle this.

For others who might not know, simple one liner example to pull out the series name:

Code:
comictagger.py -p -t cr Green\ Arrow\ #019\ \(2013\).cbz|egrep "series:"|cut -f2- -d' '|xargs echo

To produce your example, you could make a script like this:

Code:
#!/bin/bash

# get the ComicRack tags from the given file
# (save the info for efficiency)
CT_OUTPUT=$(comictagger.py -t cr -p "$1")

series=$(echo "$CT_OUTPUT" |sed -n 's/\(^series:\s\{0,\}\)\(.*\)/\2/p')
year=$(echo "$CT_OUTPUT" |sed -n 's/\(^year:\s\{0,\}\)\(.*\)/\2/p')
issue=$(echo "$CT_OUTPUT" |sed -n 's/\(^issue:\s\{0,\}\)\(.*\)/\2/p')

echo "$series #$issue ($year)"


You can also write some python to access the comictaggerlib directly:
Code:

#!/usr/bin/python

import sys

from comictaggerlib.comicarchive import *
from comictaggerlib.settings import *
import comictaggerlib.utils

utils.fix_output_encoding()

settings = ComicTaggerSettings()
style = MetaDataStyle.CIX
filename = sys.argv[1]

ca = ComicArchive(filename, settings )
if ca.hasMetadata( style ):
   md = ca.readMetadata( style )
   print "{0} #{1} ({2})".format(md.series, md.issue, md.year)


See "inventory.py" here (https://code.google.com/p/comictagger/source/browse/#svn%2Ftrunk%2Fscripts) for a more complex example.

avatar
ComicTagger
Admin

Posts : 208
Join date : 2012-12-02

View user profile http://comictagger.forumotion.com

Back to top Go down

Re: -p -t -m combination

Post  anomander on Sun Apr 21, 2013 4:28 pm

The problem is the user has to jump though some hoops to make 100% sure your getting safe data.

For example it is perfectly viable to have a new line starting with series or year or day: in the comments/summary field resulting in two entrys, one of which being nonsense.

For sure you can get around this with some sanity checks or even safer using --raw and extrapolating the xml etc but once you get to that level you might as well do it direct and bypass CT.

Far better to ask CT for specific fields and only get that data back rather than placing the sanity check burden on the user.... hence this request.

avatar
anomander

Posts : 74
Join date : 2013-03-28

View user profile

Back to top Go down

Re: -p -t -m combination

Post  ComicTagger on Sun Apr 21, 2013 8:30 pm

I see your point. I hadn't considered that case you've brought up, which, while probably quite unlikely, is technically possible. I'll think about the about the request.

In the meantime, play with the Python example I gave above. You can run it outside of the context of the app proper, since your debian system has the comictagger library available for general use. Once you have the metadata structure you can print it out any way you want, very easily.

avatar
ComicTagger
Admin

Posts : 208
Join date : 2012-12-02

View user profile http://comictagger.forumotion.com

Back to top Go down

Re: -p -t -m combination

Post  anomander on Mon Apr 22, 2013 1:49 am

Excellent, will do.
avatar
anomander

Posts : 74
Join date : 2013-03-28

View user profile

Back to top Go down

Re: -p -t -m combination

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum