 # -*- coding: utf-8 -*-
from setup import *
from imports import *
import urllib2
from cookielib import CookieJar
cj = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36')]

class m2list(MenuList):

    def __init__(self, list):
        MenuList.__init__(self, list, False, eListboxPythonMultiContent)
        self.l.setFont(0, gFont('Regular', 14))
        self.l.setFont(1, gFont('Regular', 16))
        self.l.setFont(2, gFont('Regular', 18))
        self.l.setFont(3, gFont('Regular', 20))
        self.l.setFont(4, gFont('Regular', 22))
        self.l.setFont(5, gFont('Regular', 24))
        self.l.setFont(6, gFont('Regular', 26))
        self.l.setFont(7, gFont('Regular', 28))
        self.l.setFont(8, gFont('Regular', 32))


def show_(name, link, img):
    res = [(name, link, img)]
    res.append(MultiContentEntryText(pos=(0, 0), size=(800, 40), font=8, text=name, flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER))
    return res


def show3_(name, link, img, id):
    res = [(name,
      link,
      img,
      id)]
    res.append(MultiContentEntryText(pos=(0, 0), size=(800, 40), font=8, text=name, flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER))
    return res


class wsssport(Screen):

    def __init__(self, session):
        sz_w = getDesktop(0).size().width()
        if sz_w == 1920:
            path = '/usr/lib/enigma2/python/Plugins/Extensions/Albatros/skin/defaultListScreen_new.xml'
        else:
            path = '/usr/lib/enigma2/python/Plugins/Extensions/Albatros/skin/defaultListScreen.xml'
        with open(path, 'r') as f:
            self.skin = f.read()
            f.close()
        self.session = session
        Screen.__init__(self, session)
        self['actions'] = ActionMap(['OkCancelActions',
         'ColorActions',
         'DirectionActions',
         'MovieSelectionActions'], {'up': self.up,
         'down': self.down,
         'left': self.left,
         'right': self.right,
         'ok': self.ok,
         'red': self.exit,
         'cancel': self.exit}, -1)
        self['menulist'] = m2list([])
        self['poster'] = Pixmap()
        self['title'] = Label('WSS-SPORT')
        self['text'] = Label('')
        self['red'] = Label(_('Exit'))
        self['green'] = Label('')
        self['yellow'] = Label(_(' '))
        self['blue'] = Label('')
        self['Menu'] = Label(_(' '))
        self['name'] = Label('')
        self.dnfile = 'False'
        self.currentList = 'menulist'
        self.menulist = []
        self.loading_ok = False
        self.check = 'abc'
        self.count = 0
        self.ch_list = []
        self.loading = 0
        self.dir()
        self.onLayoutFinish.append(self.abc)

    def about(self):
        self.session.open(AboutScreen)

    def jobix(self):
        if JobManagerInstalled:
            self.session.open(JobManagerFrontEnd)

    def dnitnow(self):
        if JobManagerInstalled and self.check == 'letter_movie':
            self.dnfile = 'True'
            link = self['menulist'].getCurrent()[0][1]
            self.filmname = self['menulist'].getCurrent()[0][0]
            self.get_play_link(self.filmname, link)

    def up(self):
        self[self.currentList].up()
        self.load_poster()

    def down(self):
        self[self.currentList].down()
        self.load_poster()

    def left(self):
        self[self.currentList].pageUp()
        self.load_poster()

    def right(self):
        self[self.currentList].pageDown()
        self.load_poster()

    def switchList(self):
        if self.currentList == 'menulist':
            self['ButtonBlue'].hide()
            self['TextBlue'].hide()
            self['menulist'].selectionEnabled(0)
            self.currentList = 'menulist2'
            self.check = 'abc'
        else:
            self['ButtonBlue'].show()
            self['TextBlue'].show()
            self['menulist'].selectionEnabled(1)
            self.currentList = 'menulist'
            self.check = 'letter_movie'

    def abc(self):
        self.loading_ok = False
        self.check = 'abc'
        self.currentList = 'menulist'
        self.letter_movielist = []
        self['menulist'].selectionEnabled(1)
        self['menulist'].show()
        self.genre_name = 'Al Cinema'
        uri = 'https://www.cartoonthemes.us/wsss/wssskysports1/wssskysports1.html'
        res=opener.open(uri)
        ans=res.read()
        user=re.findall('http://s1.wssiptv.com:8000/live/(.*?)/.*?ts',ans)[0]
        password=re.findall('http://s1.wssiptv.com:8000/live/.*?/(.*?)/',ans)[0]
        print user,password
        url='http://s1.wssiptv.com:8000/get.php?username=%s&password=%s&type=m3u&output=mpegts' %(user,password)		
        resp=opener.open(url)
        m3u8 = resp.read()
        channels=re.findall('#EXTINF:-1,(.*?)\n(http://.*?ts)',m3u8,re.DOTALL)
        print channels
        for (title,url) in channels:
            title=title.replace('\r','')
            if title=='SportTV5':
                img='https://'
            elif title=='SportTV4':
                img='https://'
            elif title=='OsnMovie Premier':
                img='https://'
            elif title=='OsnMovie Comedy':
                img='https://'
            elif title=='OsnMovie Action':
                img='https://'
            elif title=='BtSportseuropeHD':
                img='https://www.cartoonthemes.us/wsss/images/btsporteurope.png'
            elif title=='show-bein1':
                img='https://www.cartoonthemes.us/wsss/images/bs1hd.png'
            elif title=='show-bein2':
                img='https://www.cartoonthemes.us/wsss/images/bs2hd.png'
            elif title=='show-bein3':
                img='https://www.cartoonthemes.us/wsss/images/bs3hd.png'
            elif title=='show-bein4':
                img='https://www.cartoonthemes.us/wsss/images/bs4hd.png'
            elif title=='show-bein5':
                img='https://www.cartoonthemes.us/wsss/images/bs5hd.png'
            elif title=='show-bein6':
                img='https://www.cartoonthemes.us/wsss/images/bs6hd.png'
            elif title=='show-bein7':
                img='https://www.cartoonthemes.us/wsss/images/bs7hd.png'
            elif title=='show-bein8':
                img='https://www.cartoonthemes.us/wsss/images/bs8hd.png'
            elif title=='show-bein11':
                img='https://www.cartoonthemes.us/wsss/images/bs11hd.png'
            elif title=='show-bein12':
                img='https://www.cartoonthemes.us/wsss/images/bs12hd.png'
            elif title=='Sam2g-WWE':
                img='https://'
            elif title=='Sam2g-Willow':
                img='https://www.cartoonthemes.us/wsss/images/crickethd.jpg'
            elif title=='Sam2g-TenSports':
                img='https://www.cartoonthemes.us/wsss/images/Ten-Sports.png'
            elif title=='Sam2g-TenCricket':
                img='https://www.cartoonthemes.us/wsss/images/Ten-Cricket.png'
            elif title=='Sam2g-StarSports2':
                img='https://www.cartoonthemes.us/wsss/images/starsports2.png'
            elif title=='Sam2g-StarSports1':
                img='https://www.cartoonthemes.us/wsss/images/starsports1.png'
            elif title=='Sam2g-SonySix':
                img='https://www.cartoonthemes.us/wsss/images/sonysix.png'
            elif title=='Sam2g-SkySports2':
                img='https://www.cartoonthemes.us/wsss/images/ss2.png'
            elif title=='Sam2g-PTV':
                img='https://www.cartoonthemes.us/wsss/images/PTV-SPORTS.png'
            elif title=='Sam2g-PremierSports':
                img='https://www.cartoonthemes.us/wsss/images/premiersports.png'
            elif title=='Sam2g-GeoSuper':
                img='https://'
            elif title=='StarSports1-Toni':
                img='https://www.cartoonthemes.us/wsss/images/starsports1.png'
            elif title=='StarSports2-Toni':
                img='https://www.cartoonthemes.us/wsss/images/starsports2.png'
            elif title=='StarSports4-Toni':
                img='https://www.cartoonthemes.us/wsss/images/starsports4.png'
            elif title=='TenSports-Toni':
                img='https://www.cartoonthemes.us/wsss/images/Ten-Sports.png'
            elif title=='TenCricket-Toni':
                img='https://www.cartoonthemes.us/wsss/images/Ten-Cricket.png'
            elif title=='PTV-Toni':
                img='https://www.cartoonthemes.us/wsss/images/PTV-SPORTS.png'
            elif title=='WWE-Toni':
                img='https://'
            elif title=='MUTV-Toni':
                img='https://'
            elif title=='Disney-Restream':
                img='https://'
            elif title=='Chalsea-Toni':
                img='https://'
            elif title=='TSN 1-Dex (Restream)':
                img='https://www.cartoonthemes.us/wsss/images/tsn1.png'
            elif title=='TSN 2-Dex (Restream)':
                img='https://www.cartoonthemes.us/wsss/images/tsn2.png'
            elif title=='TSN 3-Dex (Restream)':
                img='https://www.cartoonthemes.us/wsss/images/tsn3.png'
            elif title=='TSN 4-Dex (Restream)':
                img='https://www.cartoonthemes.us/wsss/images/tsn4.png'
            elif title=='TSN 5-Dex (Restream)':
                img='https://www.cartoonthemes.us/wsss/images/tsn5.png'
            elif title=='Willow Tv (Cricket)':
                img='https://www.cartoonthemes.us/wsss/images/crickethd.jpg'
            elif title=='Star Sports 1':
                img='https://www.cartoonthemes.us/wsss/images/starsports1.png'
            elif title=='Sony Six':
                img='https://www.cartoonthemes.us/wsss/images/sonysix.png'
            elif title=='Sporttv1':
                img='https://www.cartoonthemes.us/wsss/images/sporttv1.png'
            elif title=='Sporttv2':
                img='https://www.cartoonthemes.us/wsss/images/sporttv2.png'
            elif title=='Sporttv3':
                img='https://www.cartoonthemes.us/wsss/images/sporttv3.png'
            elif title=='Sport Klub 1 HD':
                img='https://www.cartoonthemes.us/wsss/images/sportklub1.png'
            elif title=='Sport Klub 2 HD':
                img='https://www.cartoonthemes.us/wsss/images/sportklub2.png'
            elif title=='Sport Klub 3 HD':
                img='https://www.cartoonthemes.us/wsss/images/sportklub3.png'
            elif title=='SkySports 1 HQ':
                img='https://www.cartoonthemes.us/wsss/images/ss1.png'
            elif title=='SkySports 2 HQ':
                img='https://www.cartoonthemes.us/wsss/images/ss2.png'
            elif title=='SkySports 3 HQ':
                img='https://www.cartoonthemes.us/wsss/images/ss3.png'
            elif title=='SkySports 4 HQ':
                img='https://www.cartoonthemes.us/wsss/images/ss4.png'
            elif title=='SkySports 5 HQ':
                img='https://www.cartoonthemes.us/wsss/images/ss5.png'
            elif title=='SkySports F1 HQ':
                img='https://www.cartoonthemes.us/wsss/images/ssf1.png'
            elif title=='SkySports News HQ':
                img='https://www.cartoonthemes.us/wsss/images/ssnews.png'
            elif title=='SkySports 1':
                img='https://www.cartoonthemes.us/wsss/images/ss1.png'
            elif title=='SkySports 2':
                img='https://www.cartoonthemes.us/wsss/images/ss2.png'
            elif title=='SkySports 3':
                img='https://www.cartoonthemes.us/wsss/images/ss3.png'
            elif title=='SkySports 4':
                img='https://www.cartoonthemes.us/wsss/images/ss4.png'
            elif title=='SkySports 5':
                img='https://www.cartoonthemes.us/wsss/images/ss5.png'
            elif title=='SkySports F1':
                img='https://www.cartoonthemes.us/wsss/images/ssf1.png'
            elif title=='SkySports News':
                img='https://www.cartoonthemes.us/wsss/images/ssnews.png'
            elif title=='Sky Sport 1 HD Italy':
                img='https://www.cartoonthemes.us/wsss/images/skyitaly1hd.png'
            elif title=='Sky Sport 2 HD Italy':
                img='https://www.cartoonthemes.us/wsss/images/skyitaly2hd.png'
            elif title=='Sky Sport 3 HD Italy':
                img='https://www.cartoonthemes.us/wsss/images/skyitaly3.png'
            elif title=='Sky Sport 24 HD Italy':
                img='https://www.cartoonthemes.us/wsss/images/skyitaly24.png'
            elif title=='Sky Sport 1 HD Deutch Germany':
                img='https://www.cartoonthemes.us/wsss/images/skysport1hdgerman.png'
            elif title=='Sky Sport 2 HD Deutch Germany':
                img='https://www.cartoonthemes.us/wsss/images/skysport2hdgerman.png'
            elif title=='Sky Movie Christmas (Ex-Drama)':
                img='https://www.cartoonthemes.us/wsss/images/skymoviesdramanromance.jpg'
            elif title=='Sky Movie (Select)':
                img='https://www.cartoonthemes.us/wsss/images/skymoviesselect.jpg'
            elif title=='Sky Movie (SciFi&Horror)':
                img='https://www.cartoonthemes.us/wsss/images/skymoviesscifinhorror.jpg'
            elif title=='Sky Movie (Premiere)':
                img='https://www.cartoonthemes.us/wsss/images/skymoviespremiere.jpg'
            elif title=='Sky Movie (Modern Greats)':
                img='https://www.cartoonthemes.us/wsss/images/skymoviesmoderngreats.jpg'
            elif title=='Sky Movie (Family)':
                img='https://www.cartoonthemes.us/wsss/images/skymoviesfamily.jpg'
            elif title=='Sky Movie (Crime&Thriller)':
                img='https://www.cartoonthemes.us/wsss/images/skymoviescrimenthriller.jpg'
            elif title=='Sky Movie (Comedy)':
                img='https://www.cartoonthemes.us/wsss/images/skymoviescomedy.jpg'
            elif title=='Sky Movie (Action&Adventure)':
                img='https://www.cartoonthemes.us/wsss/images/skymoviesactionnadventure.jpg'
            elif title=='Sky Bundesliga HD1':
                img='https://www.cartoonthemes.us/wsss/images/skybundesligahd1.png'
            elif title=='Sky Bundesliga HD2':
                img='https://www.cartoonthemes.us/wsss/images/skybundesligahd2.png'
            elif title=='Sky Bundesliga HD3':
                img='https://www.cartoonthemes.us/wsss/images/skybundesligahd3.png'
            elif title=='Sky Bundesliga HD4':
                img='https://www.cartoonthemes.us/wsss/images/skybundesligahd4.png'
            elif title=='Sky Bundesliga HD5':
                img='https://www.cartoonthemes.us/wsss/images/skybundesligahd5.png'
            elif title=='Sky Bundesliga HD6':
                img='https://www.cartoonthemes.us/wsss/images/skybundesligahd6.png'
            elif title=='Sky Bundesliga HD7':
                img='https://www.cartoonthemes.us/wsss/images/skybundesligahd7.png'
            elif title=='Sky Bundesliga HD8':
                img='https://www.cartoonthemes.us/wsss/images/skybundesligahd8.png'
            elif title=='Sky Bundesliga HD9':
                img='https://www.cartoonthemes.us/wsss/images/skybundesligahd9.png'
            elif title=='Sky Bundesliga HD10':
                img='https://'
            elif title=='Sky Atlantic':
                img='https://'
            elif title=='Setanta Sports':
                img='https://www.cartoonthemes.us/wsss/images/setantaireland.png'
            elif title=='Premier Sports':
                img='https://www.cartoonthemes.us/wsss/images/premiersports.png'
            elif title=='NHL Network':
                img='https://www.cartoonthemes.us/wsss/images/nhltv.png'
            elif title=='NFL Network':
                img='https://www.cartoonthemes.us/wsss/images/nfltv.png'
            elif title=='NBC Sports':
                img='https://www.cartoonthemes.us/wsss/images/nbcsn.png'
            elif title=='ITV 1 UK':
                img='https://www.cartoonthemes.us/wsss/images/itv1.png'
            elif title=='ITV 2 UK':
                img='https://www.cartoonthemes.us/wsss/images/itv2.png'
            elif title=='ITV 3 UK':
                img='https://www.cartoonthemes.us/wsss/images/itv3.png'
            elif title=='ITV 4 UK':
                img='https://www.cartoonthemes.us/wsss/images/itv4.png'
            elif title=='Fox Sports 1 HD NL':
                img='https://www.cartoonthemes.us/wsss/images/foxsports1.png'
            elif title=='Fox Sports 2 HD NL':
                img='https://www.cartoonthemes.us/wsss/images/foxsports2.png'
            elif title=='Fox Sports 3 HD NL':
                img='https://'
            elif title=='Fox Sports 4 HD NL':
                img='https://'
            elif title=='Fox Sports 5 HD NL':
                img='https://'
            elif title=='Fox Sports 1 USA':
                img='https://www.cartoonthemes.us/wsss/images/foxsports1.png'
            elif title=='Fox Sports 2 USA':
                img='https://www.cartoonthemes.us/wsss/images/foxsports2.png'
            elif title=='Eurosport 1':
                img='https://www.cartoonthemes.us/wsss/images/beurosport1.png'
            elif title=='Eurosport 2':
                img='https://www.cartoonthemes.us/wsss/images/beurosport2.png'
            elif title=='ESPN USA':
                img='https://www.cartoonthemes.us/wsss/images/ESPN-USA.png'
            elif title=='ESPN 2 USA':
                img='https://www.cartoonthemes.us/wsss/images/espn2.png'
            elif title=='Channel 1 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 2 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 3 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 4 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 5 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 6 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 7 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 8 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 9 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 10 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 11 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 12 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 13 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 14 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 15 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 16 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 17 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 18 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 19 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Channel 20 (not 24x7)':
                img='https://www.cartoonthemes.us/wsss/images/ch1to30.png'
            elif title=='Canal   Sport':
                img='https://www.cartoonthemes.us/wsss/images/canal+sport.jpg'
            elif title=='Canal':
                img='https://www.cartoonthemes.us/wsss/images/canal+.jpg'
            elif title=='Btn':
                img='https://www.cartoonthemes.us/wsss/images/btn.png'
            elif title=='Bt Sports 1':
                img='https://www.cartoonthemes.us/wsss/images/btsport1.png'
            elif title=='Bt Sports 2':
                img='https://www.cartoonthemes.us/wsss/images/btsport2.png'
            elif title=='Bt Sports Europe SD':
                img='https://www.cartoonthemes.us/wsss/images/beurosport1.png'
            elif title=='Bt Sports ESPN UK':
                img='https://www.cartoonthemes.us/wsss/images/btsportespn.png'
            elif title=='Bt Sports 1 HQ':
                img='https://www.cartoonthemes.us/wsss/images/btsport1.png'
            elif title=='Bt Sports 2 HQ':
                img='https://www.cartoonthemes.us/wsss/images/btsport2.png'
            elif title=='Box Nation':
                img='https://www.cartoonthemes.us/wsss/images/boxnation.png'
            elif title=='Bein Sports USA':
                img='https://www.cartoonthemes.us/wsss/images/beinusa.jpg'
            elif title=='Bein Sports 1 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs1hd.png'
            elif title=='Bein Sports 2 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs2hd.png'
            elif title=='Bein Sports 3 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs3hd.png'
            elif title=='Bein Sports 4 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs4hd.png'
            elif title=='Bein Sports 5 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs5hd.png'
            elif title=='Bein Sports 6 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs6hd.png'
            elif title=='Bein Sports 7 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs7hd.png'
            elif title=='Bein Sports 8 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs8hd.png'
            elif title=='Bein Sports 9 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs9hd.png'
            elif title=='Bein Sports 10 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs10hd.png'
            elif title=='Bein Sports 11 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs11hd.png'
            elif title=='Bein Sports 12 HD':
                img='https://www.cartoonthemes.us/wsss/images/bs12hd.png'
            elif title=='Bein Sports 1 FR':
                img='https://www.cartoonthemes.us/wsss/images/beinfr1.jpg'
            elif title=='Bein Sports 2 FR':
                img='https://www.cartoonthemes.us/wsss/images/beinfr2.jpg'
            elif title=='Bein Sports 3 FR':
                img='https://www.cartoonthemes.us/wsss/images/beinfr3.jpg'
            elif title=='Bein Max 4':
                img='https://www.cartoonthemes.us/wsss/images/beinmax4.jpg'
            elif title=='Bein Max 5':
                img='https://www.cartoonthemes.us/wsss/images/beinmax5.jpg'
            elif title=='BBC 1 UK':
                img='https://www.cartoonthemes.us/wsss/images/bbc1.jpg'
            elif title=='BBC 2 UK':
                img='https://www.cartoonthemes.us/wsss/images/bbc2.jpg'
            elif title=='BBC 3 UK':
                img='https://www.cartoonthemes.us/wsss/images/bbc3.jpg'
            elif title=='BBC 4 UK':
                img='https://www.cartoonthemes.us/wsss/images/bbc4.jpg'
            elif title=='At The Races':
                img='https://www.cartoonthemes.us/wsss/images/attheraces.png'
            elif title=='Racing UK':
                img='https://www.cartoonthemes.us/wsss/images/racinguk.jpg'
            elif title=='Arena Sports 1 HD  Croatian':
                img='https://www.cartoonthemes.us/wsss/images/arenasport1.gif'
            elif title=='Arena Sports 2 HD Croatian':
                img='https://www.cartoonthemes.us/wsss/images/arenasport2.gif'
            elif title=='Arena Sports 3 HD Croatian':
                img='https://www.cartoonthemes.us/wsss/images/arenasport3.gif'
            elif title=='Arena Sports 4 HD Croatian':
                img='https://www.cartoonthemes.us/wsss/images/arenasport4.gif'	
            self.ch_list.append(show_(title,url,img))
        self['menulist'].l.setList(self.ch_list)
        self['menulist'].l.setItemHeight(40)
        self['menulist'].moveToIndex(0)
        self.show_cover()
        return

    def ok(self):
        final_uri = self['menulist'].l.getCurrentSelection()[0][1]
        self.play_that_shit(final_uri)

    def play_that_shit(self, data):
        selectedName = self['menulist'].l.getCurrentSelection()[0][0]
        fin_uri = 'http://127.0.0.1:88/httpstream://' + data + ' headers={"User-Agent":"Mozilla/5.0 (Linux; Android 5.1; en-US; Nexus 6 Build/LMY47Z) MXPlayer/1.7.40"}'
        sref = eServiceReference(4097, 0, fin_uri)
        sref.setName(selectedName)
        self.session.open(MoviePlayer, sref)

    def exit(self):
        self.close()

    def load_poster(self):
        jp_link = self['menulist'].getCurrent()[0][2]
        tmp_image = jpg_store = '/tmp/teledunet_poster.jpg'
        try:
            downloadPage(jp_link, tmp_image).addCallback(self.downloadPic, tmp_image)
        finally:
            print "Error: can't find file or read data"

    def show_cover(self):
        jpg_link = '/usr/lib/enigma2/python/Plugins/Extensions/teledunet/images/'
        jpg_name = 'no_cover.png'
        jpg_store = jpg_link + jpg_name
        if not os.path.exists(jpg_store):
            self.downloadPic(jpg_name, jpg_store)
        else:
            self.poster_resize(jpg_store)

    def downloadPic(self, data, jpg_store):
        if fileExists(jpg_store):
            self.poster_resize(jpg_store)
        else:
            print '[teledunet] logo not found'

    def poster_resize(self, poster_path):
        self['poster'].instance.setPixmap(None)
        self['poster'].hide()
        sc = AVSwitch().getFramebufferScale()
        self.picload = ePicLoad()
        size = self['poster'].instance.size()
        self.picload.setPara((size.width(),
         size.height(),
         sc[0],
         sc[1],
         False,
         1,
         '#FF000000'))
        if self.picload.startDecode(poster_path, 0, 0, False) == 0:
            ptr = self.picload.getData()
            if ptr != None:
                self['poster'].instance.setPixmap(ptr)
                self['poster'].show()
            else:
                print '[teledunet] no cover.. error'
        return

    def stream_not_found(self):
        message = self.session.open(MessageBox, _('Stream not found, try again later on'), MessageBox.TYPE_INFO, timeout=3)

    def errorload2(self, error):
        print '[teledunet] error %s' % error
        count_movies = len(self.letter_movielist)
        self.loading_ok = True
        self.loading = 0
        self.count = 0

    def errorload(self, error):
        print error

    def dir(self):
        if not pathExists('/tmp/teledunet/'):
            os.system('mkdir /tmp/teledunet/')
        else:
            print '[teledunet] /tmp/teledunet/ allready present'