Skip to content

Commit

Permalink
Merge pull request #1 from athoik/addconvert
Browse files Browse the repository at this point in the history
 Update stream.xml and add new menu entry update bouquet
  • Loading branch information
athoik committed Jan 31, 2014
2 parents 2b38d1d + 26136bd commit 0dbada4
Show file tree
Hide file tree
Showing 2 changed files with 451 additions and 340 deletions.
39 changes: 38 additions & 1 deletion plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
url_sc = "/usr/lib/enigma2/python/Plugins/Extensions/GreekStreamTV/update.sh"
url_pd = "/usr/lib/enigma2/python/Plugins/Extensions/GreekStreamTV/depends.sh"

GSXML = "/usr/lib/enigma2/python/Plugins/Extensions/GreekStreamTV/stream.xml"
GSBQ = "/etc/enigma2/userbouquet.greekstreamtv.tv"

def menu(menuid, **kwargs):
if menuid == "mainmenu":
return [("GreekStreamTV", main, "GreekStreamTV", 33)]
Expand Down Expand Up @@ -49,9 +52,11 @@ def __init__(self, session):
self.session = session
menu = []
if path.isdir("/usr/lib/enigma2/python/Plugins/Extensions/GreekStreamTV"):
menu.append((_("GreekStreamTV"),"/usr/lib/enigma2/python/Plugins/Extensions/GreekStreamTV/stream.xml"))
menu.append((_("GreekStreamTV"), GSXML))
menu.extend(self.getStreams())
menu.append((_("Update Greek Stations"), "update"))
if path.isfile(GSBQ):
menu.append((_("Update Bouquet"), "updatebq"))
menu.append((_("Install Dependencies"), "depends"))
menu.append((_("About..."), "about"))
self["menu"] = MenuList(menu)
Expand All @@ -72,6 +77,17 @@ def go(self):
self.session.open(MessageBox, tmpMessage, MessageBox.TYPE_INFO)
elif choice == "update":
self.session.openWithCallback(self.update, MessageBox,_("Confirm your selection, or exit"), MessageBox.TYPE_YESNO)
elif choice == "updatebq":
try:
self.updatebq()
from enigma import eDVBDB
eDVBDB.getInstance().reloadBouquets()
eDVBDB.getInstance().reloadServicelist()
tmpMessage = "GreekStreamTV bouquet updated successfully..."
except Exception as err:
print "[GreekStreamTV::PluginMenu] Exception: ", str(err)
tmpMessage = "GreekStreamTV bouquet update failed..."
self.session.open(MessageBox, tmpMessage, MessageBox.TYPE_INFO)
elif choice == "depends":
self.session.openWithCallback(self.depends, MessageBox,_("Confirm your selection, or exit"), MessageBox.TYPE_YESNO)
elif choice == "about":
Expand All @@ -80,6 +96,27 @@ def go(self):
tmpMessage += "GreekStreamTV is free and source code included."
self.session.open(MessageBox, tmpMessage, MessageBox.TYPE_INFO)

def updatebq(self):
from xml.etree.cElementTree import ElementTree
tree = ElementTree()
tree.parse(GSXML)
tvlist = []
for iptv in tree.findall("iptv"):
name = iptv.findtext("name").title()
(protocol, serviceType, bufferSize, epgId) = iptv.findtext("type").split(":")
uri = iptv.findtext("uri")
if protocol in "livestreamer":
uri = "http://127.1:88/" + uri
uri = uri.replace(":", "%3a")
service = "#SERVICE {s}:0:1:{e}:{e}:0:0:0:0:0:{u}:{n}\n".format(s=serviceType,e=epgId,u=uri,n=name)
tvlist.append((name,service))

tvlist=sorted(tvlist, key=lambda channel: channel[0]) #sort by name
with open(GSBQ, "w") as f:
f.write("#NAME GreekStreamTV\n")
for (name, service) in tvlist:
f.write(service)

def update(self, answer):
if answer:
self.session.open(Console,_("Install "),["%s update" % url_sc])
Expand Down
Loading

0 comments on commit 0dbada4

Please sign in to comment.