I am trying to write an Episode scanner for Eyetv. After much poking and prodding, I managed to scan one show from a directory containing four shows. I am having trouble debugging the scanner, partly because I have just started picking up Python, and partly because I can’t figure out how to print any debug messages. I have tried scanning from the terminal with ~/Library/Application\ Support/Plex/Plex\ Media\ Server.app/Contents/MacOS/Plex\ Media\ Scanner -vrs , but I get none of my debug messages. Here is my code, adapted from another Eyetv scanner for movies. Suggestions welcome.
Edit
Well I figured out how to find the debug messages finally (The console.app under utilities in the Applications folder, for the next guy…), and my scanner finds all four eyetv recordings in my test folder. But, It places all four recordings in the same show. I have episodes of three different shows in the folder, but they all get lumped into the first show. Suggestions appreciated.
'''<br />
Created on Oct 19, 2011<br />
<br />
@author: croaker<br />
'''<br />
import re, os, os.path, sys<br />
import Media, VideoFiles, UnicodeHelper, unicodedata, plistlib<br />
<br />
def Scan(path, files, mediaList, subdirs):<br />
#ToRemove = []<br />
#paths = path.split('/')<br />
print("*********")<br />
if len(files) >= 1:<br />
if path.endswith(".eyetv") and not path.endswith("Live TV Buffer.eyetv"):<br />
pl = None<br />
OkRecording = None<br />
recording = None<br />
show = None<br />
ep = "0"<br />
season = "0"<br />
title = "Unknown"<br />
for i in files:<br />
#print(i)<br />
#Log("test")<br />
if i.endswith(".mpg"):<br />
recording = i<br />
if i.endswith(".eyetvp"):<br />
OkRecording = True<br />
pl = plistlib.readPlist(i)<br />
try: <br />
show = pl['epg info']['TITLE'].encode('utf-8')<br />
<br />
except: pass<br />
print("show: " + show)<br />
try: <br />
ep = pl['epg info']['EPISODENUM']<br />
print("Episode Number(Plist): " + str(ep))<br />
if ep == '':<br />
ep = 0<br />
#ep = "0"<br />
except: pass<br />
<br />
#Finish pulling data, check to see if it works<br />
#Ask on forums about python development environment<br />
try: <br />
season = pl['epg info']['SEASONID']<br />
print("Season(Plist): " + str(season))<br />
print(type(season))<br />
<br />
#season = "0"<br />
except: pass<br />
<br />
try: <br />
title = pl['epg info']['ABSTRACT'].encode('utf-8')<br />
print("Episode Title(Plist): " + title)<br />
if title == '':<br />
title = "Unknown"<br />
#title = "unknown"<br />
except: pass<br />
#print("Episode Title: " + title)<br />
#does eyetv (tvguide) store the year a recording was made?<br />
#try: year = int(pl['epg info'][<br />
tv_show = Media.Episode(show, season, ep, title)<br />
<br />
<br />
if OkRecording:<br />
<br />
#tvshow = Media.Episode(i)<br />
print("Adding: " + recording)<br />
print("show: " + show)<br />
print("Episode Number: " + str(ep))<br />
print("Season: " + str(season))<br />
print("Episode Title: " + title)<br />
tv_show.parts.append(recording)<br />
mediaList.append(tv_show)