How do you use "Use Extra Script AFTER Post-Processing"?

Information and Tutorials on features in Mylar and how to use it
Post Reply
Gauntlet
Posts: 6
Joined: Sun Dec 28, 2014 10:40 pm

How do you use "Use Extra Script AFTER Post-Processing"?

Post by Gauntlet »

I have written a simple Python script to change cbr's to cbz's so that they can store tags. Right now the script searches recursively through the comics directory for all cbr's and rar's and changes them. What I would like it to do is get the path to the comic that has just been post processed and transform it.

I have a few questions:
Does Mylar pass on the path info through the command line?
Is there a particular class structure Mylar tries to find in the script?
Is there a wiki or something where this info exists?

Link to scripts: https://github.com/Gauntlet/cbr2cbz
User avatar
evilhero
Site Admin
Posts: 2883
Joined: Sat Apr 20, 2013 3:43 pm
Contact:

Re: How do you use "Use Extra Script AFTER Post-Processing"?

Post by evilhero »

Gauntlet wrote:I have written a simple Python script to change cbr's to cbz's so that they can store tags. Right now the script searches recursively through the comics directory for all cbr's and rar's and changes them. What I would like it to do is get the path to the comic that has just been post processed and transform it.

I have a few questions:
Does Mylar pass on the path info through the command line?
Is there a particular class structure Mylar tries to find in the script?
Is there a wiki or something where this info exists?

Link to scripts: https://github.com/Gauntlet/cbr2cbz
The following is the list of items Mylar will pass back to any scripts (post post-processing):
folderp, nzbn, filen, metadata

Where:
folderp = folder location after move/rename
nzbn = original nzb name
filen = new filename
metadata = seriesmetadata { name, comicyear, comicid , issueid, issueyear, issue, publisher }

There's no class structure, but your script will have to account for the information being flung back to it (ie. make use of 'parameter=None' in the function declaration). What you do with that information is dependent on your script.

Unfortunately there's no wiki on this, but there is information posted within the forums here as well as on github.

I'm fully for creating your own scripts and doing things yourself et all, but did you realize that if you enable metatagging within Mylar (and make use of the ComicTagger program - which is the only tagger that supports CLI-based commands), Mylar will convert the cbr to cbz.

Mylar will uncompress the .cbr and in doing so tests the archive for errors, then zips them all up into the same filename but with a .cbz extension. It will then apply metatagging to the cbz using ComicTagger (it passes the IssueID directly from Mylar so it's a guaranteed match everytime). Not something you have to use, but just something you might want to be aware of ;)
Gauntlet
Posts: 6
Joined: Sun Dec 28, 2014 10:40 pm

Re: How do you use "Use Extra Script AFTER Post-Processing"?

Post by Gauntlet »

Thanks for the reply!
Yeah I knew about comictagger, I'll probably set it up soon.
The reason for writing my own script is that I started learning Python last week and I learn best by actually trying to do something with a real world outcome.
Learned about "#!/usr/bin/env python" that had me stumped for a little while, wouldn't have realised what it did if I hadn't accidentally come across it in some example code while looking something else up!

Finally got it working with Mylar. The fact the script silently fails (when executed by Mylar) if there are any errors made it difficult to figure out. Also every git pull reverted its file privileges to 664.

Weird thing is that the extraction and repacking is faster now than it was previously.

One final thing actually Mylar passes the following items to scripts:
nzbname, nzbpath, newfilename, newpath, metadata

Where:
nzbname = original nzb name
nzbpath = path to the nzb before Mylar moves it
newfilename = the name given to the file by Mylar
newpath = path to the file after Mylar has processed it
metadata = seriesmetadata { name, comicyear, comicid , issueid, issueyear, issue, publisher } (didn't use it but appears to be the same as you state from a casual glance).
Post Reply