aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Christopher Rosell <chrippa@tanuki.se>2012-08-27 13:11:19 +0200
committerGravatar Christopher Rosell <chrippa@tanuki.se>2012-08-27 13:11:19 +0200
commit009c8bd2dff12a696be3b55d4de134cc9074ff55 (patch)
tree964716bf9ac4d3c20ea329b168a1068de1241a2a
parent2bf4a57b4402285d23a1e5ffe2f4c30f7d65ad9f (diff)
livestreamer.plugins.gomtv: Handle main page URL.
-rw-r--r--src/livestreamer/plugins/gomtv.py22
1 files 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")