示例#1
0
    def __init__(
        self,
        session,
        config_starttime=None,
        config_endtime=None,
        config_date=None,
    ):
        Screen.__init__(self, session)

        skin = skin_path + 'settings.xml'
        try:
            from boxbranding import getImageDistro, getImageVersion, getOEVersion
        except:

            if owibranding.getMachineBrand(
            ) == "Dream Multimedia" or owibranding.getOEVersion() == "OE 2.2":
                skin = skin_path + 'DreamOS/settings.xml'

        with open(skin, 'r') as f:
            self.skin = f.read()

        self['key_red'] = StaticText(_('Close'))
        self['key_green'] = StaticText(_('Save'))

        self.createConfig(config_date, config_starttime, config_endtime)

        self['actions'] = ActionMap(['XStreamityActions'], {
            'cancel': self.keyCancel,
            'red': self.keyCancel,
            'green': self.keyGo,
        }, -2)

        self.list = []
        ConfigListScreen.__init__(self, self.list)
        self.createSetup(self["config"])
示例#2
0
    def __init__(self, session, streamurl, servicetype):
        Screen.__init__(self, session)

        self.session = session

        InfoBarBase.__init__(self)
        InfoBarMoviePlayerSummarySupport.__init__(self)
        InfoBarServiceNotifications.__init__(self)
        IPTVInfoBarShowHide.__init__(self)
        InfoBarSeek.__init__(self)
        InfoBarAudioSelection.__init__(self)
        InfoBarSubtitleSupport.__init__(self)
        IPTVInfoBarPVRState.__init__(self, PVRState, True)
        InfoBarInstantRecord.__init__(self)

        self.streamurl = streamurl
        self.servicetype = servicetype

        skin = skin_path + 'streamplayer.xml'

        self["epg_description"] = StaticText()
        self["nowchannel"] = StaticText()
        self["nowtitle"] = StaticText()
        self["nexttitle"] = StaticText()
        self["nowtime"] = StaticText()
        self["nexttime"] = StaticText()
        self["streamcat"] = StaticText()
        self["streamtype"] = StaticText()
        self["extension"] = StaticText()
        self["progress"] = ProgressBar()
        self["progress"].hide()
        self["epg_picon"] = Pixmap()

        self["eventname"] = Label()
        self["state"] = Label()
        self["speed"] = Label()
        self["statusicon"] = MultiPixmap()

        self["PTSSeekBack"] = Pixmap()
        self["PTSSeekPointer"] = Pixmap()

        with open(skin, 'r') as f:
            self.skin = f.read()

        self.setup_title = _('TV')

        self['actions'] = ActionMap(
            ["XStreamityActions"], {
                'cancel': self.back,
                'tv': self.toggleStreamType,
                "channelUp": self.next,
                "channelDown": self.prev,
                "up": self.prev,
                "down": self.next,
                "stop": self.back,
                "rec": self.IPTVstartInstantRecording,
            }, -2)

        self.onLayoutFinish.append(self.__layoutFinished)
示例#3
0
文件: menu.py 项目: OpenVu/XStreamity
    def __init__(self, session):
        Screen.__init__(self, session)
        self.session = session

        skin = skin_path + 'menu.xml'
        with open(skin, 'r') as f:
            self.skin = f.read()

        self.list = []
        self.drawList = []
        self["list"] = List(self.drawList, enableWrapAround=True)

        self.setup_title = (_('Stream Selection'))

        self['key_red'] = StaticText(_('Back'))
        self['key_yellow'] = StaticText(_('Refresh Lists'))

        self['lastchecked'] = StaticText(
            _("Lists updated: ") +
            str(glob.current_playlist['data']['last_check']))

        self["splash"] = Pixmap()
        self["splash"].show()

        self['actions'] = ActionMap(
            ['XStreamityActions'], {
                'red': self.quit,
                'cancel': self.quit,
                'yellow': self.updateCategories,
                'ok': self.next,
            }, -2)

        self.protocol = glob.current_playlist['playlist_info']['protocol']
        self.domain = glob.current_playlist['playlist_info']['domain']
        self.host = glob.current_playlist['playlist_info']['host']
        self.username = glob.current_playlist['playlist_info']['username']
        self.password = glob.current_playlist['playlist_info']['password']

        self.live_streams = "%s/player_api.php?username=%s&password=%s&action=get_live_streams" % (
            self.host, self.username, self.password)

        self.p_live_categories_url = "%s/player_api.php?username=%s&password=%s&action=get_live_categories" % (
            self.host, self.username, self.password)
        self.p_vod_categories_url = "%s/player_api.php?username=%s&password=%s&action=get_vod_categories" % (
            self.host, self.username, self.password)
        self.p_series_categories_url = "%s/player_api.php?username=%s&password=%s&action=get_series_categories" % (
            self.host, self.username, self.password)
        self.p_live_streams_url = "%s/player_api.php?username=%s&password=%s&action=get_live_streams" % (
            self.host, self.username, self.password)

        glob.current_playlist['data']['live_streams'] = []

        self.onFirstExecBegin.append(self.delayedDownload)
        self.onLayoutFinish.append(self.__layoutFinished)
示例#4
0
    def __init__(self, session):
        Screen.__init__(self, session)

        if cfg.parental.getValue() == True:
            ProtectedScreen.__init__(self)
        self.session = session

        skin = skin_path + 'settings.xml'

        try:
            from boxbranding import getImageDistro, getImageVersion, getOEVersion
        except:

            if owibranding.getMachineBrand(
            ) == "Dream Multimedia" or owibranding.getOEVersion() == "OE 2.2":
                skin = skin_path + 'DreamOS/settings.xml'

        with open(skin, 'r') as f:
            self.skin = f.read()

        self.setup_title = (_('Main Settings'))

        self.onChangedEntry = []

        self.list = []
        ConfigListScreen.__init__(self,
                                  self.list,
                                  session=self.session,
                                  on_change=self.changedEntry)

        self['key_red'] = StaticText(_('Close'))
        self['key_green'] = StaticText(_('Save'))

        self['VirtualKB'].setEnabled(False)
        self['HelpWindow'] = Pixmap()
        self['VKeyIcon'] = Pixmap()
        self['HelpWindow'].hide()
        self['VKeyIcon'].hide()

        self['actions'] = ActionMap(
            ['XStreamityActions'], {
                'cancel': self.cancel,
                'red': self.cancel,
                'green': self.save,
                'ok': self.ok,
            }, -2)

        self.initConfig()

        self.onLayoutFinish.append(self.__layoutFinished)
示例#5
0
	def __init__(self, session, streamurl, servicetype):
		Screen.__init__(self, session)

		self.session = session

		InfoBarBase.__init__(self)
		InfoBarMoviePlayerSummarySupport.__init__(self)		
		InfoBarServiceNotifications.__init__(self)
		InfoBarShowHide.__init__(self)
		InfoBarSeek.__init__(self)
		InfoBarAudioSelection.__init__(self)
		InfoBarSubtitleSupport.__init__(self)
		IPTVInfoBarPVRState.__init__(self, PVRState, True)
		SubsSupport.__init__(self, searchSupport=True, embeddedSupport=True)
		SubsSupportStatus.__init__(self)

		self.streamurl = streamurl
		self.servicetype = servicetype

		skin = skin_path + 'catchupplayer.xml'
		self["epg_description"] = StaticText()
		self["streamcat"] = StaticText()
		self["streamtype"] = StaticText()
		self["extension"] = StaticText()
		self["epg_picon"] = Pixmap()

		self["eventname"] = Label()
		self["state"] = Label()
		self["speed"] = Label()
		self["statusicon"] = MultiPixmap()
		
		self["PTSSeekBack"] = Pixmap()
		self["PTSSeekPointer"] = Pixmap()

		with open(skin, 'r') as f:
			self.skin = f.read()

		self.setup_title = _('Catch Up')

		self['actions'] = ActionMap(["XStreamityActions"], {
			'cancel': self.back,
			'red': self.back,
			'tv': self.toggleStreamType,
			'info': self.toggleStreamType,
			"stop": self.back,

			}, -2)

		self.onFirstExecBegin.append(boundFunction(self.playStream, self.servicetype, self.streamurl))
示例#6
0
    def __init__(self, session, streamurl, servicetype):
        Screen.__init__(self, session)

        self.session = session

        InfoBarBase.__init__(self)
        InfoBarMoviePlayerSummarySupport.__init__(self)
        InfoBarServiceNotifications.__init__(self)
        InfoBarShowHide.__init__(self)
        InfoBarSeek.__init__(self)
        InfoBarAudioSelection.__init__(self)
        InfoBarSubtitleSupport.__init__(self)
        IPTVInfoBarPVRState.__init__(self, PVRState, True)
        SubsSupport.__init__(self, searchSupport=True, embeddedSupport=True)
        SubsSupportStatus.__init__(self)

        self.streamurl = streamurl
        self.servicetype = servicetype

        skin = skin_path + 'vodplayer.xml'

        self["streamcat"] = StaticText()
        self["streamtype"] = StaticText()
        self["extension"] = StaticText()
        self["cover"] = Pixmap()

        self["eventname"] = Label()
        self["state"] = Label()
        self["speed"] = Label()
        self["statusicon"] = MultiPixmap()

        with open(skin, 'r') as f:
            self.skin = f.read()

        self.setup_title = _('VOD')

        self['actions'] = ActionMap(
            ["XStreamityActions"], {
                'cancel': self.back,
                'tv': self.toggleStreamType,
                "channelUp": self.next,
                "channelDown": self.prev,
                "up": self.prev,
                "down": self.next,
                "stop": self.back,
            }, -2)

        self.onLayoutFinish.append(self.__layoutFinished)
示例#7
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.session = session

        skin = skin_path + 'userinfo.xml'
        with open(skin, 'r') as f:
            self.skin = f.read()

        self.setup_title = (_('User Information'))

        self['authorised'] = Label('')
        self['status'] = Label('')
        self['expiry'] = Label('')
        self['created'] = Label('')
        self['trial'] = Label('')
        self['activeconn'] = Label('')
        self['maxconn'] = Label('')
        self['formats'] = Label('')
        self['realurl'] = Label('')
        self['timezone'] = Label('')
        self['fullurl'] = Label('')

        self['actions'] = ActionMap(
            ['XStreamityActions'], {
                'ok': self.quit,
                'cancel': self.quit,
                'red': self.quit,
                'menu': self.quit
            }, -2)

        self['key_red'] = StaticText(_('Close'))

        self.onFirstExecBegin.append(self.createUserSetup)
        self.onLayoutFinish.append(self.__layoutFinished)
示例#8
0
    def __init__(self, session, category_type, channellist):
        Screen.__init__(self, session)
        self.session = session

        skin = skin_path + 'hidden.xml'
        self.category_type = category_type
        self.channellist = channellist

        with open(skin, 'r') as f:
            self.skin = f.read()

        self.setup_title = (_('Hidden Categories'))

        self.startList = []
        self.drawList = []
        self['hidden_list'] = List(self.drawList)
        self['hidden_list'].onSelectionChanged.append(self.getCurrentEntry)

        self.currentSelection = 0

        self["key_red"] = StaticText(_('Cancel'))
        self["key_green"] = StaticText(_('Save'))
        self['key_red'] = StaticText(_('Cancel'))
        self['key_yellow'] = StaticText(_('Invert'))
        self['key_blue'] = StaticText(_('Clear All'))

        self.protocol = glob.current_playlist['playlist_info']['protocol']
        self.domain = glob.current_playlist['playlist_info']['domain']
        self.host = glob.current_playlist['playlist_info']['host']

        self['setupActions'] = ActionMap(
            ['ColorActions', 'SetupActions', 'ChannelSelectEPGActions'], {
                'red': self.keyCancel,
                'green': self.keyGreen,
                'yellow': self.toggleAllSelection,
                'blue': self.clearAllSelection,
                'save': self.keyGreen,
                'cancel': self.keyCancel,
                'ok': self.toggleSelection,
            }, -2)

        self.onFirstExecBegin.append(self.loadHidden)
        self.onLayoutFinish.append(self.__layoutFinished)
示例#9
0
文件: main.py 项目: OpenVu/XStreamity
    def __init__(self, session):
        Screen.__init__(self, session)
        self.session = session

        skin = skin_path + 'playlists.xml'
        with open(skin, 'r') as f:
            self.skin = f.read()

        self.list = []
        self['menu'] = List(self.list, enableWrapAround=True)

        self.setup_title = (_('Select Server'))

        self['key_red'] = StaticText(_('Back'))
        self['key_green'] = StaticText(_('Add'))
        self['key_yellow'] = StaticText()
        self['key_blue'] = StaticText()
        self['key_info'] = StaticText()
        self['key_menu'] = StaticText(_('Settings'))
        self['version'] = StaticText()

        self.list = []
        self.drawList = []
        self["playlists"] = List(self.drawList)
        self['playlists'].onSelectionChanged.append(self.getCurrentEntry)

        self["splash"] = Pixmap()
        self["splash"].hide()

        self["scroll_up"] = Pixmap()
        self["scroll_down"] = Pixmap()

        self["scroll_up"].hide()
        self["scroll_down"].hide()

        glob.configchanged = True

        self['actions'] = ActionMap(
            ['XStreamityActions'], {
                'red': self.quit,
                'green': self.addServer,
                'yellow': self.editServer,
                'blue': self.deleteServer,
                'cancel': self.quit,
                'info': self.openUserInfo,
                'ok': self.getStreamTypes,
                'menu': self.settings
            }, -2)

        self.onFirstExecBegin.append(self.start)
        self.onLayoutFinish.append(self.__layoutFinished)
示例#10
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.session = session

        skin = skin_path + 'menu.xml'
        with open(skin, 'r') as f:
            self.skin = f.read()

        self.startList = []
        self.list = []
        self.drawList = []
        self["list"] = List(self.drawList)

        self.setup_title = (_('Stream Selection'))

        self['key_red'] = StaticText(_('Back'))

        self.tempcategorytypepath = "/tmp/xstreamity/categories.xml"

        self['actions'] = ActionMap(['XStreamityActions'], {
            'red': self.quit,
            'cancel': self.quit,
            'ok': self.next,
        }, -2)

        ref = str(glob.current_playlist['playlist_info']['enigma2_api'])
        self.protocol = glob.current_playlist['playlist_info']['protocol']
        self.domain = glob.current_playlist['playlist_info']['domain']
        self.host = glob.current_playlist['playlist_info']['host']
        self.username = glob.current_playlist['playlist_info']['username']
        self.password = glob.current_playlist['playlist_info']['password']
        self.live_categories = "%s/enigma2.php?username=%s&password=%s&type=get_live_categories" % (
            self.host, self.username, self.password)
        self.live_streams = "%s/player_api.php?username=%s&password=%s&action=get_live_streams" % (
            self.host, self.username, self.password)

        if ref:
            if not ref.startswith(self.host):
                ref = str(ref.replace(self.protocol + self.domain, self.host))

        self.onFirstExecBegin.append(
            boundFunction(self.downloadEnigma2API, ref))
        self.onLayoutFinish.append(self.__layoutFinished)
示例#11
0
	def __init__(self, session, startList, currentList):
		Screen.__init__(self, session)
		self.session = session

		self.currentList =[]
		self.currentList.append(currentList)

		skin = skin_path + 'catchup.xml'

		with open(skin, 'r') as f:
			self.skin = f.read()

		self.setup_title = (_('Catch Up TV'))
		self.main_title = self.currentList[-1]["title"]

		self["channel"] = StaticText(self.main_title)

		self.list1 = []
		self.channelList = []
		self["channel_list"] = List(self.channelList, enableWrapAround=True)
		self["channel_list"].onSelectionChanged.append(self.selectionChanged)
		self.selectedlist = self["channel_list"]

		#epg variables
		self["epg_bg"] = Pixmap()
		self["epg_bg"].hide()
		self["epg_title"] = StaticText()
		self["epg_description"] = StaticText()
		self["epg_picon"] = Pixmap()
		self["epg_picon"].hide()
		
		self.catchup_all = []
		self["catchup_list"] = List(self.catchup_all, enableWrapAround=True)
		self["catchup_list"].onSelectionChanged.append(self.selectionChanged)
		


		self["key_red"] = StaticText(_('Back'))
		self["key_green"] = StaticText(_('OK'))
		self["key_yellow"] = StaticText('')
		self["key_blue"] = StaticText('')

		self.isStream = False
		self.pin = False

		self.protocol = glob.current_playlist['playlist_info']['protocol']
		self.domain = glob.current_playlist['playlist_info']['domain']
		self.host = glob.current_playlist['playlist_info']['host']
		self.username = glob.current_playlist['playlist_info']['username']
		self.password = glob.current_playlist['playlist_info']['password']
		self.live_categories = "%s/player_api.php?username=%s&password=%s&action=get_live_streams" % (self.host, self.username, self.password)
		self.simpledatatable = "%s/player_api.php?username=%s&password=%s&action=get_simple_data_table&stream_id=" % (self.host, self.username, self.password)
		
		self.downloadingpicon = False

		self["actions"] = ActionMap(["XStreamityActions"], {
			'red': self.back,
			'cancel': self.back,
			'ok' :  self.next,
			'green' : self.next,
			"left": self.pageUp,
			"right": self.pageDown,
			"up": self.goUp,
			"down": self.goDown,
			"channelUp": self.pageUp,
			"channelDown": self.pageDown,
			"0": self.reset,
			}, -2)

		glob.nextlist = []
		glob.nextlist.append({"playlist_url": self.currentList[-1]["playlist_url"], "index": 0})

		self.onFirstExecBegin.append(self.createSetup)
		self.onLayoutFinish.append(self.__layoutFinished)
示例#12
0
    def __init__(self, session, editmode):
        Screen.__init__(self, session)
        self.session = session

        skin = skin_path + 'settings.xml'

        try:
            from boxbranding import getImageDistro, getImageVersion, getOEVersion
        except:

            if owibranding.getMachineBrand(
            ) == "Dream Multimedia" or owibranding.getOEVersion() == "OE 2.2":
                skin = skin_path + 'DreamOS/settings.xml'

        with open(skin, 'r') as f:
            self.skin = f.read()

        self.setup_title = (_('Add Server'))

        self.editmode = editmode
        if self.editmode:
            self.setup_title = (_('Edit Server'))

        self.onChangedEntry = []

        self.list = []
        ConfigListScreen.__init__(self,
                                  self.list,
                                  session=self.session,
                                  on_change=self.changedEntry)

        self['key_red'] = StaticText(_('Close'))
        self['key_green'] = StaticText(_('Save'))

        self['VirtualKB'].setEnabled(False)
        self['HelpWindow'] = Pixmap()
        self['VKeyIcon'] = Pixmap()
        self['HelpWindow'].hide()
        self['VKeyIcon'].hide()

        self.name = ''
        self.protocol = 'http://'
        self.server = 'domain.xyz'
        self.port = 80
        self.username = '******'
        self.password = '******'
        self.listType = 'm3u'
        self.output = 'ts'
        self.livetype = cfg.livetype.getValue()
        self.vodtype = cfg.vodtype.getValue()
        self.epgShift = 0

        self['actions'] = ActionMap(['XStreamityActions'], {
            'cancel': self.cancel,
            'red': self.cancel,
            'green': self.save,
        }, -2)

        self.onFirstExecBegin.append(self.initConfig)

        self.onLayoutFinish.append(self.__layoutFinished)
示例#13
0
	def __init__(self, session, streamurl, servicetype):
		Screen.__init__(self, session)

		self.session = session

		InfoBarBase.__init__(self)
		InfoBarMoviePlayerSummarySupport.__init__(self)		
		InfoBarServiceNotifications.__init__(self)
		InfoBarShowHide.__init__(self)
		InfoBarSeek.__init__(self)
		InfoBarAudioSelection.__init__(self)
		InfoBarSubtitleSupport.__init__(self)
		IPTVInfoBarPVRState.__init__(self, PVRState, True)
		SubsSupport.__init__(self, searchSupport=True, embeddedSupport=True)
		SubsSupportStatus.__init__(self)

		self.streamurl = streamurl
		self.servicetype = servicetype

		skin = skin_path + 'vodplayer.xml'

		self["streamcat"] = StaticText()
		self["streamtype"] = StaticText()
		self["extension"] = StaticText()
		
		self.PicLoad = ePicLoad()
		self.Scale = AVSwitch().getFramebufferScale()
		try:
			self.PicLoad.PictureData.get().append(self.DecodePicture)
		except:
			self.PicLoad_conn = self.PicLoad.PictureData.connect(self.DecodePicture)
		
		self["cover"] = Pixmap()

		self["eventname"] = Label()
		self["state"] = Label()
		self["speed"] = Label()
		self["statusicon"] = MultiPixmap()
		
		self["PTSSeekBack"] = Pixmap()
		self["PTSSeekPointer"] = Pixmap()

		with open(skin, 'r') as f:
			self.skin = f.read()

		self.setup_title = _('VOD')

		self['actions'] = ActionMap(["XStreamityActions"], {
			'cancel': self.back,
			'tv': self.toggleStreamType,
			'info': self.toggleStreamType,
			"channelUp": self.next,
			"channelDown": self.prev,
			"up": self.prev,
			"down": self.next,
			"stop": self.back,
			"red": self.back,

			}, -2)

		self.onFirstExecBegin.append(boundFunction(self.playStream, self.servicetype, self.streamurl))
示例#14
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.session = session

        skin = skin_path + 'catchup.xml'

        with open(skin, 'r') as f:
            self.skin = f.read()

        self.setup_title = (_('Catch Up TV'))
        self.main_title = (_('Catch Up TV'))

        url = str(glob.current_playlist['playlist_info']
                  ['player_api']) + "&action=get_live_categories"

        self.level = 1
        self.category = 0

        glob.nextlist = []
        glob.nextlist.append({
            "playlist_url": url,
            "index": 0,
            "level": self.level
        })

        self["channel"] = StaticText(self.main_title)

        self.list = []
        self.channelList = []
        self["channel_list"] = List(self.channelList, enableWrapAround=True)
        self.selectedlist = self["channel_list"]

        #epg variables
        self["epg_bg"] = Pixmap()
        self["epg_bg"].hide()

        self["epg_title"] = StaticText()
        self["epg_description"] = StaticText()

        self.epgshortlist = []
        self["epg_short_list"] = List(self.epgshortlist, enableWrapAround=True)
        self["epg_short_list"].onSelectionChanged.append(self.displayShortEPG)

        self["epg_picon"] = Pixmap()
        self["epg_picon"].hide()

        self["key_red"] = StaticText(_('Back'))
        self["key_green"] = StaticText(_('OK'))
        self["key_rec"] = StaticText('')

        self.isStream = False
        self.pin = False

        self.protocol = glob.current_playlist['playlist_info']['protocol']
        self.domain = glob.current_playlist['playlist_info']['domain']
        self.host = glob.current_playlist['playlist_info']['host']
        self.livetype = glob.current_playlist['player_info']['livetype']
        self.username = glob.current_playlist['playlist_info']['username']
        self.password = glob.current_playlist['playlist_info']['password']
        self.output = glob.current_playlist['playlist_info']['output']

        self.live_categories = str(
            glob.current_playlist['playlist_info']
            ['player_api']) + "&action=get_live_categories"
        self.live_streams = str(glob.current_playlist['playlist_info']
                                ['player_api']) + "&action=get_live_streams"
        self.simpledatatable = str(
            glob.current_playlist['playlist_info']
            ['player_api']) + "&action=get_simple_data_table&stream_id="

        self["page"] = StaticText('')
        self["listposition"] = StaticText('')
        self.page = 0
        self.pageall = 0
        self.position = 0
        self.positionall = 0
        self.itemsperpage = 10

        self.showingshortEPG = False

        self.listType = ''

        self["actions"] = ActionMap(
            ["XStreamityActions"], {
                'red': self.back,
                'cancel': self.back,
                'ok': self.next,
                'green': self.next,
                "left": self.pageUp,
                "right": self.pageDown,
                "up": self.goUp,
                "down": self.goDown,
                "channelUp": self.pageUp,
                "channelDown": self.pageDown,
                "0": self.reset,
                "rec": self.downloadVideo,
            }, -2)

        self.onFirstExecBegin.append(self.createSetup)
        self.onLayoutFinish.append(self.__layoutFinished)
示例#15
0
	def __init__(self, session):
		Screen.__init__(self, session)
		
		if cfg.parental.getValue() == True:
			ProtectedScreen.__init__(self)
		self.session = session
		
		skin = skin_path + 'settings.xml'
		try:
			from boxbranding import getImageDistro, getImageVersion, getOEVersion
		except:
		
		if getBoxBrand() == "dreambox":
			skin = skin_path + 'DreamOS/settings.xml'
	
		with open(skin, 'r') as f:
			self.skin = f.read()
			
		self.setup_title = (_('Main Settings'))
		
		self.onChangedEntry = []
		
		self.list = []
		ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry)
		
		self['key_red'] = StaticText(_('Close'))
		self['key_green'] = StaticText(_('Save'))

		self['VirtualKB'].setEnabled(False)
		self['HelpWindow'] = Pixmap()
		self['VKeyIcon'] = Pixmap()
		self['HelpWindow'].hide()
		self['VKeyIcon'].hide()
		
		self['actions'] = ActionMap(['XStreamityActions'],
		 {
		 'cancel': self.cancel,
		 'red': self.cancel,
		 'green': self.save,
		 'ok': self.ok,
		 }, -2)
		 
		self.initConfig()
		
		self.onLayoutFinish.append(self.__layoutFinished)
		
	def __layoutFinished(self):
		self.setTitle(self.setup_title)
		
		
	def cancel(self, answer = None):
		if answer is None:
			if self['config'].isChanged():
				self.session.openWithCallback(self.cancel, MessageBox, _('Really close without saving settings?'))
			else:
				self.close()
		elif answer:
			for x in self['config'].list:
				x[1].cancel()
				
			self.close()
		return
		
		
	def save(self):
		glob.changed = False
		if self['config'].isChanged():
			glob.changed = True
			for x in self['config'].list:
				x[1].save()
			cfg.save()
			configfile.save()
		self.close()
		

	def initConfig(self):
		self.cfg_skin = getConfigListEntry(_('Select skin *Restart GUI Required'), cfg.skin)
		self.cfg_location = getConfigListEntry(_('playlists.txt location'), cfg.location)
		self.cfg_timeout = getConfigListEntry(_('Server timeout (seconds)'), cfg.timeout)
		
		self.cfg_livetype = getConfigListEntry(_('Default LIVE stream type'), cfg.livetype)
		self.cfg_vodtype = getConfigListEntry(_('Default VOD/SERIES stream type'), cfg.vodtype)
		self.cfg_catchuptype = getConfigListEntry(_('Default CATCHUP stream type'), cfg.vodtype)
		
		self.cfg_livepreview = getConfigListEntry(_('Preview LIVE streams in mini tv before playing'), cfg.livepreview)
		#self.cfg_stopstream = getConfigListEntry(_('Stop stream on back button'), cfg.stopstream)
		self.cfg_downloadlocation = getConfigListEntry(_('VOD download folder'), cfg.downloadlocation)
		self.cfg_parental = getConfigListEntry(_('Parental control'), cfg.parental)
		self.cfg_main = getConfigListEntry(_('Show in main menu *Restart GUI Required'), cfg.main)
		
		self.cfg_refreshTMDB = getConfigListEntry(_('Update VOD Movie Database information'), cfg.refreshTMDB)
		self.cfg_TMDBLanguage = getConfigListEntry(_('VOD Movie Database language'), cfg.TMDBLanguage)
		
		self.cfg_catchupstart = getConfigListEntry(_('Margin before catchup (mins)'), cfg.catchupstart)
		self.cfg_catchupend = getConfigListEntry(_('Margin after catchup (mins)'), cfg.catchupend)

		self.createSetup()

		
	def createSetup(self):
			self.list = []
			self.list.append(self.cfg_skin)
			self.list.append(self.cfg_location)
			self.list.append(self.cfg_timeout)
		
			self.list.append(self.cfg_livetype)
			self.list.append(self.cfg_vodtype)
			self.list.append(self.cfg_catchuptype)
			
			self.list.append(self.cfg_livepreview)
			#self.list.append(self.cfg_stopstream)
				
			self.list.append(self.cfg_downloadlocation)
				
			self.list.append(self.cfg_refreshTMDB)
			if cfg.refreshTMDB.value == True:
				self.list.append(self.cfg_TMDBLanguage)
				
			self.list.append(self.cfg_catchupstart)
			self.list.append(self.cfg_catchupend)
				
			self.list.append(self.cfg_parental)
			
			self.list.append(self.cfg_main)
			self['config'].list = self.list
			self['config'].l.setList(self.list)
			self.handleInputHelpers()       
	

	def handleInputHelpers(self):
		if self['config'].getCurrent() is not None:
			if isinstance(self['config'].getCurrent()[1], ConfigText) or isinstance(self['config'].getCurrent()[1], ConfigPassword) :
				if self.has_key('VKeyIcon'):
					if isinstance(self['config'].getCurrent()[1], ConfigNumber):
						self['VirtualKB'].setEnabled(False)
						self['VKeyIcon'].hide()
					else:
						self['VirtualKB'].setEnabled(True)
						self['VKeyIcon'].show()
				
				if not isinstance(self['config'].getCurrent()[1], ConfigNumber):
					
					if isinstance(self['config'].getCurrent()[1].help_window, ConfigText) or isinstance(self['config'].getCurrent()[1].help_window, ConfigPassword):
						if self['config'].getCurrent()[1].help_window.instance is not None:
							helpwindowpos = self['HelpWindow'].getPosition()

							if helpwindowpos:
								helpwindowposx, helpwindowposy = helpwindowpos
								if helpwindowposx and helpwindowposy:
									from enigma import ePoint
									self['config'].getCurrent()[1].help_window.instance.move(ePoint(helpwindowposx,helpwindowposy))
				
			else:
				if self.has_key('VKeyIcon'):
					self['VirtualKB'].setEnabled(False)
					self['VKeyIcon'].hide()
		else:
			if self.has_key('VKeyIcon'):
				self['VirtualKB'].setEnabled(False)
				self['VKeyIcon'].hide()
					   
	
	def changedEntry(self):
		self.item = self['config'].getCurrent()
		for x in self.onChangedEntry:
			x()
			
		try:
			if isinstance(self['config'].getCurrent()[1], ConfigEnableDisable) or isinstance(self['config'].getCurrent()[1], ConfigYesNo) or isinstance(self['config'].getCurrent()[1], ConfigSelection):
				self.createSetup()
		except:
			pass


	def getCurrentEntry(self):
		return self['config'].getCurrent() and self['config'].getCurrent()[0] or ''


	def getCurrentValue(self):
		return self['config'].getCurrent() and str(self['config'].getCurrent()[1].getText()) or ''


	def ok(self):
		ConfigListScreen.keyOK(self)
		sel = self['config'].getCurrent()[1]
		if sel and sel == cfg.location:
			self.openDirectoryBrowser(cfg.location.value, "location")
		elif sel and sel == cfg.downloadlocation:
			self.openDirectoryBrowser(cfg.downloadlocation.value, "downloadlocation")
		else:
			pass
			

	def openDirectoryBrowser(self, path, cfgitem):
		if cfgitem == "location":
			try:
				self.session.openWithCallback(
				 self.openDirectoryBrowserCB,
				 LocationBox,
				 windowTitle=_('Choose Directory:'),
				 text=_('Choose directory'),
				 currDir=str(path),
				 bookmarks=config.movielist.videodirs,
				 autoAdd=False,
				 editDir=True,
				 inhibitDirs=['/bin', '/boot', '/dev', '/home', '/lib', '/proc', '/run', '/sbin', '/sys', '/var'],
				 minFree=15)
			except Exception as e:
				print(e)
			except:
				pass
				
		if cfgitem == "downloadlocation":
			try:
				self.session.openWithCallback(
				 self.openDirectoryBrowserCB2,
				 LocationBox,
				 windowTitle=_('Choose Directory:'),
				 text=_('Choose directory'),
				 currDir=str(path),
				 bookmarks=config.movielist.videodirs,
				 autoAdd=False,
				 editDir=True,
				 inhibitDirs=['/bin', '/boot', '/dev', '/home', '/lib', '/proc', '/run', '/sbin', '/sys', '/var'],
				 minFree=15)
			except Exception as e:
				print(e)
			except:
				pass


	def openDirectoryBrowserCB(self, path):
		if path is not None:
			cfg.location.setValue(path)
		return
		
	
	def openDirectoryBrowserCB2(self, path):
		if path is not None:
			cfg.downloadlocation.setValue(path)
		return
示例#16
0
	def __init__(self, session, editmode):
		Screen.__init__(self, session)
		self.session = session
		
		skin = skin_path + 'settings.xml'
		try:
			from boxbranding import getImageDistro, getImageVersion, getOEVersion
		except:
		
		if getBoxBrand() == "dreambox":
			skin = skin_path + 'DreamOS/settings.xml'

		with open(skin, 'r') as f:
			self.skin = f.read()
			
		self.setup_title = (_('Add Server'))
		
		self.editmode = editmode
		if self.editmode:
			self.setup_title = (_('Edit Server'))
			
		self.onChangedEntry = []
		
		self.list = []
		ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry)
		
		self['key_red'] = StaticText(_('Close'))
		self['key_green'] = StaticText(_('Save'))
		
		self['VirtualKB'].setEnabled(False)
		self['HelpWindow'] = Pixmap()
		self['VKeyIcon'] = Pixmap()
		self['HelpWindow'].hide()
		self['VKeyIcon'].hide()
		
		self.protocol = 'http://'
		self.server = 'domain.xyz'
		self.port = 80
		self.username = '******'
		self.password = '******'
		self.listType = 'm3u'
		self.output = 'ts'
		
		self['actions'] = ActionMap(['XStreamityActions'],
		 {
		 'cancel': self.cancel,
		 'red': self.cancel,
		 'green': self.save,
		 }, -2)
		 
		self.onFirstExecBegin.append(self.initConfig)   
		self.onLayoutFinish.append(self.__layoutFinished)

	
	def __layoutFinished(self):
		self.setTitle(self.setup_title)
		
		
	def cancel(self, answer = None):
		if answer is None:
			if self['config'].isChanged():
				self.session.openWithCallback(self.cancel, MessageBox, _('Really close without saving settings?'))
			else:
				self.close()
		elif answer:
			for x in self['config'].list:
				x[1].cancel()
				
			self.close()
		return
		
		
	def initConfig(self): 
		streamtypechoices = [('1', 'DVB(1)'), ('4097', 'IPTV(4097)')]

		if os.path.exists("/usr/bin/gstplayer"):
			streamtypechoices.append( ('5001', 'GStreamer(5001)' ) )
			
		if os.path.exists("/usr/bin/exteplayer3"):
			streamtypechoices.append( ('5002', 'ExtePlayer(5002)') )
			
		if os.path.exists("/usr/bin/apt-get"):
			streamtypechoices.append( ('8193', 'DreamOS GStreamer(8193)') )
				
		if self.editmode == False: 
			self.protocolCfg = NoSave(ConfigSelection(default=self.protocol, choices=[('http://', _('http://')), ('https://', _('https://'))]))
			self.serverCfg = NoSave(ConfigText(default=self.server, fixed_size=False))
			self.portCfg = NoSave(ConfigNumber(default=self.port))
			self.usernameCfg = NoSave(ConfigText(default=self.username, fixed_size=False))
			self.passwordCfg = NoSave(ConfigText(default= self.password, fixed_size=False))
			self.outputCfg = NoSave(ConfigSelection(default=self.output, choices=[('ts', 'ts'), ('m3u8', 'm3u8')]))
		else: 
			self.name = str(glob.current_playlist['playlist_info']['name'])
			self.protocol = str(glob.current_playlist['playlist_info']['protocol'])
			self.domain = str(glob.current_playlist['playlist_info']['domain'])
			self.port = str(glob.current_playlist['playlist_info']['port'])
			self.username = str(glob.current_playlist['playlist_info']['username'])
			self.password = str(glob.current_playlist['playlist_info']['password'])
			self.output = str(glob.current_playlist['playlist_info']['output'])
			self.liveType = str(glob.current_playlist['player_info']['livetype'])
			self.vodType = str(glob.current_playlist['player_info']['vodtype'])
			self.catchupType = str(glob.current_playlist['player_info']['catchuptype'])
			self.epgType = str(glob.current_playlist['player_info']['epgtype'])
			self.epgshift = str(glob.current_playlist['player_info']['epgshift'])
			self.epgquickshift = str(glob.current_playlist['player_info']['epgquickshift'])
			self.showlive = glob.current_playlist['player_info']['showlive']
			self.showvod = glob.current_playlist['player_info']['showvod']
			self.showseries = glob.current_playlist['player_info']['showseries']
			self.showcatchup = glob.current_playlist['player_info']['showcatchup']
			  
			self.nameCfg = NoSave(ConfigText(default=self.name, fixed_size=False))
			self.protocolCfg = NoSave(ConfigSelection(default=self.protocol, choices=[('http://', _('http://')), ('https://', _('https://'))]))
			self.serverCfg = NoSave(ConfigText(default=self.domain, fixed_size=False))
			self.portCfg = NoSave(ConfigNumber(default=self.port))
			self.usernameCfg = NoSave(ConfigText(default=self.username, fixed_size=False))
			self.passwordCfg = NoSave(ConfigText(default=self.password, fixed_size=False))  
			self.outputCfg = NoSave(ConfigSelection(default=self.output, choices=[('ts', 'ts'), ('m3u8', 'm3u8')]))
			self.liveTypeCfg = NoSave(ConfigSelection(default=self.liveType, choices=streamtypechoices))
			self.vodTypeCfg = NoSave(ConfigSelection(default=self.vodType, choices=streamtypechoices))
			self.catchupTypeCfg = NoSave(ConfigSelection(default=self.catchupType, choices=streamtypechoices))
			self.epgTypeCfg = NoSave(ConfigSelection(default=self.epgType, choices=[   ('0', _('Off')), ('1', _('Quick')), ('2', _('Full')) ]))
			self.epgShiftCfg = NoSave(ConfigSelectionNumber(min = -12, max = 12, stepwidth = 1, default=self.epgshift))
			self.epgQuickShiftCfg = NoSave(ConfigSelectionNumber(min = -12, max = 12, stepwidth = 1, default=self.epgquickshift))
			self.showliveCfg = NoSave(ConfigYesNo(default=self.showlive))
			self.showvodCfg = NoSave(ConfigYesNo(default=self.showvod))
			self.showseriesCfg = NoSave(ConfigYesNo(default=self.showseries))
			self.showcatchupCfg = NoSave(ConfigYesNo(default=self.showcatchup))
			
		self.createSetup()
			
			
	def createSetup(self):  
		self.list = [] 
		
		if self.editmode == True: 
			self.list.append(getConfigListEntry(_('Display name:'), self.nameCfg))
			
		self.list.append(getConfigListEntry(_('Protocol:'), self.protocolCfg))
		self.list.append(getConfigListEntry(_('Server URL:'), self.serverCfg))
		self.list.append(getConfigListEntry(_('Port:'), self.portCfg))
		self.list.append(getConfigListEntry(_('Username:'******'Password:'******'Output:'), self.outputCfg))
		
		if self.editmode == True: 
			self.list.append(getConfigListEntry(_('Show LIVE category:'), self.showliveCfg))
			self.list.append(getConfigListEntry(_('Show VOD category:'), self.showvodCfg))
			self.list.append(getConfigListEntry(_('Show SERIES category:'), self.showseriesCfg))
			self.list.append(getConfigListEntry(_('Show CATCHUP category:'), self.showcatchupCfg))
			
			if self.showliveCfg.value == True:
				self.list.append(getConfigListEntry(_('Stream Type LIVE:'), self.liveTypeCfg))
				
			if self.showvodCfg.value == True or self.showseriesCfg.value == True:
				self.list.append(getConfigListEntry(_('Stream Type VOD/SERIES:'), self.vodTypeCfg))
				
			if self.showcatchupCfg.value == True:
				self.list.append(getConfigListEntry(_('Stream Type CATCHUP:'), self.catchupTypeCfg))
			
			if self.showliveCfg.value == True:
				self.list.append(getConfigListEntry(_('EPG Type:'), self.epgTypeCfg))
				self.list.append(getConfigListEntry(_('EPG/Catchup Timeshift:'), self.epgShiftCfg))
				if self.epgTypeCfg.value == '1':
					self.list.append(getConfigListEntry(_('Quick EPG Timeshift:'), self.epgQuickShiftCfg))
		
		self['config'].list = self.list
		self['config'].l.setList(self.list)
		self.handleInputHelpers()   
		
		
	def handleInputHelpers(self):
		if self['config'].getCurrent() is not None:
			if self.has_key('VKeyIcon'):
				self['VirtualKB'].setEnabled(False)
				self['VKeyIcon'].hide() 
				
			if isinstance(self['config'].getCurrent()[1], ConfigText) or isinstance(self['config'].getCurrent()[1], ConfigPassword):
				if self.has_key('VKeyIcon'):
					if isinstance(self['config'].getCurrent()[1], ConfigNumber):
						self['VirtualKB'].setEnabled(False)
						self['VKeyIcon'].hide()
					else:
						self['VirtualKB'].setEnabled(True)
						self['VKeyIcon'].show()
					
					if not isinstance(self['config'].getCurrent()[1], ConfigNumber):
						if isinstance(self['config'].getCurrent()[1].help_window, ConfigText) or isinstance(self['config'].getCurrent()[1].help_window, ConfigPassword):
							if self['config'].getCurrent()[1].help_window.instance is not None:
								helpwindowpos = self['HelpWindow'].getPosition()

								if helpwindowpos:
									helpwindowposx, helpwindowposy = helpwindowpos
									if helpwindowposx and helpwindowposy:
										from enigma import ePoint
										self['config'].getCurrent()[1].help_window.instance.move(ePoint(helpwindowposx,helpwindowposy))
		
	def save(self):
		if self['config'].isChanged():
			
			protocol = self.protocolCfg.value
			domain = self.serverCfg.value.strip()
			port = self.portCfg.value
			username = self.usernameCfg.value.strip()
			password = self.passwordCfg.value.strip()
			listtype = "m3u"
			output = self.outputCfg.value
			
			
			if self.editmode == True: 
				name = self.nameCfg.value.strip()
				
				showlive = self.showliveCfg.value
				showvod = self.showvodCfg.value
				showseries = self.showseriesCfg.value
				showcatchup = self.showcatchupCfg.value
				
				livetype = self.liveTypeCfg.value
				vodtype = self.vodTypeCfg.value
				catchuptype = self.catchupTypeCfg.value
				
				epgshift = self.epgShiftCfg.value
				epgtype = self.epgTypeCfg.value
				epgquickshift = self.epgQuickShiftCfg.value
				
				glob.current_playlist['playlist_info']['name'] = name
				glob.current_playlist['playlist_info']['protocol'] = protocol
				glob.current_playlist['playlist_info']['domain'] = domain
				glob.current_playlist['playlist_info']['port'] = port
				glob.current_playlist['playlist_info']['username'] = username
				glob.current_playlist['playlist_info']['password'] = password
				glob.current_playlist['playlist_info']['output'] = output
				glob.current_playlist['player_info']['showlive'] = showlive
				glob.current_playlist['player_info']['showvod'] = showvod
				glob.current_playlist['player_info']['showseries'] = showseries
				glob.current_playlist['player_info']['showcatchup'] = showcatchup
				glob.current_playlist['player_info']['livetype'] = livetype
				glob.current_playlist['player_info']['vodtype'] = vodtype
				glob.current_playlist['player_info']['catchuptype'] = catchuptype
				glob.current_playlist['player_info']['epgtype'] = epgtype
				glob.current_playlist['player_info']['epgshift'] = epgshift
				glob.current_playlist['player_info']['epgquickshift'] = epgquickshift
			
			playlistline = '%s%s:%s/get.php?username=%s&password=%s&type=%s&output=%s' % (protocol, domain, port, username, password, listtype, output)
			
			# update playlists.txt file 
			with open(playlist_path, 'r+') as f:
				lines = f.readlines()
				f.seek(0)
				exists = False
				for line in lines:
					if not line.startswith('http://') and not line.startswith('https://') and not line.startswith('#'):
						line = '# ' + line
					if domain in line and username in line and password in line:
						line = "\n" + str(playlistline) + "\n"
						exists = True
					f.write(line)
				if exists == False:
					f.write("\n" + str(playlistline) + "\n")
				f.truncate()    
				
				
			#update json file
			
			if os.path.isfile(json_file) and os.stat(json_file).st_size > 0:
				self.playlists_all = []
				with open(json_file) as f:
					self.playlists_all = json.load(f, object_pairs_hook=OrderedDict)
				
				x = 0
				for playlist in self.playlists_all:
					if playlist['playlist_info']['domain'] == str(domain).strip() and playlist['playlist_info']['username'] == str(username).strip() and playlist['playlist_info']['password'] == str(password).strip(): 
						self.playlists_all[x] =  glob.current_playlist
						break
					x += 1

				with open(json_file, 'w') as f:
					json.dump(self.playlists_all, f)    
			
			if self.editmode == False:  
				glob.configchanged = True
	
		self.close()
		
		
	def changedEntry(self):
		self.item = self['config'].getCurrent()
		for x in self.onChangedEntry:
			x()
		try:
			if isinstance(self['config'].getCurrent()[1], ConfigEnableDisable) or isinstance(self['config'].getCurrent()[1], ConfigYesNo) or isinstance(self['config'].getCurrent()[1], ConfigSelection):
				self.createSetup()
		except:
			pass