Re: [Imdbpy-help] TV series with unknown episode numbers

2013-02-09 Thread Davide Alberani
On Fri, Feb 8, 2013 at 9:02 AM, Mike Castle dalg...@gmail.com wrote:

 Basically, every episode in the unknown season gets number -1.
 Fortunately they're all still there in the 'episdode -1' key, so just
 extract them.

Great, I've included it in the repository version.

Thank you very much!


-- 
Davide Alberani davide.alber...@gmail.com  [PGP KeyID: 0x465BFD47]
http://www.mimante.net/

--
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
___
Imdbpy-help mailing list
Imdbpy-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-help


Re: [Imdbpy-help] TV series with unknown episode numbers

2013-02-08 Thread Mike Castle
So this problem has returned.

I hadn't been actually using imdbpy in a while, but I think this is a
result of the rewrite that happened 2012-01-29


This seems to fix it.  I'm trying to make the code a bit more
resilient, but I'm not sure it needs it.  so you can probably simplify
as needed.

The show I was using to test was 0441718

Basically, every episode in the unknown season gets number -1.
Fortunately they're all still there in the 'episdode -1' key, so just
extract them.

diff -r 58ce09901775 imdb/parser/http/movieParser.py
--- a/imdb/parser/http/movieParser.py   Thu Jan 24 22:34:38 2013 +0100
+++ b/imdb/parser/http/movieParser.py   Thu Feb 07 23:52:54 2013 -0800
@@ -1486,6 +1486,14 @@
 try: selected_season = int(selected_season)
 except: pass
 nd = {selected_season: {}}
+if 'episode -1' in data:
+  counter = 1
+  for episode in data['episode -1']:
+while 'episode %d' % counter in data:
+  counter += 1
+k = 'episode %d' % counter
+data[k] = [episode]
+  del data['episode -1']
 for episode_nr, episode in data.iteritems():
 if not (episode and episode[0] and
 episode_nr.startswith('episode ')):

--
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
___
Imdbpy-help mailing list
Imdbpy-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-help


Re: [Imdbpy-help] TV series with unknown episode numbers

2010-06-27 Thread Davide Alberani
On Jun 27, Mike Castle dalg...@gmail.com wrote:

 I assume that the bit that processes XML or whatever would be the
 ideal place to have a counter to keep track of it?

Sure, or - even better - rethink the data structure: after all,
maybe we don't really need a dictionary of dictionaries to store
seasons/episodes.
The current choice was probably made to accomodate things like
unknown season or episode 0, but maybe we don't need these
pieces of information and move to a list of lists or a dictionary
of lists.

 But I was busy and didn't have time to figure out your entire
 code base.   :-

Feel free to poke around, clone/fork the repository, and ask if
you need help!

 For a personal fix, I ended up using just an integer
  [...]
 I've not yet looked at yours, though.

It does the same. :-)

 I suppose on of the problems with this is that there is no good
 way to guarantee an order.

That's why there are the sortedSeasons and sortedEpisodes
functions in the 'helpers' module (but they can't guarantee
to return the same order you've read on the web page).

Hmmm... I've to think more carefully about it, but right now
I'm inclined to use a dictionary of lists (keeping the 'season'
a key in a dictionary - when possible an integer - and the list
of episodes as its values).

E.g., for movie['episodes']:
  {1: [Movie1.1, Movie1.2, ...],
   2: [Movie2.1, Movie2.2, ...],
   'unknown': [MovieX.1, MovieX.2, ...]}

Where MovieX.Y obviously are Movie instance, like now.

What do you think?


Thanks for your help!
-- 
Davide Alberani davide.alber...@gmail.com [GPG KeyID: 0x465BFD47]
http://www.mimante.net/

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Imdbpy-help mailing list
Imdbpy-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-help


Re: [Imdbpy-help] TV series with unknown episode numbers

2010-06-26 Thread Mike Castle
On Sat, Jun 26, 2010 at 1:01 AM, Davide Alberani
davide.alber...@gmail.com wrote:
 In fact it's not a great improvement: to tell the truth, the numer
 of the episode should not be computed in the _build_episode function (but
 right now I don't have time for a better solution, and anyway... this
 one works :-)

I concur; that's not the best place to keep it.  I assume that the bit
that processes XML or whatever would be the ideal place to have a
counter to keep track of it?  But I was busy and didn't have time to
figure out your entire code base.   :-

For a personal fix, I ended up using just an integer instead of the
unknownN type, mostly because the tool that I was writing needs an
integer, and it seemed silly to take an integer counter, turn it into
a string, only to have to parse it to turn it back into an integer
again.  I've not yet looked at yours, though.

I suppose on of the problems with this is that there is no good way to
guarantee an order.  I imagine that most of the time it will be the
same, but it'll be a the whim of the order that IMDB sends the data,
rather than anything that we can predetermine.

mrc

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Imdbpy-help mailing list
Imdbpy-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-help