diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-12 12:54:08 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-12 12:54:08 +0100 |
commit | 4422ff62686b28c72595409113f4085ef3f3d731 (patch) | |
tree | 73a1f3bbd14b6f289e93714481a3c5155c7460ac /module | |
parent | EgoFilesCom: regex updated (diff) | |
parent | Movie2kTo: fixed regex to be more reliable (diff) | |
download | pyload-4422ff62686b28c72595409113f4085ef3f3d731.tar.xz |
Merge pull request #41 from 4Christopher/stable
Wrote crypter plugin ChipDe and fixed Movie2kTo
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/crypter/ChipDe.py | 24 | ||||
-rw-r--r-- | module/plugins/crypter/Movie2kTo.py | 62 |
2 files changed, 59 insertions, 27 deletions
diff --git a/module/plugins/crypter/ChipDe.py b/module/plugins/crypter/ChipDe.py new file mode 100644 index 000000000..fcb84a300 --- /dev/null +++ b/module/plugins/crypter/ChipDe.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from module.plugins.Crypter import Crypter + +class ChipDe(Crypter): + __name__ = "ChipDe" + __type__ = "container" + __pattern__ = r"http://(?:www\.)?chip.de/video/.*\.html" + __version__ = "0.1" + __description__ = """Chip.de Container Plugin""" + __author_name__ = ('4Christopher') + __author_mail__ = ('4Christopher@gmx.de') + + def decrypt(self, pyfile): + self.html = self.load(pyfile.url) + try: + url = re.search(r'"(http://video.chip.de/\d+?/.*)"', self.html).group(1) + self.logDebug('The file URL is %s' % url) + except: + self.fail('Failed to find the URL') + + self.packages.append((self.pyfile.package().name, [ url ], self.pyfile.package().folder)) diff --git a/module/plugins/crypter/Movie2kTo.py b/module/plugins/crypter/Movie2kTo.py index a9cdb188b..c32f6f930 100644 --- a/module/plugins/crypter/Movie2kTo.py +++ b/module/plugins/crypter/Movie2kTo.py @@ -3,15 +3,17 @@ import re from module.plugins.Crypter import Crypter +from collections import defaultdict class Movie2kTo(Crypter): - __name__ = "Movie2kTo" - __type__ = "container" - __pattern__ = r"http://(?:www\.)?movie2k\.to/(.*)\.html" - __version__ = "0.2" - __config__ = [("accepted_hosters", "str", "List of accepted hosters", "Xvidstage, "), - ("whole_season", "bool", "Download whole season", "False"), - ("everything", "bool", "Download everything", "False")] + __name__ = 'Movie2kTo' + __type__ = 'container' + __pattern__ = r'http://(?:www\.)?movie2k\.to/(.*)\.html' + __version__ = '0.3' + __config__ = [('accepted_hosters', 'str', 'List of accepted hosters', 'Xvidstage, '), + ('whole_season', 'bool', 'Download whole season', 'False'), + ('everything', 'bool', 'Download everything', 'False'), + ('firstN', 'int', 'Download the first N files for each episode. The first file is probably all you will need.', '1')] __description__ = """Movie2k.to Container Plugin""" __author_name__ = ('4Christopher') __author_mail__ = ('4Christopher@gmx.de') @@ -21,7 +23,7 @@ class Movie2kTo(Crypter): SEASON_PATTERN = r'<div id="episodediv(\d+?)" style="display:(inline|none)">(.*?)</div>' EP_PATTERN = r'<option value="(.+?)"( selected)?>Episode\s*?(\d+?)</option>' BASE_URL = 'http://www.movie2k.to' - + def decrypt(self, pyfile): self.package = pyfile.package() self.folder = self.package.folder @@ -42,17 +44,18 @@ class Movie2kTo(Crypter): season_links += self.getInfoAndLinks('%s/%s' % (self.BASE_URL, url_path)) elif (whole_season and (season_sel == 'inline')) or everything: season_links += self.getInfoAndLinks('%s/%s' % (self.BASE_URL, url_path)) - self.packages.append(('%s: Season %s' % (self.name, season), season_links, 'Season %s' % season)) + self.logDebug(season_links) + self.packages.append(('%s: Season %s' % (self.name, season), season_links, 'Season %s' % season)) else: self.packages.append((self.package.name, self.getLinks(), self.package.folder)) - + def tvshow_number(self, number): if int(number) < 10: return '0%s' % number else: return number - + def name_tvshow(self, season, ep): return '%s S%sE%s' % (self.name, self.tvshow_number(season), self.tvshow_number(ep)) @@ -77,33 +80,38 @@ class Movie2kTo(Crypter): self.getInfo(url) return self.getLinks() + ## This function returns the links for one episode as list def getLinks(self): accepted_hosters = re.findall(r'\b(\w+?)\b', self.getConfig('accepted_hosters')) + firstN = self.getConfig('firstN') links = [] ## h_id: hoster_id of a possible hoster re_hoster_id_js = re.compile(r'links\[(\d+?)\].+ (.+?)</a>') - re_hoster_id_html = re.compile(r'<a href=".*?(\d{7}).*?".+? (.+?)</a>') + re_hoster_id_html = re.compile(r'</td><td.*?<a href=".*?(\d{7}).*?".+? (.+?)</a>') ## I assume that the ID is 7 digits longs if re_hoster_id_js.search(self.html): re_hoster_id = re_hoster_id_js + self.logDebug('Assuming that the ID can be found in a JavaScript section.') elif re_hoster_id_html.search(self.html): re_hoster_id = re_hoster_id_html + self.logDebug('Assuming that the ID can be found in a HTML section.') + count = defaultdict(int) for h_id, hoster in re_hoster_id.findall(self.html): + # self.logDebug('Hoster %s' % hoster) if hoster in accepted_hosters: - if h_id != self.id: - self.html = self.load('%s/tvshows-%s-%s.html' % (self.BASE_URL, h_id, self.name)) - else: - self.logDebug('This is already the right ID') - try: - url = re.search(r'<a target="_blank" href="(http://.*?)"', self.html).group(1) - self.logDebug('id: %s, %s: %s' % (h_id, hoster, url)) - links.append(url) - except: - self.logDebug('Failed to find the URL') - - # self.logDebug(links[-1]) ## Last link, this is probably everything - ## you will need - # links.append('http://localhost/IfTheProcessFunctionReturnsOnlyOneLinkItWillFail') + # self.logDebug('Accepted %s' % hoster) + count[hoster] += 1 + if count[hoster] <= firstN: + if h_id != self.id: + self.html = self.load('%s/tvshows-%s-%s.html' % (self.BASE_URL, h_id, self.name)) + else: + self.logDebug('This is already the right ID') + try: + url = re.search(r'<a target="_blank" href="(http://.*?)"', self.html).group(1) + self.logDebug('id: %s, %s: %s' % (h_id, hoster, url)) + links.append(url) + except: + self.logDebug('Failed to find the URL') + self.logDebug(links) - # return links[-1] return links |