public
Description: Simple to use TVDB (thetvdb.com) API in Python, and automatic TV episode namer
Homepage: http://dbr.lighthouseapp.com/projects/13342-tvdb_api/tickets
Clone URL: git://github.com/dbr/tvdb_api.git
Search Repo:
Moved cfile['showname'] (parsed showname from filename) to 
cfile['file_showname'] to deal with corrected showname from tvdb. Also now 
deals with tvdb_shownotfound exception
dbr (author)
Thu May 15 19:10:51 -0700 2008
commit  77c548eb9fd441bf66d0f8a281466f883669ccfe
tree    e3bef5b7c24d50506a2fc0d91d3c7f3e31520762
parent  5708b2b9433838d9d96a75f889aa266af102fd08
...
97
98
99
100
101
102
103
104
105
 
 
 
 
 
 
106
107
108
...
184
185
186
187
 
 
 
 
 
 
 
 
188
189
190
...
193
194
195
 
 
 
 
 
196
197
198
...
97
98
99
 
 
 
 
 
 
100
101
102
103
104
105
106
107
108
...
184
185
186
 
187
188
189
190
191
192
193
194
195
196
197
...
200
201
202
203
204
205
206
207
208
209
210
0
@@ -97,12 +97,12 @@
0
                 showname,seasno,epno = match.groups()
0
                 showname = showname.replace("."," ").strip()
0
                 seasno,epno = int(seasno), int(epno)
0
- allEps.append({ 'showname':showname,
0
- 'seasno':seasno,
0
- 'epno':epno,
0
- 'filepath':filepath,
0
- 'filename':filename,
0
- 'ext':ext
0
+ allEps.append({ 'file_showname':showname,
0
+ 'seasno':seasno,
0
+ 'epno':epno,
0
+ 'filepath':filepath,
0
+ 'filename':filename,
0
+ 'ext':ext
0
                              })
0
                 break
0
         else:
0
@@ -184,7 +184,14 @@
0
     for cfile in validFiles:
0
         
0
         # Ask for episode name from tvdb_api
0
- epname = t[ cfile['showname'] ][ cfile['seasno'] ][ cfile['epno'] ]['name']
0
+ try:
0
+ epname = t[ cfile['file_showname'] ][ cfile['seasno'] ][ cfile['epno'] ]['name']
0
+ except tvdb_shownotfound:
0
+ # No such show
0
+ epname = None
0
+ showname = None
0
+ finally:
0
+ showname = t[ cfile['file_showname'] ]['showname'] # get the corrected showname
0
         
0
         # Either use the found episode name, warn if not found
0
         if epname:
0
@@ -193,6 +200,11 @@
0
             cfile['epname'] = None
0
             sys.stderr.write("! Episode name not found for %s\n" % ( cfile ) )
0
         #end if epname
0
+
0
+ if showname:
0
+ cfile['showname'] = showname
0
+ else:
0
+ cfile['showname'] = cfile['file_showname'] # no corrected showname found, use one from filename
0
         
0
         # Format new filename, strip unwanted characters
0
         newname = formatName( cfile )

Comments

    No one has commented yet.