From 44a6760d2bce175fc3ad3f77418886c71ea33746 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Tue, 5 Jun 2012 06:42:11 +0200 Subject: [PATCH] Resolve title for PutLocker and SockShare links --- resolvers/putlocker.py | 10 ++++++++-- resolvers/sockshare.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/resolvers/putlocker.py b/resolvers/putlocker.py index 2f1ff99..7ef9e06 100644 --- a/resolvers/putlocker.py +++ b/resolvers/putlocker.py @@ -24,10 +24,11 @@ def resolve(url): try: browser.select_form(nr=0) result = browser.submit() + page = result.read() except Exception, e: raise ResolverError("The file was removed, or the URL is incorrect.") - matches = re.search("playlist: '([^']+)'", result.read()) + matches = re.search("playlist: '([^']+)'", page) if matches is None: 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.") @@ -46,4 +47,9 @@ def resolve(url): video_file = matches.group(1) - return { 'video': video_file } + try: + video_title = re.search(']*>([^<]*)<\/strong><\/a>', page).group(1) + except: + raise ResolverError("Could not find the video title.") + + return { 'title': video_title, 'videos': { 'video': video_file } } diff --git a/resolvers/sockshare.py b/resolvers/sockshare.py index 6f0c527..32e5fab 100644 --- a/resolvers/sockshare.py +++ b/resolvers/sockshare.py @@ -24,10 +24,11 @@ def resolve(url): try: browser.select_form(nr=0) result = browser.submit() + page = result.read() except Exception, e: raise ResolverError("The file was removed, or the URL is incorrect.") - matches = re.search("playlist: '([^']+)'", result.read()) + matches = re.search("playlist: '([^']+)'", page) if matches is None: 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.") @@ -46,4 +47,9 @@ def resolve(url): video_file = matches.group(1) - return { 'video': video_file } + try: + video_title = re.search(']*>([^<]*)<\/strong><\/a>', page).group(1) + except: + raise ResolverError("Could not find the video title.") + + return { 'title': video_title, 'videos': { 'video': video_file } }