From 009c8bd2dff12a696be3b55d4de134cc9074ff55 Mon Sep 17 00:00:00 2001 From: Christopher Rosell Date: Mon, 27 Aug 2012 13:11:19 +0200 Subject: livestreamer.plugins.gomtv: Handle main page URL. --- src/livestreamer/plugins/gomtv.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/livestreamer/plugins/gomtv.py b/src/livestreamer/plugins/gomtv.py index 3c8562c..bdfbbec 100644 --- a/src/livestreamer/plugins/gomtv.py +++ b/src/livestreamer/plugins/gomtv.py @@ -21,7 +21,7 @@ limitations under the License. """ -from livestreamer.compat import str, bytes, urlencode, urllib, cookies, cookiejar +from livestreamer.compat import str, bytes, urlencode, urllib, urlparse, cookies, cookiejar from livestreamer.plugins import Plugin, PluginError, NoStreamsError from livestreamer.stream import HTTPStream from livestreamer.utils import urlget @@ -30,6 +30,11 @@ from livestreamer.options import Options import xml.dom.minidom, re class GomTV(Plugin): + BaseURL = "http://www.gomtv.net" + LiveURL = BaseURL + "/main/goLive.gom" + LoginURL = "https://ssl.gomtv.net/userinfo/loginProcess.gom" + LoginCheckURL = BaseURL + "/forum/list.gom?m=my" + options = Options({ "cookie": None, "username": None, @@ -40,6 +45,15 @@ class GomTV(Plugin): def can_handle_url(self, url): return "gomtv.net" in url + def __init__(self, url): + parsed = urlparse(url) + + # Attempt to resolve current live URL if main page is passed + if len(parsed.path) <= 1: + url = self.LiveURL + + Plugin.__init__(self, url) + def _get_streams(self): options = self.options # Setting urllib up so that we can store cookies @@ -98,11 +112,11 @@ class GomTV(Plugin): "mb_password": password } data = bytes(urlencode(values), "ascii") - headers = {"Referer": "http://www.gomtv.net/"} - request = urllib.Request("https://ssl.gomtv.net/userinfo/loginProcess.gom", data, headers) + headers = {"Referer": self.BaseURL} + request = urllib.Request(self.LoginURL, data, headers) urlget(request, opener=self.opener) - req = urllib.Request("http://www.gomtv.net/forum/list.gom?m=my") + req = urllib.Request(self.LoginCheckURL) if b"Please need login" in urlget(req, opener=self.opener): raise PluginError("Authentication failed") -- cgit v1.2.3