Add www.oppetarkiv.se support
authorMikael Frykholm <mikael@frykholm.com>
Tue, 16 Apr 2013 10:16:43 +0000 (12:16 +0200)
committerMikael Frykholm <mikael@frykholm.com>
Tue, 16 Apr 2013 10:16:43 +0000 (12:16 +0200)
Simple fix for now, will refactor and clean up "later".

svtplaydump.py

index 5348f6118f86d6cb57357700bdb0d24ca9866f15..16516a8c1e92823f0e516924915376fc75605681 100755 (executable)
@@ -40,10 +40,13 @@ def scrape_player_page(url, title):
     video = {}
     soup = BeautifulSoup(requests.get(url).text)
     video_player = soup.body('a',{'data-json-href':True})[0]
     video = {}
     soup = BeautifulSoup(requests.get(url).text)
     video_player = soup.body('a',{'data-json-href':True})[0]
-    if video_player.attrs['data-json-href'].startswith("/wd"):
-        flashvars = requests.get("http://www.svt.se/%s"%video_player.attrs['data-json-href']).json()
+    if 'oppetarkiv.se' in url:
+        flashvars = requests.get("http://www.oppetarkiv.se/%s"%video_player.attrs['data-json-href']+"?output=json").json()
     else:    
     else:    
-        flashvars = requests.get("http://www.svtplay.se/%s"%video_player.attrs['data-json-href']+"?output=json").json()
+        if video_player.attrs['data-json-href'].startswith("/wd"):
+            flashvars = requests.get("http://www.svt.se/%s"%video_player.attrs['data-json-href']).json()
+        else:    
+            flashvars = requests.get("http://www.svtplay.se/%s"%video_player.attrs['data-json-href']+"?output=json").json()
     video['duration'] = video_player.attrs.get('data-length',0)
     video['title'] = title
     if not title:
     video['duration'] = video_player.attrs.get('data-length',0)
     video['title'] = title
     if not title: