diff --git a/resolv/resolvers/filebox.py b/resolv/resolvers/filebox.py index 4400e5a..0fc14ed 100644 --- a/resolv/resolvers/filebox.py +++ b/resolv/resolvers/filebox.py @@ -1,5 +1,5 @@ import re, time, urllib2 -from resolv.shared import ResolverError, Task +from resolv.shared import ResolverError, TechnicalError, Task class FileboxTask(Task): result_type = "video" @@ -21,7 +21,7 @@ class FileboxTask(Task): contents = self.fetch_page("http://www.filebox.com/embed-%s-970x543.html" % video_id) except urllib2.URLError, e: self.state = "failed" - raise ResolverError("Could not retrieve the video page.") + raise TechnicalError("Could not retrieve the video page.") matches = re.search("url: '([^']+)',", contents) diff --git a/resolv/resolvers/mediafire.py b/resolv/resolvers/mediafire.py index bc5f405..a891ab1 100644 --- a/resolv/resolvers/mediafire.py +++ b/resolv/resolvers/mediafire.py @@ -1,5 +1,5 @@ import re, urllib2 -from resolv.shared import ResolverError, unescape, Task +from resolv.shared import ResolverError, TechnicalError, unescape, Task class MediafireTask(Task): result_type = "file" @@ -13,7 +13,7 @@ class MediafireTask(Task): contents = self.fetch_page(self.url) except urllib2.URLError, e: self.state = "failed" - raise ResolverError("Could not retrieve the specified URL.") + raise TechnicalError("Could not retrieve the specified URL.") if '
([^<]+)<\/title>', contents).group(1)) except: self.state = "failed" - raise ResolverError("Could not find the download title.") + raise TechnicalError("Could not find the download title.") file_dict = { 'url' : file_url, diff --git a/resolv/resolvers/onechannel.py b/resolv/resolvers/onechannel.py index ad9f5ad..164df22 100644 --- a/resolv/resolvers/onechannel.py +++ b/resolv/resolvers/onechannel.py @@ -1,5 +1,5 @@ import re, base64 -from resolv.shared import ResolverError, Task +from resolv.shared import ResolverError, TechnicalError, Task class OneChannelTask(Task): result_type = "url" @@ -19,7 +19,7 @@ class OneChannelTask(Task): real_url = base64.b64decode(matches.group(2)).strip() except TypeError: self.state = "failed" - raise ResolverError("The provided URL is malformed.") + raise TechnicalError("The provided URL is malformed.") self.results = { 'url': real_url } self.state = "finished" diff --git a/resolv/resolvers/putlocker.py b/resolv/resolvers/putlocker.py index 96e8058..8a66af4 100644 --- a/resolv/resolvers/putlocker.py +++ b/resolv/resolvers/putlocker.py @@ -1,5 +1,5 @@ import re -from resolv.shared import ResolverError, unescape, Task +from resolv.shared import ResolverError, TechnicalError, unescape, Task class PutlockerTask(Task): result_type = "video" @@ -13,7 +13,7 @@ class PutlockerTask(Task): import mechanize except ImportError: self.state = "failed" - raise ResolverError("The Python mechanize module is required to resolve PutLocker URLs.") + raise TechnicalError("The Python mechanize module is required to resolve PutLocker URLs.") matches = re.search("https?:\/\/(www\.)?putlocker\.com\/(file|embed)\/([A-Z0-9]+)", self.url) @@ -29,7 +29,7 @@ class PutlockerTask(Task): browser.open("http://putlocker.com/embed/%s" % video_id) except: self.state = "failed" - raise ResolverError("The PutLocker site could not be reached.") + raise TechnicalError("The PutLocker site could not be reached.") try: browser.select_form(nr=0) @@ -42,6 +42,7 @@ class PutlockerTask(Task): matches = re.search("playlist: '([^']+)'", page) if matches is None: + self.state = "failed" raise ResolverError("No playlist was found on the given URL; the PutLocker server for this file may be in maintenance mode, or the given URL may not be a video file. The PutLocker resolver currently only supports video links.") playlist = matches.group(1) @@ -50,7 +51,7 @@ class PutlockerTask(Task): browser.open("http://www.putlocker.com%s" % playlist) except: self.state = "failed" - raise ResolverError("The playlist file for the given URL could not be loaded.") + raise TechnicalError("The playlist file for the given URL could not be loaded.") matches = re.search("url=\"([^\"]+)\" type=\"video\/x-flv\"", browser.response().read()) @@ -64,7 +65,7 @@ class PutlockerTask(Task): video_title = unescape(re.search(']*>([^<]*)<\/strong><\/a>', page).group(1)) except: self.state = "failed" - raise ResolverError("Could not find the video title.") + raise TechnicalError("Could not find the video title.") stream_dict = { 'url' : video_file, diff --git a/resolv/resolvers/sockshare.py b/resolv/resolvers/sockshare.py index 3e34866..6d9e080 100644 --- a/resolv/resolvers/sockshare.py +++ b/resolv/resolvers/sockshare.py @@ -1,5 +1,5 @@ import re -from resolv.shared import ResolverError, unescape, Task +from resolv.shared import ResolverError, TechnicalError, unescape, Task class SockshareTask(Task): result_type = "video" @@ -13,7 +13,7 @@ class SockshareTask(Task): import mechanize except ImportError: self.state = "failed" - raise ResolverError("The Python mechanize module is required to resolve Sockshare URLs.") + raise TechnicalError("The Python mechanize module is required to resolve Sockshare URLs.") matches = re.search("https?:\/\/(www\.)?sockshare\.com\/(file|embed)\/([A-Z0-9]+)", self.url) @@ -29,7 +29,7 @@ class SockshareTask(Task): browser.open("http://sockshare.com/embed/%s" % video_id) except: self.state = "failed" - raise ResolverError("The Sockshare site could not be reached.") + raise TechnicalError("The Sockshare site could not be reached.") try: browser.select_form(nr=0) @@ -42,6 +42,7 @@ class SockshareTask(Task): matches = re.search("playlist: '([^']+)'", page) if matches is None: + self.state = "failed" raise ResolverError("No playlist was found on the given URL; the Sockshare server for this file may be in maintenance mode, or the given URL may not be a video file. The Sockshare resolver currently only supports video links.") playlist = matches.group(1) @@ -50,7 +51,7 @@ class SockshareTask(Task): browser.open("http://www.sockshare.com%s" % playlist) except: self.state = "failed" - raise ResolverError("The playlist file for the given URL could not be loaded.") + raise TechnicalError("The playlist file for the given URL could not be loaded.") matches = re.search("url=\"([^\"]+)\" type=\"video\/x-flv\"", browser.response().read()) @@ -64,7 +65,7 @@ class SockshareTask(Task): video_title = unescape(re.search(']*>([^<]*)<\/strong><\/a>', page).group(1)) except: self.state = "failed" - raise ResolverError("Could not find the video title.") + raise TechnicalError("Could not find the video title.") stream_dict = { 'url' : video_file, diff --git a/resolv/resolvers/youtube.py b/resolv/resolvers/youtube.py index a1cde41..d6f5b7c 100644 --- a/resolv/resolvers/youtube.py +++ b/resolv/resolvers/youtube.py @@ -1,5 +1,5 @@ import re, urllib, urllib2, urlparse -from resolv.shared import ResolverError, unescape, Task +from resolv.shared import ResolverError, TechnicalError, unescape, Task class YoutubeTask(Task): result_type = "video" @@ -19,7 +19,11 @@ class YoutubeTask(Task): contents = self.fetch_page(self.url) except urllib2.URLError, e: self.state = "failed" - raise ResolverError("Could not retrieve the specified URL.") + raise TechnicalError("Could not retrieve the specified URL.") + + if '', contents).group(1)) except: self.state = "failed" - raise ResolverError("Could not find the video title.") + raise TechnicalError("Could not find the video title.") self.results = { 'title': video_title, diff --git a/resolv/shared.py b/resolv/shared.py index 4c583a9..94ba755 100644 --- a/resolv/shared.py +++ b/resolv/shared.py @@ -11,6 +11,13 @@ class ResolverError(Exception): def __str__(self): return repr(self.val) + +class TechnicalError(Exception): + def __init__(self, value): + self.val = value + + def __str__(self): + return repr(self.val) class Task(): captcha = None diff --git a/setup.py b/setup.py index 639f629..93b19fa 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup setup(name='resolv', - version='1.1.0', + version='1.2.0', description='Module for resolving URLs from filehosters, video hosters, and other content hosters', author='Sven Slootweg', author_email='resolv@cryto.net',