First, look at this page, specifically the ``unknown'' season:

Now, run the following code (sys.path adjusted as necessary):

import sys
sys.path.insert(0, '/home/nexus/workspace/imdbpy')
import imdb

print imdb.VERSION
imdb_http = imdb.IMDb()
m = imdb_http.get_movie('0169455')   # Inside the Actor's Studio
imdb_http.update(m, 'episodes')
eps = m['episodes']
print len(eps['unknown']),  eps['unknown'].keys()

Output is:
1 ['unknown']

the 'unknown' season has only 1 episode, rather than the expected 9.

I suspect that the proper way to fix this is by submitting updates to
IMDB.  But, anyway this could be adjusted for in code?  Maybe episodes
could be unknown1, unknown2, unknown3, etc.... ?

Here's a hack for that, though we all know globals are evil

--- a/imdb/parser/http/   Sun Jun 20 09:37:51 2010 +0200
+++ b/imdb/parser/http/   Thu Jun 24 21:15:22 2010 -0700
@@ -1573,6 +1573,7 @@
             return {}
         return {'merchandising links': data}

+unknown_eps = 0

 def _build_episode(x):
     """Create a Movie object for a given series' episode."""
@@ -1599,8 +1600,10 @@
         e['season'] = int(season[7:])
         e['episode'] = int(episode[8:])
+        global unknown_eps
+        unknown_eps += 1
         e['season'] = 'unknown'
-        e['episode'] = 'unknown'
+        e['episode'] = 'unknown%d' % unknown_eps
     plot = x.get('plot')
     if plot:
         e['plot'] = plot.strip()

With this, the output is:
9 ['unknown2', 'unknown3', 'unknown1', 'unknown6', 'unknown7',
'unknown4', 'unknown5', 'unknown8', 'unknown9']

I imagine there's a much better way of achieving this.


ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win:
Imdbpy-help mailing list

Reply via email to