update tvrss

This commit is contained in:
j 2007-03-02 20:44:43 +00:00
parent a9c8d43f6b
commit 0a8d0b2170
2 changed files with 53 additions and 27 deletions

View File

@ -170,9 +170,9 @@ class IMDb:
else: else:
IMDbDict['rating'] = -1 IMDbDict['rating'] = -1
#Votes #Votes
m = re.compile('<small>\(<a href="ratings">(.*?) votes</a>\)</small>', re.IGNORECASE).search(data) m = re.compile('<small>\(<a href="ratings">(.*?) votes</a>\)</small>', re.IGNORECASE).findall(data)
if m: if m:
IMDbDict['votes'] = int(m.group(1).replace(',', '')) IMDbDict['votes'] = int(m[0].replace(',', ''))
else: else:
IMDbDict['votes'] = -1 IMDbDict['votes'] = -1

View File

@ -9,6 +9,7 @@ import datetime
import time import time
import re import re
from urllib2 import urlopen from urllib2 import urlopen
from urllib import quote
import Image import Image
import StringIO import StringIO
@ -52,6 +53,17 @@ def get_episodedate(string):
return s[1].strip() return s[1].strip()
return None return None
def get_episode_string(string):
episode = get_episode(string)
season = get_season(string)
episodedate = get_episodedate(string)
estring = None
if season and episode:
estring = "S%02dE%02d" % (season, episode)
elif episodedate:
estring = episodedate
return estring
def choose_item(old, new): def choose_item(old, new):
if old['link'] == new['link']: if old['link'] == new['link']:
return False return False
@ -63,29 +75,50 @@ def choose_item(old, new):
return True return True
return False return False
def get_imdbdata(imdbid): def get_episodes(show_title):
thumbnail = None search_url = "http://tvrss.net/search/index.php?distribution_group=combined&show_name=%s&show_name_exact=true&filename=&date=&quality=&release_group=&mode=rss" % quote(show_title)
description='' data = read_url(search_url)
imdb = IMDb.parse(imdbid) fd = feedparser.parse(search_url)
if imdb: episodes = {}
poster = imdb['poster'] for t in fd.entries:
if poster != 'http://i.imdb.com/Heads/npa.gif': episode = get_episode_string(t['summary'])
log.debug("getting poster %s" % poster) episodes[episode] = t['enclosures'][0]['href']
return episodes
def get_thumbnail(url):
try: try:
thumbnail = read_url(poster) thumbnail = read_url(url)
im = Image.open(StringIO.StringIO(thumbnail)) im = Image.open(StringIO.StringIO(thumbnail))
out = StringIO.StringIO() out = StringIO.StringIO()
width = 100
height = int((100.0 / im.size[0]) * im.size[1])
im = im.resize((width, height))
im.crop((0,0,100,100)).convert().save(out, 'JPEG') im.crop((0,0,100,100)).convert().save(out, 'JPEG')
thumbnail = out.getvalue() thumbnail = out.getvalue()
except: except:
thumbnail = None thumbnail = None
if imdb['summary']: return thumbnail
description=imdb['summary']
def get_imdbdata(imdbid):
thumbnail = None
description=''
i = imdb.IMDb(imdbid).parse()
if i:
poster = i['poster']
if poster != 'http://i.imdb.com/Heads/npa.gif':
log.debug("getting poster %s" % poster)
thumbnail = get_thumbnail(poster)
if i['plot']:
description=i['plot']
elif i['plot_outline']:
description=i['plot_outline']
else: else:
description=imdb['tagline'] description=i['tagline']
return (imdb, description, thumbnail)
return (i, description, thumbnail)
else: else:
return(imdb, '', None) return(i, '', None)
def load(): def load():
log.debug("getting new shows from tvrss...") log.debug("getting new shows from tvrss...")
@ -93,14 +126,7 @@ def load():
shows = {} shows = {}
for item in feed['entries']: for item in feed['entries']:
show = get_show(item['description']) show = get_show(item['description'])
season = get_season(item['description']) estring = get_episode_string(item['description'])
episode = get_episode(item['description'])
episodedate = get_episodedate(item['description'])
estring = None
if season and episode:
estring = "S%02dE%02d" %(season, episode)
elif episodedate:
estring = episodedate
if estring: if estring:
if show and not hr_hdtv.search(item['title']): if show and not hr_hdtv.search(item['title']):
if shows.has_key(show): if shows.has_key(show):