Metadata/Handbrake CLI post-processing script failing

General discussion about Sick Beard or related topics

Metadata/Handbrake CLI post-processing script failing

Postby brooklynfall » Wed May 18, 2011 10:34 pm

Hey guys,

Trying to get this script I found on gist to run: https://gist.github.com/708284

I'm running SB (the most recent update) on Mac OS 10.6.7.

Code: Select all
#!/usr/bin/env python
import os, re, subprocess, sys
from xml.etree import ElementTree

retag = sys.argv[1] == "retag"
if retag:
    del sys.argv[1]

source = os.path.abspath(sys.argv[1])
extensionless = '.'.join(source.split('.')[:-1])
dest =  extensionless + '.m4v'

if not os.path.exists(dest):
    subprocess.check_call(["HandBrakeCLI", "-i", source, "-o", dest, "--preset", 'AppleTV'])
elif not retag:
    print "Output already exists at", dest
    sys.exit(0)
else:
    print "Retagging", dest

nfo = extensionless + ".nfo"
season = episode = title = plot = None
if os.path.exists(nfo):
    epi = ElementTree.parse(open(nfo))
    if 'xbmcmultiepisode' in epi.getroot().tag:
        epi = epi.find("episodedetails")
    season = epi.findtext("season")
    episode = epi.findtext("episode")
    title = epi.findtext("title")
    plot = epi.findtext("plot")
    if season is None or episode is None or title is None or plot is None:
        print ".nfo Missing item: %s %s %s" % (season, episode, title)
else:
    print "No .nfo, trying to extract from title"
    m = re.match(".* - (\d+)x(\d+) - (.*)\.[\w\d]{3}", source)
    if m:
        season, episode, title = m.groups()
    else:
        print "Couldn't match", source
srcdir = os.path.dirname(source)
# Always mark it as a TV show and name it.  Add the other fields if they're avialable
command = ["AtomicParsley",  dest, "--stik", 'TV Show', "--TVShowName", os.path.basename(srcdir)]
for flag, value in [("--TVSeasonNum", season), ("--TVEpisodeNum", episode), ("--TVEpisode", title),
        ("--title", title), ("--description", plot)]:
    if value is not None:
        command.append(flag)
        command.append(value)
subprocess.check_call(command)
tmp = [i for i in os.listdir(srcdir) if "-temp" in i]
assert len(tmp) == 1
os.rename(srcdir + "/" + tmp[0], dest)

os.system("""osascript << EOF
tell application "iTunes"
    launch
    with timeout of 30000 seconds
        add ("%s" as POSIX file)
    end timeout
end tell
EOF""" % dest)


Here's my debug log:
Code: Select all
May-19 00:15:03 INFO     CP Server Thread-4 :: Processing succeeded for /Users/[USERNAME]/Downloads/TV Shows/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv
May-19 00:15:03 INFO     CP Server Thread-4 :: Unable to run extra_script: 2
May-19 00:15:03 ERROR    CP Server Thread-4 :: Unknown value passed in, ignoring it:
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Absolute path to script: /Users/[USERNAME]/Sick-Beard/add_to_itunes.py
May-19 00:15:03 INFO     CP Server Thread-4 :: Executing command ['add_to_itunes.py', u'/Users/[USERNAME]/Downloads/TV Shows/Game of Thrones/Season 01/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv', u'/Users/[USERNAME]/Downloads/TV Shows/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv', '121361', '1', '5', '2011-05-15']
May-19 00:15:03 DEBUG    CP Server Thread-4 :: sickbeard.db: UPDATE tv_episodes SET status = ?, tvdbid = ?, airdate = ?, location = ?, description = ?, hasnfo = ?, hastbn = ?, name = ? WHERE season = ? AND showid = ? AND episode = ? with args [404, 3436441, 734272, u'/Users/[USERNAME]/Downloads/TV Shows/Game of Thrones/Season 01/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv', u'Incensed over news of Daenerys\u2019 alliance with the Dothrakis, Robert orders a preemptive strike on the Targaryens that drives a wedge in his relationship with Ned. A captive Tyrion helps Catelyn, but receives a cold reception at the Eyrie from her sister, Jon Arryn\u2019s widow Lysa. Sansa is charmed by the dashing Ser Loras Tyrell, a.k.a. the Knight of Flowers. Arya overhears a plot against her father.', False, False, u'The Wolf and the Lion', 1, 121361, 5]
May-19 00:15:03 DEBUG    CP Server Thread-4 :: STATUS IS 404
May-19 00:15:03 DEBUG    CP Server Thread-4 :: 121361: Saving episode details to database
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Notification for NMJ scan update not enabled, skipping this notification
May-19 00:15:03 DEBUG    CP Server Thread-4 :: sickbeard.db: INSERT INTO history (action, date, showid, season, episode, quality, resource, provider) VALUES (?,?,?,?,?,?,?,?) with args [404, '20110519001503', 121361, 1, 5, -1, u'/Users/[USERNAME]/Downloads/TV Shows/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv', -1]
May-19 00:15:03 DEBUG    CP Server Thread-4 :: sickbeard.db: UPDATE tv_episodes SET status = ?, tvdbid = ?, airdate = ?, location = ?, description = ?, hasnfo = ?, hastbn = ?, name = ? WHERE season = ? AND showid = ? AND episode = ? with args [404, 3436441, 734272, u'/Users/[USERNAME]/Downloads/TV Shows/Game of Thrones/Season 01/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv', u'Incensed over news of Daenerys\u2019 alliance with the Dothrakis, Robert orders a preemptive strike on the Targaryens that drives a wedge in his relationship with Ned. A captive Tyrion helps Catelyn, but receives a cold reception at the Eyrie from her sister, Jon Arryn\u2019s widow Lysa. Sansa is charmed by the dashing Ser Loras Tyrell, a.k.a. the Knight of Flowers. Arya overhears a plot against her father.', False, False, u'The Wolf and the Lion', 1, 121361, 5]
May-19 00:15:03 DEBUG    CP Server Thread-4 :: STATUS IS 404
May-19 00:15:03 DEBUG    CP Server Thread-4 :: 121361: Saving episode details to database
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Setting permissions for /Users/[USERNAME]/Downloads/TV Shows/Game of Thrones/Season 01/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv to 644 as parent directory has 755
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Moving file from /Users/[USERNAME]/Downloads/TV Shows/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv to /Users/[USERNAME]/Downloads/TV Shows/Game of Thrones/Season 01/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv
May-19 00:15:03 DEBUG    CP Server Thread-4 :: sickbeard.db: UPDATE tv_episodes SET status = ?, tvdbid = ?, airdate = ?, location = ?, description = ?, hasnfo = ?, hastbn = ?, name = ? WHERE season = ? AND showid = ? AND episode = ? with args [404, 3436441, 734272, u'/Users/[USERNAME]/Downloads/TV Shows/Game of Thrones/Season 01/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv', u'Incensed over news of Daenerys\u2019 alliance with the Dothrakis, Robert orders a preemptive strike on the Targaryens that drives a wedge in his relationship with Ned. A captive Tyrion helps Catelyn, but receives a cold reception at the Eyrie from her sister, Jon Arryn\u2019s widow Lysa. Sansa is charmed by the dashing Ser Loras Tyrell, a.k.a. the Knight of Flowers. Arya overhears a plot against her father.', False, False, u'The Wolf and the Lion', 1, 121361, 5]
May-19 00:15:03 DEBUG    CP Server Thread-4 :: STATUS IS 404
May-19 00:15:03 DEBUG    CP Server Thread-4 :: 121361: Saving episode details to database
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Destination folder for this episode: /Users/[USERNAME]/Downloads/TV Shows/Game of Thrones/Season 01
May-19 00:15:03 DEBUG    CP Server Thread-4 :: There were no files associated with /Users/[USERNAME]/Downloads/TV Shows/Game of Thrones/Season 01/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv, not deleting anything
May-19 00:15:03 DEBUG    CP Server Thread-4 :: File /Users/[USERNAME]/Downloads/TV Shows/Game of Thrones/Season 01/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv doesn't exist so there's no worries about replacing it
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Is ep a priority download: False
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Quality of the episode we're processing: 4
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv looks like it has quality HD TV, using that
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Looking up quality for name Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv, got HD TV
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Looking up quality for name TV Shows, got Unknown
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Retrieving episode object for 1x5
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Loading show object for tvdb_id 121361
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Lookup successful, using tvdb id 121361
May-19 00:15:03 DEBUG    CP Server Thread-4 :: sickbeard.db: SELECT * FROM tv_shows WHERE show_name LIKE ? OR tvr_name LIKE ? with args [u'Game of Thrones', u'Game of Thrones']
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Looking up Game of Thrones in the DB
May-19 00:15:03 DEBUG    CP Server Thread-4 :: cache.db: SELECT show_name, tvdb_id FROM scene_exceptions
May-19 00:15:03 DEBUG    CP Server Thread-4 :: cache.db: SELECT tvdb_id FROM scene_exceptions WHERE LOWER(show_name) = ? with args [u'game of thrones']
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Checking scene exceptions for a match on Game of Thrones
May-19 00:15:03 DEBUG    CP Server Thread-4 :: Parsed /Users/[USERNAME]/Downloads/TV Shows/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv into Game of Thrones - S1E5 - 720p.HDTV.x264 (CTU) [ABD: False]
May-19 00:15:03 INFO     CP Server Thread-4 :: Analyzing name u'/Users/[USERNAME]/Downloads/TV Shows/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv'
May-19 00:15:03 DEBUG    CP Server Thread-4 :: sickbeard.db: SELECT * FROM history WHERE resource LIKE ? with args [u'TV_Shows']
May-19 00:15:03 INFO     CP Server Thread-4 :: Processing /Users/[USERNAME]/Downloads/TV Shows/Game.of.Thrones.S01E05.720p.HDTV.x264-CTU.mkv (None)


I have the script in my Sick-Beard folder in my home folder. In config.ini, the argument is
Code: Select all
 extra_scripts = add_to_itunes.py


I'm a semi-beginner here...any thoughts? Oh yeah, and the executables for AtomicParsley and Handbrake CLI are also in the Sick-Beard folder.

Thanks!

Philip
brooklynfall
 
Posts: 1
Joined: Wed May 18, 2011 10:24 pm

Re: Metadata/Handbrake CLI post-processing script failing

Postby rascalli » Wed May 18, 2011 11:05 pm

I think it is better to ask at the forum where you found this script .. as this is not a SB error/problem .. but something in the script is wrong
NL newsserver starting €44,40 a year

Image

Hope you will use my refereal link
rascalli
 
Posts: 4903
Joined: Tue Aug 10, 2010 2:26 pm

Re: Metadata/Handbrake CLI post-processing script failing

Postby peramus » Thu Oct 13, 2011 9:54 am

I found the same script. It's just a Gist page with absolutely NO information or instructions. Were you able to get this one working? Transcoding would be a HUGE capability for SickBeard.
peramus
 
Posts: 4
Joined: Thu Oct 13, 2011 9:50 am

Re: Metadata/Handbrake CLI post-processing script failing

Postby rascalli » Thu Oct 13, 2011 12:14 pm

did you try with the whole path ?

ALso make sure all apps needed in teh script are in teh same place as the script is looking for it
NL newsserver starting €44,40 a year

Image

Hope you will use my refereal link
rascalli
 
Posts: 4903
Joined: Tue Aug 10, 2010 2:26 pm

Re: Metadata/Handbrake CLI post-processing script failing

Postby peramus » Sun Oct 16, 2011 7:27 pm

I modified the script to use the whole path to the executable and modified the config.ini to point at the full path for add_to_itunes.py.

The following is the log from SABnzb. Anyone know what an error 13 refers to?
Loading config from /usr/local/SickBeard/autoProcessTV/autoProcessTV.cfg
Opening URL: http://localhost:8081/home/postprocess/ ... p.XviD-aAF
Processing folder /Users/peramus/Downloads/complete/Life.After.People.The.Series.S02E01.BDRip.XviD-aAF

Processing /Users/peramus/Downloads/complete/Life.After.People.The.Series.S02E01.BDRip.XviD-aAF/aaf-lap.s02e01.bdxvid.avi (Life.After.People.The.Series.S02E01.BDRip.XviD-aAF.nzb)

Found result in history: (83897, 2, [])

Parsed /Users/peramus/Downloads/complete/Life.After.People.The.Series.S02E01.BDRip.XviD-aAF/aaf-lap.s02e01.bdxvid.avi into Life After People The Series - S2E1 - BDRip.XviD (aAF) [ABD: False]

Checking scene exceptions for a match on Life After People The Series

Scene exception lookup got tvdb id 83897, using that

Loading show object for tvdb_id 83897

Retrieving episode object for 2x1

The old status had a quality in it, using that: SD DVD

SB snatched this episode so I'm marking it as priority

Is ep a priority download: True

There is no existing file so there's no worries about replacing it

This download is marked a priority download so I'm going to replace an existing file if I find one

Destination folder for this episode: /Volumes/Big Boy/TV Series/Life After People/Season 02

Season folder didn't exist, creating it

Moving file from /Users/peramus/Downloads/complete/Life.After.People.The.Series.S02E01.BDRip.XviD-aAF/aaf-lap.s02e01.bdxvid.avi to /Volumes/Big Boy/TV Series/Life After People/Season 02/Life After People - S02E01 - Wrath of God.avi

Executing command ['/usr/local/SickBeard/add_to_itunes.py', u'/Volumes/Big Boy/TV Series/Life After People/Season 02/Life After People - S02E01 - Wrath of God.avi', u'/Users/peramus/Downloads/complete/Life.After.People.The.Series.S02E01.BDRip.XviD-aAF/aaf-lap.s02e01.bdxvid.avi', '83897', '2', '1', '2010-01-05']

Absolute path to script: /usr/local/SickBeard/add_to_itunes.py

Unable to run extra_script: 13

Deleting folder /Users/peramus/Downloads/complete/Life.After.People.The.Series.S02E01.BDRip.XviD-aAF

Processing succeeded for /Users/peramus/Downloads/complete/Life.After.People.The.Series.S02E01.BDRip.XviD-aAF/aaf-lap.s02e01.bdxvid.avi

peramus
 
Posts: 4
Joined: Thu Oct 13, 2011 9:50 am

Re: Metadata/Handbrake CLI post-processing script failing

Postby peramus » Sun Oct 16, 2011 7:57 pm

Think I may have gotten it... Did a chmod +x on add_to_itunes.py it appears to be running now (at least it's taking a REALLY long time to process the latest download).
peramus
 
Posts: 4
Joined: Thu Oct 13, 2011 9:50 am

Re: Metadata/Handbrake CLI post-processing script failing

Postby peramus » Tue Nov 08, 2011 6:45 pm

Okay so the chmod +x worked. Only problem now is that all of the shows show up in iTunes as "Season 03" (or 04 or 5 or whatever) for the show name. Also it doesn't delete the old AVI file (I'm sure this is an easy edit however my python skills are LACKING!
peramus
 
Posts: 4
Joined: Thu Oct 13, 2011 9:50 am


Return to General

Who is online

Users browsing this forum: No registered users and 2 guests