Private GIT

Skip to content
Snippets Groups Projects
Commit 1393e6e6 authored by miigotu's avatar miigotu
Browse files

Merge pull request #2555 from SiCKRAGETV/imdbPopular-fixes

Change imdb url in imdbPopular to akas.imdb.com (same as used in imdb…
parents 8beebae7 5639ab30
Branches
Tags
No related merge requests found
...@@ -8,12 +8,20 @@ import sickbeard ...@@ -8,12 +8,20 @@ import sickbeard
from sickbeard import helpers from sickbeard import helpers
from sickrage.helper.encoding import ek from sickrage.helper.encoding import ek
# pylint: disable=C1001
class imdbPopular: class imdbPopular:
def __init__(self): def __init__(self):
"""Gets a list of most popular TV series from imdb"""
# Use akas.imdb.com, just like the imdb lib.
self.url = 'http://akas.imdb.com/search/title'
self.url = "http://www.imdb.com/search/title?at=0&sort=moviemeter&title_type=tv_series&year=%s,%s" % \ self.params = {
(date.today().year - 1, date.today().year + 1) 'at': 0,
'sort': 'moviemeter',
'title_type': 'tv_series',
'year': '%s,%s' % (date.today().year - 1, date.today().year + 1)
}
self.session = requests.Session() self.session = requests.Session()
...@@ -22,13 +30,13 @@ class imdbPopular: ...@@ -22,13 +30,13 @@ class imdbPopular:
popular_shows = [] popular_shows = []
data = helpers.getURL(self.url, session=self.session) data = helpers.getURL(self.url, session=self.session, params=self.params, headers={'Referer': 'http://akas.imdb.com/'})
if not data: if not data:
return None return None
soup = BeautifulSoup(data, 'html.parser') soup = BeautifulSoup(data, 'html.parser')
results = soup.find("table", {"class": "results"}) results = soup.find("table", {"class": "results"})
rows = results.find_all("tr"); rows = results.find_all("tr")
for row in rows: for row in rows:
show = {} show = {}
...@@ -54,10 +62,14 @@ class imdbPopular: ...@@ -54,10 +62,14 @@ class imdbPopular:
if rating_string: if rating_string:
rating_string = rating_string['title'] rating_string = rating_string['title']
matches = re.search(".* (.*)\/10.*\((.*)\).*", rating_string).groups() match = re.search(r".* (.*)\/10.*\((.*)\).*", rating_string)
if match:
matches = match.groups()
show['rating'] = matches[0] show['rating'] = matches[0]
show['votes'] = matches[1] show['votes'] = matches[1]
else:
show['rating'] = None
show['votes'] = None
else: else:
show['rating'] = None show['rating'] = None
show['votes'] = None show['votes'] = None
...@@ -67,7 +79,8 @@ class imdbPopular: ...@@ -67,7 +79,8 @@ class imdbPopular:
return popular_shows return popular_shows
def change_size(self, image_url, factor=3): @staticmethod
def change_size(image_url, factor=3):
match = re.search("^(.*)V1._(.{2})(.*?)_(.{2})(.*?),(.*?),(.*?),(.*?)_.jpg$", image_url) match = re.search("^(.*)V1._(.{2})(.*?)_(.{2})(.*?),(.*?),(.*?),(.*?)_.jpg$", image_url)
if match: if match:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment