Nzbirc/v1/Post Processor
From tiberious.org
Main_Page > NZBirc > v1 > Post Processor
Contents |
[edit]
Post Processor
A seperate php file, that takes an input from the 'handler script' of hellanzb (see Hellanzb config), and adds information into the bots and also parses the file based on rules
[edit]
Hellanzb Output
# Optional external handler script. hellanzb will run this script after post # processing an archive, with the following arguments: # # handler_script type archiveName destDir elapsedTime parMessage # # type: post processing result, either 'SUCCESS' or 'ERROR' # archiveName: name of the archive, e.g. 'Usenet_Post5' # destDir: where the archive ended up, e.g. '/ext2/usenet/Usenet_Post5' # elapsedTime: a pretty string showing how long post processing took, e.g. # '10m 37s' # parMessage: optional post processing message. e.g. '(No Pars)'
[edit]
Updating nzbirc
- Modify nzbHistory data with a 'downloaded' -> <bla> flag
- If failed: modifiy nzbHistory data with failed -> <bla>
- Modify worker.xml with nzbQError saying it failed (with parMessage) and stuffs
- Modify autotv with downloaded info ?? (leave to nzbHistory ?)
[edit]
File moving
[edit]
Match
- Category
- file [find]
- archiveName
- type
- parMessage
- id
[edit]
Actions
- Delete [files matching [regex's]]
- Rename
- regex match
- regex replace
- '(\s)' => '.'
- '([A-Z]+)' => 'strtolower($1)'
- Into Format eg:
- {show}.s{series}e{episode:02d}.{title}.{extension}
- {show} - {series}x{episode:02d} - {title}.{extension}
- Moved
- individual file [regex], previous renamed file
- all files
- to folder "/path/to/tv/{show}/series.{series:02d}/" or whatever
- {show} can have regex replace performed or not
- File server safe naming >> regex replace
[edit]
Curly Brackets
{var} gets replaced by $var['var'];
{var:02d} gets replaced by sprintf( '%02d', $var['var'] );
Based on a slightly modified version of my existing template engine in nzbirc (that will probably be put into the main prog as I need the {var:02d} stuffs)
[edit]
Get Info
- useTvrage
- useNzb
etc
[edit]
Needs
- Be able to run standalone
- Be able to run with nzbirc and communicate with it (xml file?)
[edit]
How my mind works
Below is how I came up with what I think works well
This is a kind of sample run of what will happen
-- CUSTOM --
if type == 'SUCCESS' then
getNzb
-- AUTO --
find file matches '/^\.msgid_(\d+)$/i' id
nzb = nzb(id[1])
-- CUSTOM --
if archiveName matches '/^(.+?) - (\d+)x(\d{2,})( - (.+))?$/i' [aM]
getTvVars
-- AUTO --
if tvrage
if nzb[url] matches '/^http:\/\/www.tvrage.com\/(.+)\/episodes\/(\d+)\//i' [tM]
vars = tvrage(tM[1], tM[2]) or fail
else
vars = tvrage(tM[1], aM[2], aM[3]) or fail
else
fail
if fail
vars = ['show' = aM[1], 'series' = aM[2], 'episode' = aM[3], 'title' = aM[5]]
-- CUSTOM --
find all file matches '/(\S+)\.(avi|mkv|mpg|ts|mp4|wmv|ogm)$/i' [fM]
foreach files as file
if file !matches '/sample/i' then
vars[extension] = fM[2]
from = [ ' ', 'A-Z', '\(Part (\d+)\)' ]
to = [ '.', 'a-z', ' $1' ]
-- AUTO --
vars = regexReplace( from, to, vars )
-- CUSTOM --
oFile = format( '{show}.s{series}e{episode:02d}.{title}.{extension}', vars )
oDir = format( '/path/to/tv/{show}/series.{series:02d}/', vars )
-- AUTO --
oFile = safeName( oFile )
foreach split( '/', oDir ) as dSplit
if !isdir dSplit then
mkdir dSplit
-- CUSTOM --
move file > oDir.oFile
Just the custom parts becomes:
if type == 'SUCCESS' then
getNzb
if nzb[category] == TV then
if archiveName matches '/^(.+?) - (\d+)x(\d{2,})( - (.+))?$/i' [aM]
getTvVars
find all file matches '/(\S+)\.(avi|mkv|mpg|ts|mp4|wmv|ogm)$/i' [fM]
foreach files as file
if file !matches '/sample/i' then
vars[extension] = fM[2]
from = [ ' ', 'A-Z', '\(Part (\d+)\)' ]
to = [ '.', 'a-z', ' $1' ]
if count files > 1 then
vars[title] += ' 1'
oFile = format( '{show}.s{series}e{episode:02d}.{title}.{extension}', vars )
oDir = format( '/path/to/tv/{show}/series.{series:02d}/', vars )
move file > oDir.oFile
Putting this into a simple set
if type = success
use nzb
if nzb[category] = tv
archiveName match '/^(.+?) - (\d+)x(\d{2,})( - (.+))?$/i'
use tvrage
find files match '/(\S+)\.(avi|mkv|mpg|ts|mp4|wmv|ogm)$/i' and exclude files match '/sample/i'
set vars[extension] = file extension
file format: '{show}.s{series}e{episode:02d}.{title}.{extension}'
move to dir
format: '/path/to/tv/{show}/series.{series:02d}/'
replace '/(\s)/' -> '.' '/([A-Z]+)/e' -> 'strtolower($1)' '/\((\d+)\)$/' -> ' $2'
[edit]
Final Solution (I think)
even simpler
useNzb
TV
useTvrage
archiveName: '/^(.+?) - (\d+)x(\d{2,})( - (.+))?$/i'
find Files: '/(\S+)\.(avi|mkv|mpg|ts|mp4|wmv|ogm)$/i'
exlude Files: '/sample/i'
vars
with * spacer: .
with * case: lowercase
with title '/\((\d+)\)$/' -> '$2'
file format: '{show}.s{series:02d}e{episode:02d}.{title}'
move file dir format: '/path/to/tv/{show}/series.{series:02d}/'
if move succ
delete archiveDir
lets try movies
useNzb
Movie
archiveName: '.+'
vars
with archiveName spacer: .
with archiveName case: lowercase
find Files '/\.(avi|mkv|wmv|iso|img|mds|mdf|bin|cue|mpg|ts|mp4|ogm|srt|sub|ssa|smi)$/i'
move file dir format: '/path/to/films/{archiveName}
find Files '/^(VIDEO_TS|VTS_(\d+)_(\d+)).(IFO|BUP|VOB)/i'
move file dir format: '/path/to/films/{archiveName}/VIDEO_TS/
find Dir '/^(VIDEO|AUDIO)_TS/i'
move dir dir format: '/path/to/films/{archiveName}
if move succ
delete archiveDir
