From f10d1824681be4eeda982c985d5148f9b87dd5ba Mon Sep 17 00:00:00 2001 From: mano3m <-> Date: Sat, 31 Aug 2013 17:20:22 +0200 Subject: [PATCH 1/4] Added Blu-ray.com backlog automation I missed a few movies, so I added backlog functionality to Blu-ray.com If you want to add all Blu-rays that ever came out to the wanted list, you can use this. Be careful with what you wish for :D --- .../providers/automation/bluray/__init__.py | 7 ++++ .../core/providers/automation/bluray/main.py | 37 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/couchpotato/core/providers/automation/bluray/__init__.py b/couchpotato/core/providers/automation/bluray/__init__.py index e0675247..a47deee1 100644 --- a/couchpotato/core/providers/automation/bluray/__init__.py +++ b/couchpotato/core/providers/automation/bluray/__init__.py @@ -18,6 +18,13 @@ config = [{ 'default': False, 'type': 'enabler', }, + { + 'name': 'backlog', + 'advanced': True, + 'description': 'Parses the history tables until the minimum movie year is reached. Note: only do this once!', + 'default': False, + 'type': 'bool', + }, ], }, ], diff --git a/couchpotato/core/providers/automation/bluray/main.py b/couchpotato/core/providers/automation/bluray/main.py index 235a1e5f..50a47d87 100644 --- a/couchpotato/core/providers/automation/bluray/main.py +++ b/couchpotato/core/providers/automation/bluray/main.py @@ -1,3 +1,4 @@ +from bs4 import BeautifulSoup from couchpotato.core.helpers.rss import RSS from couchpotato.core.helpers.variable import tryInt from couchpotato.core.logger import CPLog @@ -10,11 +11,47 @@ class Bluray(Automation, RSS): interval = 1800 rss_url = 'http://www.blu-ray.com/rss/newreleasesfeed.xml' + backlog_url = 'http://www.blu-ray.com/movies/movies.php?show=newreleases&page=%s' def getIMDBids(self): movies = [] + if self.conf('backlog'): + + page = 0 + while True: + page = page + 1 + + url = self.backlog_url % page + data = self.getHTMLData(url) + soup = BeautifulSoup(data) + + try: + # Stop if the release year is before the minimal year + page_year = soup.body.find_all('center')[3].table.tr.find_all('td', recursive=False)[3].h3.get_text().split(', ')[1] + if tryInt(page_year) < self.getMinimal('year'): + break + + for table in soup.body.find_all('center')[3].table.tr.find_all('td', recursive=False)[3].find_all('table')[1:20]: + name = table.h3.get_text().lower().split('blu-ray')[0].strip() + year = table.small.get_text().split('|')[1].strip() + + if not name.find('/') == -1: # make sure it is not a double movie release + continue + + if tryInt(year) < self.getMinimal('year'): + continue + + imdb = self.search(name, year) + + if imdb: + if self.isMinimalMovie(imdb): + movies.append(imdb['imdb']) + except: + log.debug('Error loading page: %s', page) + break + rss_movies = self.getRSSData(self.rss_url) for movie in rss_movies: From 00bb055474b0fb28336b29932e700fb5d0a299ea Mon Sep 17 00:00:00 2001 From: mano3m <-> Date: Sat, 31 Aug 2013 19:08:23 +0200 Subject: [PATCH 2/4] set backlog to False after backlog search --- couchpotato/core/providers/automation/bluray/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/couchpotato/core/providers/automation/bluray/main.py b/couchpotato/core/providers/automation/bluray/main.py index 50a47d87..335d7768 100644 --- a/couchpotato/core/providers/automation/bluray/main.py +++ b/couchpotato/core/providers/automation/bluray/main.py @@ -52,6 +52,8 @@ class Bluray(Automation, RSS): log.debug('Error loading page: %s', page) break + self.conf('backlog', value = False) + rss_movies = self.getRSSData(self.rss_url) for movie in rss_movies: From 116bc839fc75ca1523db2dad558b804e1b7a9c62 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 28 Sep 2013 19:12:05 +0200 Subject: [PATCH 3/4] Make description more clear --- couchpotato/core/providers/automation/bluray/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/providers/automation/bluray/__init__.py b/couchpotato/core/providers/automation/bluray/__init__.py index a47deee1..ed270056 100644 --- a/couchpotato/core/providers/automation/bluray/__init__.py +++ b/couchpotato/core/providers/automation/bluray/__init__.py @@ -21,7 +21,7 @@ config = [{ { 'name': 'backlog', 'advanced': True, - 'description': 'Parses the history tables until the minimum movie year is reached. Note: only do this once!', + 'description': 'Parses the history until the minimum movie year is reached. (Will be disabled once it has completed)', 'default': False, 'type': 'bool', }, From 7d4f9d60b1374f97c520fa7ef4eea676f9a0775c Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 28 Sep 2013 19:17:41 +0200 Subject: [PATCH 4/4] Code formating --- couchpotato/core/providers/automation/bluray/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/providers/automation/bluray/main.py b/couchpotato/core/providers/automation/bluray/main.py index 335d7768..d98557ec 100644 --- a/couchpotato/core/providers/automation/bluray/main.py +++ b/couchpotato/core/providers/automation/bluray/main.py @@ -29,11 +29,11 @@ class Bluray(Automation, RSS): try: # Stop if the release year is before the minimal year - page_year = soup.body.find_all('center')[3].table.tr.find_all('td', recursive=False)[3].h3.get_text().split(', ')[1] + page_year = soup.body.find_all('center')[3].table.tr.find_all('td', recursive = False)[3].h3.get_text().split(', ')[1] if tryInt(page_year) < self.getMinimal('year'): break - for table in soup.body.find_all('center')[3].table.tr.find_all('td', recursive=False)[3].find_all('table')[1:20]: + for table in soup.body.find_all('center')[3].table.tr.find_all('td', recursive = False)[3].find_all('table')[1:20]: name = table.h3.get_text().lower().split('blu-ray')[0].strip() year = table.small.get_text().split('|')[1].strip()