From c4495452be5ac0018037dad121bcaf0eb53c6c2a Mon Sep 17 00:00:00 2001 From: Rhys Williams Date: Fri, 27 Dec 2019 19:10:54 +0200 Subject: [PATCH 1/2] Added YTS Popular Automation. --- .../movie/providers/automation/yifypopular.py | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 couchpotato/core/media/movie/providers/automation/yifypopular.py diff --git a/couchpotato/core/media/movie/providers/automation/yifypopular.py b/couchpotato/core/media/movie/providers/automation/yifypopular.py new file mode 100644 index 0000000..2f2ea51 --- /dev/null +++ b/couchpotato/core/media/movie/providers/automation/yifypopular.py @@ -0,0 +1,82 @@ +import requests +from html.parser import HTMLParser +from couchpotato import fireEvent +from couchpotato.core.logger import CPLog +from couchpotato.core.media.movie.providers.automation.base import Automation + +log = CPLog(__name__) + +autoload = 'YTSPopular' + + +class YTSPopular(Automation): + + interval = 1800 + url = 'https://yts.lt/' + + def getIMDBids(self): + + movies = [] + source = self.getHTMLData(self.url) + + class MyHTMLParser(HTMLParser): + doparse = False + dotitle = False + doyear = False + currentmovie = {'title':"", 'year':""} + movies = [] + def handle_starttag(self, tag, attrs): + for attr in attrs: + self.doparse = (attr[0] == "id" and attr[1] == "popular-downloads") or self.doparse + self.dotitle = (attr[0] == "class" and attr[1] == "browse-movie-title" and self.doparse) + self.doyear = (attr[0] == "class" and attr[1] == "browse-movie-year" and self.doparse) + if (attr[0] == "class" and attr[1] == "home-movies"): + self.doparse = False + + def handle_endtag(self, tag): + self.dotitle = False + self.doyear = False + + def handle_data(self, data): + if (self.doparse): + if (self.dotitle): + self.dotitle = False + self.currentmovie['title'] = data + if (self.doyear): + self.doyear = False + self.currentmovie['year'] = data + self.movies.append(self.currentmovie) + self.currentmovie = {'title':"", 'year':""} + + def getMovies(self): + return self.movies + + parser = MyHTMLParser() + parser.feed(source) + for el in parser.getMovies(): + imdb = self.search(el['title'], el['year']) + if imdb and self.isMinimalMovie(imdb): + movies.append(imdb['imdb']) + + return movies + + +config = [{ + 'name': 'ytspopular', + 'groups': [ + { + 'tab': 'automation', + 'list': 'automation_providers', + 'name': 'ytspopular_automation', + 'label': 'YTS Popular', + 'description': 'Imports popular downloas as currently listed on YTS.', + 'options': [ + { + 'name': 'automation_enabled', + 'default': False, + 'type': 'enabler', + }, + ], + }, + ], +}] From 465edd3440ab41a2f84bd5c6d3593a9b3c968a5a Mon Sep 17 00:00:00 2001 From: Rhys Williams Date: Fri, 27 Dec 2019 20:01:38 +0200 Subject: [PATCH 2/2] Fixed python version issue for YTS. --- couchpotato/core/media/movie/providers/automation/yifypopular.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/couchpotato/core/media/movie/providers/automation/yifypopular.py b/couchpotato/core/media/movie/providers/automation/yifypopular.py index 2f2ea51..5794f1e 100644 --- a/couchpotato/core/media/movie/providers/automation/yifypopular.py +++ b/couchpotato/core/media/movie/providers/automation/yifypopular.py @@ -1,5 +1,4 @@ -import requests -from html.parser import HTMLParser +import HTMLParser from couchpotato import fireEvent from couchpotato.core.logger import CPLog from couchpotato.core.media.movie.providers.automation.base import Automation