The branch, dharma has been updated
via 9e78ad6f41224803aedd7e994b361f282d929783 (commit)
from 1953d78e48bcb7441b4394211379fb54653d9dd3 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=9e78ad6f41224803aedd7e994b361f282d929783
commit 9e78ad6f41224803aedd7e994b361f282d929783
Author: spiff <[email protected]>
Date: Tue Feb 7 07:57:34 2012 +0100
[plugin.video.sarpur] updated to version 1.0.1
diff --git a/plugin.video.sarpur/addon.xml b/plugin.video.sarpur/addon.xml
index a9340ec..8965ae8 100644
--- a/plugin.video.sarpur/addon.xml
+++ b/plugin.video.sarpur/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.sarpur"
name="Sarpur"
- version="1.0"
+ version="1.0.1"
provider-name="dagur">
<requires>
<import addon="xbmc.python" version="1.0"/>
@@ -14,7 +14,7 @@
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Play videos and radio recordings from the Icelandic
National Radio's website</summary>
- <description lang="en">An Iceland IP-Address is required to use this
because ruv.is locks all other out</description>
+ <description lang="en">An Iceland IP-Address is required to use this
because of geoblocking</description>
<platform>all</platform>
</extension>
</addon>
diff --git a/plugin.video.sarpur/default.py b/plugin.video.sarpur/default.py
index 1ed86f3..777b1aa 100644
--- a/plugin.video.sarpur/default.py
+++ b/plugin.video.sarpur/default.py
@@ -14,7 +14,7 @@ def forsida():
for tab in tabs:
title, url = tab
addDir(title.encode('utf-8'), 'nytt', url)
- for i,stod in enumerate(showtree[:-1]):
+ for i,stod in enumerate(showtree):
title = u'%s \xfe\xe6ttir' % stod['name']
addDir(title.encode('utf-8'), 'stod', i)
# addDir(u'V\xf6ktun K\xf6tlu'.encode('utf-8'), 'eldfjall', 'katla')
diff --git a/plugin.video.sarpur/scraper.py b/plugin.video.sarpur/scraper.py
index fbcd96b..c9baac7 100644
--- a/plugin.video.sarpur/scraper.py
+++ b/plugin.video.sarpur/scraper.py
@@ -1,12 +1,13 @@
#!/usr/bin/env python
-import urllib2, re, os, time
+import urllib2, re, os
from BeautifulSoup import BeautifulSoup
from datetime import datetime
import simplejson as json
user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3)
Gecko/2008092417 Firefox/3.0.3'
-showtreefile_location = os.path.join(os.getcwd(),
'resources','data','showtree.dat')
-tabfile_location = os.path.join(os.getcwd(), 'resources','data','tabs.dat')
+data_path = os.path.join(os.getcwd(), 'resources','data')
+showtreefile_location = os.path.join(data_path,'showtree.dat')
+tabfile_location = os.path.join(data_path,'tabs.dat')
showtree = [] #All the shows under the thaettir menu
tabs = [] #Tabs in the Sarpur main page
@@ -27,13 +28,15 @@ def get_tabs():
div = soup.find("div", attrs={"class": "menu-block-ctools-menu-sarpsmynd-1
menu-name-menu-sarpsmynd parent-mlid-_active:0 menu-level-2"})
for li in div.findAll("li"):
tabs.append((li.a.contents[0], li.a['href']))
-
+
def parse_show_index(html):
"Take the html from the show index and create a data structure"
+ global showtree
+ showtree = []
soup = BeautifulSoup(html)
stodvar = soup.findAll("div",
attrs={"style":re.compile("width:280px;float:left;.*")}) #0: Stod 1 #1: Ras 1
#2: Ras 2
-
+
for i,stod in enumerate(stodvar):
showtree.append({"name":stod.h1.contents[0], "categories":[]})
for flokkur in stod.div:
@@ -43,7 +46,10 @@ def parse_show_index(html):
elif flokkur.name == 'div':
for show in flokkur.findAll("div"):
showtree[i]["categories"][-1]['shows'].append((show.a.contents[0],
show.a['href']))
+
+
+
def get_episodes(url):
"Find playable files on a shows page"
episodes = []
@@ -71,31 +77,33 @@ def get_latest_episodes(url):
"Find playable files on the 'recent' pages"
html = fetch_page(url)
soup = BeautifulSoup(html)
-
+
spilari = soup.find("div", attrs={'class':'kubbur sarpefst'})
dags = re.search(r'\d{1,2}\. \w{3} \d{4} \|
\d\d:\d\d',repr(spilari)).group()
featured = "%s %s" % (spilari.h1.contents[0], dags)
-
+
episodes = [(featured, url)]
-
+
for li in soup.find("ul", attrs={'class':'sarplisti'}).findAll("li"):
title = "%s %s" % (li.h4.a.contents[0], li.em.contents[0])
pageurl = u"http://www.ruv.is%s" % li.h4.a['href']
episodes.append((title , pageurl))
-
+
return episodes
+
+
def get_stream_info(page_url):
"Get a page url and finds the url of the rtmp stream"
html = fetch_page(page_url)
- access_point_hyperlink = re.search('"http://load.cache.is.*?"',
html).group()[1:-1]
+ access_point_hyperlink = re.search('"http://load.cache.is.*?"',
html).group()[1:-1]
javascript = fetch_page(access_point_hyperlink)
access_point = re.search('"(.*?)"', javascript).group(1)
path = re.search('ruv(vod)?\?key=\d+', html).group()
rtmp_url = "rtmp://%s/%s" % (access_point, path)
playpath = re.findall("\'file\': \'(.*?)\'", html)[-1] #.group(1)
-
+
return {'playpath': playpath, 'rtmp_url': rtmp_url}
def update_index():
@@ -103,32 +111,45 @@ def update_index():
print "Update Sarpur data files."
html = fetch_page('http://dagskra.ruv.is/thaettir/')
parse_show_index(html)
- showtree.append(time.time())
+
+ #showtree.append(time.time())
json.dump(showtree, file(showtreefile_location,'wb'))
get_tabs()
json.dump(tabs, file(tabfile_location,'wb'))
## init
try:
- tabs = json.load(file(tabfile_location,'rb'))
- showtree = json.load(file(showtreefile_location,'rb'))
- delta = datetime.now() - datetime.fromtimestamp(showtree[-1])
+ delta = datetime.now() -
datetime.fromtimestamp(os.path.getmtime(showtreefile_location))
if delta.days > 0:
update_index()
+ else:
+ tabs = json.load(file(tabfile_location,'rb'))
+ showtree = json.load(file(showtreefile_location,'rb'))
+except OSError:
+ if not os.path.exists(data_path):
+ os.makedirs(data_path)
+ update_index()
except IOError:
+ os.unlink(showtreefile_location)
+ os.unlink(tabfile_location)
update_index()
if __name__ == '__main__':
- None
#showtree = []; update_index()
#print showtree[0]['categories']
-
- #for stod in showtree[:-1]:
- # print stod['name'].encode('utf-8')
+ #get_tabs()
+ #os.unlink(showtreefile_location)
+ #os.unlink(tabfile_location)
+ #update_index()
+ #print showtree
+
+ for stod in showtree:
+ #print stod
+ print stod['name'].encode('utf-8')
#for flokkur in showtree[0]['categories']:
# print flokkur
@@ -138,8 +159,12 @@ if __name__ == '__main__':
#print get_episodes("http://dagskra.ruv.is/opus")
- #print get_stream_info("http://www.ruv.is/sarpurinn/nytt")
- #print get_latest_episodes("http://www.ruv.is/sarpurinn/nytt")
+ #print get_stream_info("http://www.ruv.is/ruv")
+ #print get_stream_info("http://www.ruv.is/ras1")
+ #print get_stream_info("http://www.ruv.is/sarpurinn/regina-osk/19012012")
+ #print get_latest_episodes("http://www.ruv.is/sarpurinn/ras1")
#get_tabs()
#print tabs
+
+
-----------------------------------------------------------------------
Summary of changes:
plugin.video.sarpur/addon.xml | 4 +-
plugin.video.sarpur/changelog.txt | 3 ++
plugin.video.sarpur/default.py | 2 +-
plugin.video.sarpur/scraper.py | 67 +++++++++++++++++++++++++-----------
4 files changed, 52 insertions(+), 24 deletions(-)
create mode 100644 plugin.video.sarpur/changelog.txt
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons