def leaveMoviePlayer(self, ret=None, lastPosition=None, *args, **kwargs): printDBG("leaveMoviePlayer ret[%r], lastPosition[%r]" % (ret, lastPosition)) # There is need to set None for current service # otherwise there is a problem with resuming play self.session.nav.playService(None) self.lastPosition = lastPosition self.canRunMoviePlayer = False self.inMoviePlayer = False # ret == 1 - no data in buffer # ret == 0 - triggered by user if 1 == ret: if DMHelper.STS.DOWNLOADING == self.downloader.getStatus(): self.lastSize = self.downloader.getLocalFileSize(True) printDBG("IPTVPlayerBufferingWidget.leaveMoviePlayer: movie player consume all data from buffer - still downloading") self.confirmExitCallBack() # continue else: printDBG("IPTVPlayerBufferingWidget.leaveMoviePlayer: movie player consume all data from buffer - downloading finished") if DMHelper.STS.DOWNLOADED != self.downloader.getStatus(): self.session.openWithCallback(self.close, MessageBox, text=_("Nastąpił błąd pobierania."), type = MessageBox.TYPE_ERROR, timeout=5) else: self.close() elif 0 == ret or None == ret: # ask if we should close self.lastSize = self.downloader.getLocalFileSize(True) self.session.openWithCallback(self.confirmExitCallBack, MessageBox, text=_("Zakończyć odtwarzanie?"), type=MessageBox.TYPE_YESNO)
def getLinksForVideo(self, cItem, baseName='grooveshark.com '): printDBG("GrooveShark.getLinksForVideo SongID[%s], BroadcastID[%s]" % (cItem.get('SongID', ''), cItem.get('BroadcastID', '')) ) if 'SongID' in cItem: cache_key = cItem['SongID'] elif 'Token' in cItem: cache_key = cItem['Token'] elif 'BroadcastID' in cItem: cache_key = cItem['BroadcastID'] else: return if self.url_cache['id'] == cache_key and 0 < len(self.url_cache['urlTab']): return self.url_cache['urlTab'] else: self.url_cache = {'id':0, 'urlTab':[]} urlTab = [] # FROM SongID if 'SongID' in cItem: url = self.api.getSongUrl(cItem['SongID'], False) name = baseName + _('PC') if '' == url: url = self.api.getSongUrl(cItem['SongID'], True) name = baseName + _('mobile') # FROM file Token #elif 'Token' in cItem: # url = self.api.getBroadcastUrl(cItem['Token']) # name = baseName + _('PC') # FROM mobile brodcast stream elif 'BroadcastID' in cItem: url = self.api.getBroadcastUrl(cItem['BroadcastID']) name = baseName + _('mobile broadcast') if '' != url: urlTab.append({'name':name, 'url':url}) self.url_cache = {'id':cache_key, 'urlTab':urlTab} return urlTab
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_("Show file size"), config.plugins.iptvplayer.local_showfilesize )) optionList.append(getConfigListEntry(_("Show hiddens files"), config.plugins.iptvplayer.local_showhiddensfiles )) optionList.append(getConfigListEntry(_("Show hiddens catalogs"), config.plugins.iptvplayer.local_showhiddensdir )) optionList.append(getConfigListEntry(_("Max items per page"), config.plugins.iptvplayer.local_maxitems )) return optionList
def addFromTab(self, params, tab, path, category='', need_resolve=0): table = [] if category == 'iso': table = self.getMountsTable(True) tab.sort() for item in tab: params = dict(params) params.update( {'title':item['title'], 'category':category, 'desc':''} ) if category in ['m3u', 'dir', 'iso']: fullPath = os_path.join(path, item['title']) params['path'] = fullPath if category != 'dir': descTab = [] if item.get('size', -1) >= 0: descTab.append( _("Total size: ") + formatBytes(item['size']) ) #if len(table): # params['iso_mount_path'] = self.getMountPoint(fullPath, table) # if params['iso_mount_path']: # descTab.append( _('Mounted on %s') % params['iso_mount_path'] ) if len(descTab): params['desc'] = '[/br]'.join(descTab) self.addDir(params) else: fullPath = 'file://' + os_path.join(path, item['title']) params['url'] = fullPath params['type'] = category if 'picture' == category: params['icon'] = fullPath params['need_resolve'] = need_resolve if item.get('size', -1) >= 0: params['desc'] = _("Total size: ") + formatBytes(item['size']) self.currList.append(params)
def displayList(self, activeIdx=0): list = [] tmpList = self.stackList[-1]['list'] type = self.stackList[-1]['type'] iconType = CDisplayListItem.TYPE_CATEGORY if type == 'movie': self["title"].setText(_("Select movie")) if type == 'episode': self["title"].setText(_("Select episode")) elif type == "lang": self["title"].setText(_("Select language")) elif type == "sub": iconType = CDisplayListItem.TYPE_ARTICLE self["title"].setText(_("Select subtitles to download")) self["title"].show() for item in tmpList: dItem = CDisplayListItem(name = clean_html(item['title']), type=iconType) dItem.privateData = item['private_data'] list.append( (dItem,) ) self["list"].setList(list) self["list"].show() try: self["list"].moveToIndex(activeIdx) except: pass self.setListMode(True)
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry('web-live.tv ' + _("premium user?"), config.plugins.iptvplayer.satlivetv_premium)) if config.plugins.iptvplayer.satlivetv_premium.value: optionList.append(getConfigListEntry('web-live.tv ' + _("login") + ':', config.plugins.iptvplayer.satlivetv_login)) optionList.append(getConfigListEntry('web-live.tv ' + _("password") + ':', config.plugins.iptvplayer.satlivetv_password)) return optionList
def listGames(self, cItem, category): printDBG("Twitch.listGames") sts, data = self.cm.getPage(cItem['url']) if sts: try: data = json.loads(data) if 'featured' in data: main_key = 'featured' else: main_key = 'top' for item in data[main_key]: params = dict(cItem) if 'viewers' in item and 'channels' in item: desc = _('%s viewers, %s channels') % (item['viewers'], item['channels']) else: desc = '' item = item['game'] icon = config.plugins.iptvplayer.twitch_iconssize.value params.update({'title':self._getStr(item['name']), 'url':'', 'game':self._getStr(item['name']), 'category':self._getStr(category), 'desc':self._getStr(desc), 'icon':self._getStr(item['box'][icon])}) self.addDir(params) if len(data[main_key]): nextPage = data['_links']['next'] params = dict(cItem) params.update({'title':_('Next page'), 'url':nextPage+'&on_site=1', 'desc':''}) self.addDir(params) except: printExc()
def __init__(self, session, params={}): # params: vk_title, movie_title self.session = session Screen.__init__(self, session) self.params = params self.params['login'] = config.plugins.iptvplayer.opensuborg_login.value self.params['password'] = config.plugins.iptvplayer.opensuborg_password.value self.searchPattern = CParsingHelper.getNormalizeStr( self.params.get('movie_title', '') ) # try to guess season and episode number try: tmp = CParsingHelper.getSearchGroups(self.searchPattern + ' ', 's([0-9]+?)e([0-9]+?)[^0-9]', 2) self.episodeData = {'season': int(tmp[0]), 'episode':int(tmp[1])} except: self.episodeData = {'season':-1, 'episode':-1} self.onShown.append(self.onStart) self.onClose.append(self.__onClose) self.subProvider = OpenSubOrgProvider() self["title"] = Label(" ") self["console"] = Label(" ") self["label_red"] = Label(_("Cancel")) self["label_yellow"] = Label(_("Move group")) self["label_green"] = Label(_("Apply")) self["icon_red"] = Cover3() self["icon_yellow"] = Cover3() self["icon_green"] = Cover3() self["list"] = IPTVMainNavigatorList() self["list"].connectSelChanged(self.onSelectionChanged) self["actions"] = ActionMap(["ColorActions", "SetupActions", "WizardActions", "ListboxActions"], { "cancel": self.keyExit, "ok" : self.keyOK, "red" : self.keyRed, "yellow": self.keyYellow, "green" : self.keyGreen, }, -2) self.iconPixmap = {} for icon in ['red', 'yellow', 'green']: self.iconPixmap[icon] = LoadPixmap(GetIconDir(icon+'.png')) self.movieTitle = '' self.stackList = [] self.stackItems = [] self.defaultLanguage = GetDefaultLang() self.listMode = False self.downloadedSubFilePath = '' self.loginPassed = False self.tmpItem = None
def changePin(self, pin = None, start = False): # 'PUT_OLD_PIN', 'PUT_NEW_PIN', 'CONFIRM_NEW_PIN' if True == start: self.changingPinState = 'PUT_OLD_PIN' self.session.openWithCallback(self.changePin, IPTVPinWidget, title=_("Enter old pin")) else: if pin == None: return if 'PUT_OLD_PIN' == self.changingPinState: if pin == config.plugins.iptvplayer.pin.value: self.changingPinState = 'PUT_NEW_PIN' self.session.openWithCallback(self.changePin, IPTVPinWidget, title=_("Enter new pin")) else: self.session.open(MessageBox, _("Pin incorrect!"), type=MessageBox.TYPE_INFO, timeout=5) elif 'PUT_NEW_PIN' == self.changingPinState: self.newPin = pin self.changingPinState = 'CONFIRM_NEW_PIN' self.session.openWithCallback(self.changePin, IPTVPinWidget, title=_("Confirm new pin")) elif 'CONFIRM_NEW_PIN' == self.changingPinState: if self.newPin == pin: config.plugins.iptvplayer.pin.value = pin config.plugins.iptvplayer.pin.save() configfile.save() self.session.open(MessageBox, _("Pin has been changed."), type=MessageBox.TYPE_INFO, timeout=5) else: self.session.open(MessageBox, _("Confirmation error."), type=MessageBox.TYPE_INFO, timeout=5)
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_("Language"), config.plugins.iptvplayer.tvjworg_language)) optionList.append(getConfigListEntry(_("Default video quality"), config.plugins.iptvplayer.tvjworg_default_format)) optionList.append(getConfigListEntry(_("Use default video quality"), config.plugins.iptvplayer.tvjworg_use_df)) optionList.append(getConfigListEntry(_("Icon type"), config.plugins.iptvplayer.tvjworg_icontype)) return optionList
def setOpenSSLVersion(self, ret=None): printDBG('Check opennSSL version') self.setInfo(_("Detection of the OpenSSL version."), _("OpenSSL lib is needed by wget and rtmpdump utilities.")) for ver in ['.0.9.8', '.1.0.0']: libsslExist = False libryptoExist = False for path in ['/usr/lib/', '/lib/', '/usr/local/lib/', '/local/lib/', '/lib/i386-linux-gnu/']: try: filePath = path + 'libssl.so' + ver if os_path.isfile(filePath) and not os_path.islink(filePath): libsslExist = True filePath = path + 'libcrypto.so' + ver if os_path.isfile(filePath) and not os_path.islink(filePath): libryptoExist = True if libsslExist and libryptoExist: break except: printExc() continue if libsslExist and libryptoExist: break if libsslExist and libryptoExist: self.openSSLVersion = ver #self.showMessage(_("Your OpenSSL version is [%s]") % self.openSSLVersion, MessageBox.TYPE_INFO, self.wgetDetect) self.getGstreamerVer() else: self.openSSLVersion = "" self.showMessage(_("Fatal Error!\nOpenssl could not be found. Please install it and retry."), MessageBox.TYPE_ERROR, boundFunction(self.finish, False) )
def platformDetect(self): printDBG("IPTVSetupImpl.platformDetect") self.setInfo(_("Detection of the platform."), _("Plugin can be run on one of the following platforms: sh4, mipsel, i686, arm.")) if 'j00zekFork' in globals(): from Plugins.Extensions.IPTVPlayer.j00zekScripts.j00zekToolSet import getPlatform platform = getPlatform() if platform != 'unknown': self.platform = platform config.plugins.iptvplayer.plarform.value = self.platform printDBG("IPTVSetupImpl.j00zekFork platform[%s]" % self.platform) config.plugins.iptvplayer.plarform.save() configfile.save() self.setOpenSSLVersion() return cmdTabs = [] for platform in self.supportedPlatforms: platformtesterPath = resolveFilename(SCOPE_PLUGINS, "Extensions/IPTVPlayer/bin/%s/platformtester" % platform) try: os_chmod(platformtesterPath, 0777) except: printExc() cmdTabs.append(platformtesterPath + " 2>&1 ") def _platformValidator(code, data): printDBG("IPTVSetupImpl._platformValidator") if "Test platform OK" in data: return True,False else: return False,True self.workingObj = CCmdValidator(self.platformDetectFinished, _platformValidator, cmdTabs) self.workingObj.start()
def gstifdsrcStep(self, ret=None): printDBG("IPTVSetupImpl.gstifdsrcStep") def _detectValidator(code, data): # some grep return code 1 even if the pattern has been found and printed if 0 == code or self.gstifdsrcVersion in data: return True,False return False,True def _deprecatedHandler(paths, stsTab, dataTab): sts, retPath = False, "" try: currentSize = os_path.getsize(self.gstifdsrcPaths[0]) except: currentSize = -1 if -1 < currentSize: sts, retPath = True, paths[0] return sts, retPath def _downloadCmdBuilder(binName, platform, openSSLVersion, server, tmpPath): url = server + 'bin/' + platform + ('/%s_gstreamer' % binName) + "1.0" tmpFile = tmpPath + binName cmd = SetupDownloaderCmdCreator(url, tmpFile) + ' > /dev/null 2>&1' return cmd self.stepHelper = CBinaryStepHelper("libgstifdsrc.so", self.platform, self.openSSLVersion, None) msg1 = _("GST-IFDSRC for GSTREAMER 1.X") msg2 = _("\nFor more info please ask the author [email protected]") msg3 = _('It improves buffering mode with the gstplayer.\n') self.stepHelper.updateMessage('detection', msg1, 0) self.stepHelper.updateMessage('detection', msg2, 1) self.stepHelper.updateMessage('not_detected_2', msg1 + _(' has not been detected. \nDo you want to install it? ') + msg3 + msg2, 1) self.stepHelper.updateMessage('deprecated_2', msg1 + _(' is deprecated. \nDo you want to install new one? ') + msg3 + msg2, 1) self.stepHelper.setInstallChoiseList( [('gst-ifdsrc', self.gstifdsrcPaths[0])] ) self.stepHelper.setPaths( self.gstifdsrcPaths ) self.stepHelper.setDetectCmdBuilder( lambda path: ('grep "%s" "%s" 2>&1 ' % (self.gstifdsrcVersion, path)) ) self.stepHelper.setDetectValidator( _detectValidator ) self.stepHelper.setDownloadCmdBuilder( _downloadCmdBuilder ) self.stepHelper.setDeprecatedHandler( _deprecatedHandler ) self.stepHelper.setFinishHandler( self.gstifdsrcStepFinished ) self.binaryDetect()
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_('Text files ytlist and urllist are in:'), config.plugins.iptvplayer.Sciezkaurllist)) optionList.append(getConfigListEntry(_('Show recommended by Rafalcool1:'), config.plugins.iptvplayer.urllist_showrafalcool1)) optionList.append(getConfigListEntry(_('Sort the list:'), config.plugins.iptvplayer.sortuj)) optionList.append(getConfigListEntry(_('Group links into categories: '), config.plugins.iptvplayer.grupujurllist)) return optionList
def _getHostingName(self, url): if 0 != self.up.checkHostSupport(url): return self.up.getHostName(url) elif self._uriIsValid(url): return (_('direct link')) else: return (_('unknown'))
def keyMenu(self): options = [] if not self.reorderingEnabled: options.append((_("Enable reordering mode"), "REORDERING_ENABLED")) else: options.append((_("Disable reordering mode"), "REORDERING_DISABLED")) self.session.openWithCallback(self._changeMode, ChoiceBox, title=_("Select option"), list=options)
def GetConfigList(): optionList = [] optionList.append( getConfigListEntry( _("Language:"), config.plugins.iptvplayer.movie4kto_language) ) optionList.append(getConfigListEntry(_("Use proxy gateway"), config.plugins.iptvplayer.movie4kto_use_proxy_gateway)) #if config.plugins.iptvplayer.movie4kto_use_proxy_gateway.value: # optionList.append(getConfigListEntry(" " + _("Url:"), config.plugins.iptvplayer.movie4kto_proxy_gateway_url)) return optionList
def __init__(self, session, currDir, title="Directory browser"): printDBG("IPTVDirectorySelectorWidget.__init__ -------------------------------") Screen.__init__(self, session) self["key_red"] = Label(_("Cancel")) #self["key_yellow"] = Label(_("Odśwież")) self["key_blue"] = Label(_("New dir")) self["key_green"] = Label(_("Apply")) self["curr_dir"] = Label(_(" ")) self["list"] = IPTVDirBrowserList() self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], { "green" : self.requestApply, "red" : self.requestCancel, "yellow": self.requestRefresh, "blue" : self.requestNewDir, "ok" : self.requestOk, "cancel": self.requestBack }) self.title = title self.onLayoutFinish.append(self.layoutFinished) self.onClose.append(self.__onClose) self.console = eConsoleAppContainer() self.console_appClosed_conn = eConnectCallback(self.console.appClosed, self.refreshFinished) self.console_stderrAvail_conn = eConnectCallback(self.console.stderrAvail, self.refreshNewData) self.underRefreshing = False self.underClosing = False self.deferredAction = None self.currDir = currDir self.currList = [] self.tmpData = '' self.tmpList = []
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry( "FimOn.com " + _("preferowany protokół strumieniowania" + ": "), config.plugins.iptvplayer.filmontvcom_streamprotocol)) optionList.append(getConfigListEntry( "FimOn.com " + _("użytkownik premium") + ": ", config.plugins.iptvplayer.filmontvcom_premium)) if config.plugins.iptvplayer.filmontvcom_premium.value: optionList.append(getConfigListEntry(" " + _("login") + ": ", config.plugins.iptvplayer.filmontvcom_login)) optionList.append(getConfigListEntry(" " + _("hasło") + ": ", config.plugins.iptvplayer.filmontvcom_password)) return optionList
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry("Sortuj filmy: ", config.plugins.iptvplayer.zalukajtv_filmssort)) optionList.append(getConfigListEntry("Zaloguj:", config.plugins.iptvplayer.zalukajtvPREMIUM)) if config.plugins.iptvplayer.zalukajtvPREMIUM.value: optionList.append(getConfigListEntry(" " + _("login") + ":", config.plugins.iptvplayer.zalukajtv_login)) optionList.append(getConfigListEntry(" " + _("hasło") + ":", config.plugins.iptvplayer.zalukajtv_password)) return optionList
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry( "FimOn.com " + _("Preferred streaming protocol") + ": ", config.plugins.iptvplayer.filmontvcom_streamprotocol)) optionList.append(getConfigListEntry( "FimOn.com " + _("Premium user") + ": ", config.plugins.iptvplayer.filmontvcom_premium)) if config.plugins.iptvplayer.filmontvcom_premium.value: optionList.append(getConfigListEntry(" " + _("login") + ": ", config.plugins.iptvplayer.filmontvcom_login)) optionList.append(getConfigListEntry(" " + _("password") + ": ", config.plugins.iptvplayer.filmontvcom_password)) return optionList
def stepConfirmInstalation(self, confirmed=None): if None == confirmed: self.session.openWithCallback(self.stepConfirmInstalation, MessageBox, _("Version [%s] is ready for installation. After installation, restart of the system will be done.\nDo you want to continue?") % self.serversList[self.currServIdx]['version'], type = MessageBox.TYPE_YESNO, timeout = -1) else: if confirmed: self.stepFinished(0, _("Installation has been confirmed.")) else: self.stepFinished(-1, _("Installation has been aborted."))
def downloadFinished(self, status): if status != DMHelper.STS.DOWNLOADED: self["console"].setText(_("Download failed.\nStatus[%s]") % status) else: self["console"].setText(_('Subtitles downloaded successfully. [%s], conversion to UTF-8.') % self.downloader.getFullFileName()) cmd = '%s "%s"' % (config.plugins.iptvplayer.uchardetpath.value, self.downloader.getFullFileName()) printDBG("cmd[%s]" % cmd) self.workconsole = iptv_system(cmd, self.convertSubtitles)
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry("Sortuj filmy po: ", config.plugins.iptvplayer.kinopecetowiec_filmssort)) optionList.append(getConfigListEntry("Użytkownik PREMIUM KinoPecetowiec?", config.plugins.iptvplayer.kinopecetowiec_premium)) if config.plugins.iptvplayer.kinopecetowiec_premium.value: optionList.append(getConfigListEntry(" " + _("login") + ":", config.plugins.iptvplayer.kinopecetowiec_login)) optionList.append(getConfigListEntry(" " + _("hasło") + ":", config.plugins.iptvplayer.kinopecetowiec_password)) return optionList
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_("Sort by:"), config.plugins.iptvplayer.ytSortBy)) optionList.append(getConfigListEntry(_("Path to ytlist.txt, urllist.txt"), config.plugins.iptvplayer.Sciezkaurllist)) optionList.append(getConfigListEntry(_("Video format:"), config.plugins.iptvplayer.ytformat)) optionList.append(getConfigListEntry(_("Default video quality:"), config.plugins.iptvplayer.ytDefaultformat)) optionList.append(getConfigListEntry(_("Use default video quality:"), config.plugins.iptvplayer.ytUseDF)) return optionList
def _validate(self, text): if 0 == len(text): return False, _("Name cannot be empty.") elif not IsValidFileName(text): return False, _("Name is not valid.\nPlease remove special characters.") else: group_id = text.lower() idx = self.favourites._getGroupIdx(group_id) if -1 != idx: return False, _("Group \"%s\" already exists.") % group_id return True,""
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_("Icons size"), config.plugins.iptvplayer.zdfmediathek_iconssize)) optionList.append(getConfigListEntry(_("Prefered format"), config.plugins.iptvplayer.zdfmediathek_prefformat)) optionList.append(getConfigListEntry(_("Prefered quality"), config.plugins.iptvplayer.zdfmediathek_prefquality)) optionList.append(getConfigListEntry(_("More important"), config.plugins.iptvplayer.zdfmediathek_prefmoreimportant)) optionList.append(getConfigListEntry(_("One link mode"), config.plugins.iptvplayer.zdfmediathek_onelinkmode)) return optionList
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_("Premium user"), config.plugins.iptvplayer.weebtv_premium)) if config.plugins.iptvplayer.weebtv_premium.value: optionList.append(getConfigListEntry(_("Username:"******"Password:"******"Preferred video quality:"), config.plugins.iptvplayer.weebtv_videoquality)) return optionList
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_("Kanały w jakości HD?"), config.plugins.iptvplayer.escreenHD)) optionList.append(getConfigListEntry(_("Server:"), config.plugins.iptvplayer.escreen_server)) optionList.append(getConfigListEntry(_("Escreen login:"******"Escreen hasło:"), config.plugins.iptvplayer.escreen_password)) optionList.append(getConfigListEntry(_("Adres listy M3U:"), config.plugins.iptvplayer.escreen_m3u1)) return optionList
def GetConfigList(): optionList = [] optionList.append( getConfigListEntry(_("Text files ytlist and urllist are in:"), config.plugins.iptvplayer.Sciezkaurllist) ) optionList.append(getConfigListEntry(_("Sort the list:"), config.plugins.iptvplayer.sortuj)) optionList.append(getConfigListEntry(_("Group links into categories: "), config.plugins.iptvplayer.grupujurllist)) return optionList
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_('Text files ytlist and urllist are in:'), config.plugins.iptvplayer.Sciezkaurllist)) optionList.append(getConfigListEntry(_('Sort the list:'), config.plugins.iptvplayer.sortuj)) optionList.append(getConfigListEntry(_('Group links into categories: '), config.plugins.iptvplayer.grupujurllist)) return optionList
def gettytul(): return _('Urllists player')
def getName(self): return _("Youtube Suggestions") if self.forYouyube else _("Google Suggestions")
def tryTologin(self): printDBG('tryTologin start') if None == self.loggedIn or self.login != config.plugins.iptvplayer.hdfull_login.value or self.password != config.plugins.iptvplayer.hdfull_password.value: self.cm.clearCookie(self.COOKIE_FILE, removeNames=['language']) loginCookie = GetCookieDir('hdfull.me.login') self.login = config.plugins.iptvplayer.hdfull_login.value self.password = config.plugins.iptvplayer.hdfull_password.value sts, data = self.getPage(self.getMainUrl()) if sts: self.setMainUrl(self.cm.meta['url']) freshSession = False if sts and '/logout' in data: printDBG('Check hash') hash = hexlify( md5('%s@***@%s' % (self.login, self.password)).digest()) prevHash = ReadTextFile(loginCookie)[1].strip() printDBG('$hash[%s] $prevHash[%s]' % (hash, prevHash)) if hash == prevHash: self.loggedIn = True return freshSession = True rm(loginCookie) rm(self.COOKIE_FILE) if freshSession: sts, data = self.getPage( self.getMainUrl(), MergeDicts(self.defaultParams, {'use_new_session': True})) else: sts, data = self.getPage(self.getMainUrl(), self.defaultParams) self.loggedIn = False if '' == self.login.strip() or '' == self.password.strip(): return False if sts: actionUrl = self.cm.meta['url'] post_data = {} data = self.cm.ph.getDataBeetwenNodes( data, ('<form', '>', 'login_form'), ('</form', '>'), True, False)[1] data = self.cm.ph.getAllItemsBeetwenMarkers( data, '<input', '>', False) for item in data: name = self.cm.ph.getSearchGroups( item, 'name=[\'"]([^"^\']+?)[\'"]')[0] value = self.cm.ph.getSearchGroups( item, 'value=[\'"]([^"^\']+?)[\'"]')[0] if name != '': post_data[name] = value post_data.update({ 'username': self.login, 'password': self.password, 'action': 'login' }) httpParams = dict(self.defaultParams) httpParams['header'] = MergeDicts( httpParams['header'], { 'Referer': self.cm.meta['url'], 'Content-Type': 'application/x-www-form-urlencoded' }) sts, data = self.getPage(actionUrl, httpParams, post_data) printDBG(data) if sts and '/logout' in data: printDBG('tryTologin OK') self.loggedIn = True else: msgTab = [_('Login failed.')] self.sessionEx.waitForFinishOpen(MessageBox, '\n'.join(msgTab), type=MessageBox.TYPE_ERROR, timeout=10) printDBG('tryTologin failed') if self.loggedIn: hash = hexlify( md5('%s@***@%s' % (self.login, self.password)).digest()) WriteTextFile(loginCookie, hash) return self.loggedIn
def listChannels(self, cItem): printDBG("StreamLiveTo.listChannels") page = cItem.get('page', 1) post_data = {'page': page} keysMap = { 'cat': 'category', 'lang': 'language', 'sort': 'sortBy', 'q': 'query', 'type': 'list' } if 'f_q' in cItem: keys = ['f_q'] else: keys = [] keys.extend(self.cacheFiltersKeys) for item in keys: if item not in cItem: continue key = keysMap.get(item[2:], item[2:]) post_data[key] = cItem[item] url = self.getFullUrl('channelsPages.php') sts, data = self.getPage(url, self.defaultParams, post_data) if not sts: return if 'data-page="{0}"'.format(page + 1) in data: nextPage = True else: nextPage = False data = self.cm.ph.rgetAllItemsBeetwenNodes( data.split('<nav>', 1)[0], ('</div', '>'), ('<div', '>', 'item')) for item in data: url = self._getFullUrl( self.cm.ph.getSearchGroups(item, 'href="([^"]+?)"')[0]) icon = self._getFullUrl( self.cm.ph.getSearchGroups(item, 'src="([^"]+?)"')[0]) title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<strong>', '</strong>', False)[1]) if '' == title: title = self.cleanHtmlStr( self.cm.ph.getSearchGroups(item, 'title="([^"]+?)"')[0]) if 'class="premium_only"' in item or 'Premium Only' in item: postfix = 'PREMIUM ONLY' elif 'glyphicon-king' in item: postfix = 'KING' else: postfix = '' if postfix != '': title += ' [%s]' % postfix desc = [] tmp = self.cm.ph.getAllItemsBeetwenNodes(item, ('<div', '>', '"jt'), ('</div', '>')) for t in tmp: if 'bottom' in t: continue t = self.cleanHtmlStr(t) if t != '': desc.append(t) desc = ' | '.join(desc) tmp = self.cm.ph.getAllItemsBeetwenNodes(item, ('<div', '>', 'block'), ('</div', '>'), False) for t in tmp: t = self.cleanHtmlStr(t) if t != '': desc += '[/br]' + t if self.cm.isValidUrl(url): params = { 'title': title, 'url': url, 'desc': desc, 'icon': icon } self.addVideo(params) if nextPage: params = dict(cItem) params.update({'title': _("Next page"), 'page': page + 1}) self.addDir(params)
def listProgramItems(self, cItem): title = cItem['title'] show_id = cItem['id'] printDBG("Dplay start item list of program '%s' with Id %s" % (title, show_id)) h = self.getHeader() if h == None or h == "": printDBG('Dplay wrong initialization') return url = self.SHOW_URL.format(show_id) sts, data = self.getPage(url, {'header': h}) if not sts: return #printDBG(data) try: response = json_loads(data) #attr = response["data"]["attributes"] seasonsList = self.loadSeasonsFromJson(response.get( "included", [])) for s in seasonsList: season_number = s["seasonNumber"] # search videos for each season videosForSeason = [] url = self.VIDEOBYSEASON_URL.format(show_id, season_number) sts, data = self.getPage(url, {'header': h}) if sts: try: resp_season = json_loads(data) imgList = self.loadImagesFromJson( resp_season.get("included", [])) for video in resp_season["data"]: video_id = video.get("id", "") if not video_id: continue attr = video["attributes"] name = attr.get("name", "") desc = attr.get("description", "") num_episode = attr.get("episodeNumber", "") if 'videoDuration' in attr: desc = _("Duration") + ": %s" % str( timedelta( seconds=int(attr['videoDuration'] / 1000))) + "\n" + desc plus = False if 'packages' in attr: desc = desc + "\n" + _("Packages") + ":" for p in attr['packages']: if p == "Premium": pp = "Dplay plus" plus = True else: pp = p desc = desc + " " + pp if 'publishEnd' in attr: date = datetime.strptime( attr['publishEnd'], '%Y-%m-%dT%H:%M:%SZ') desc = '{0}\n{1} {2}'.format( desc, "Disponibile fino a ", date.strftime("%d/%m/%Y")) title = '{0} ({1} {2} - {3} {4})'.format( name, _("Season"), season_number, _("Episode"), num_episode) if plus: title = title + " (PLUS)" rel = video.get("relationships", {}) images = rel.get("images", []) if images: icon_code = images["data"][0]["id"] if icon_code in imgList: icon = imgList[icon_code] else: icon = "" else: icon = "" params = { 'title': title, 'name': name, 'desc': desc, 'video_id': video_id, 'icon': icon, 'category': 'video' } #printDBG(str(params)) videosForSeason.append(params) if len(videosForSeason) > 0: # add seasons params = dict(cItem) params.update({ 'category': 'season', 'title': _("Season") + " %s (%s)" % (season_number, len(videosForSeason)), 'subitems': videosForSeason }) self.addDir(params) except: printExc() except: printExc()
def initSubProvider(self, cItem): printDBG("OpenSubtitles.initSubProvider") self.logedIn = False login = config.plugins.iptvplayer.opensuborg_login.value passwd = config.plugins.iptvplayer.opensuborg_password.value currentHash = md5('\n\n--\n\n'.join((login, passwd))).hexdigest() cokieFile = self.COOKIE_FILE + '.hash' try: with open(cokieFile, 'r') as f: prevHash = f.read() except Exception: prevHash = '' printExc() try: with open(cokieFile, 'w') as f: f.write(currentHash) except Exception: prevHash = '' printExc() # select site language sts, data = self.getPage(self.getMainUrl()) if not sts: return logoutUrl = self.getFullUrl( self.cm.ph.getSearchGroups( data, '''<a[^>]+?href=['"]([^"^']+?logout)['"]''')[0]) tmp = self.cm.ph.getDataBeetwenNodes(data, ('<ul', '>', 'lang-selector'), ('</ul', '>'))[1] printDBG(">>>\n%s\n<<" % tmp) lang = GetDefaultLang() url = self.getFullUrl( self.cm.ph.getSearchGroups( tmp, 'href="([^"]+?setlang\-%s[^"]*?)"' % lang)[0]) printDBG(">> LANG URL: " + url) if self.cm.isValidUrl(url): sts, data = self.getPage(url) if not sts: return printDBG(self.cm.ph.getAllItemsBeetwenMarkers(data, '<form', '>')) self.searchURL = self.cm.ph.getSearchGroups( data, '<form[^>]+?"searchform"[^>]+?action="([^"]+?)"')[0] printDBG(">> SEARCH URL: " + self.searchURL) # fill language cache self.languages = [] tmp = self.cm.ph.getDataBeetwenMarkers(data, '<select name="SubLanguageID"', '</select>')[1] tmp = self.cm.ph.getAllItemsBeetwenMarkers(tmp, '<option', '</option>') for item in tmp: title = self.cleanHtmlStr(item) subLanguageID = self.cm.ph.getSearchGroups( item, '''value=['"]([^"^']+?)['"]''')[0] self.languages.append({ 'title': title, 'sub_language_id': subLanguageID }) # login user if login != '' and passwd != '': if currentHash != prevHash: errMsg = _( 'Failed to connect to server "%s".') % self.getMainUrl() if logoutUrl != '': sts, data = self.getPage(logoutUrl) if not sts: self.sessionEx.open(MessageBox, errMsg, type=MessageBox.TYPE_INFO, timeout=5) return url = self.getFullUrl( self.cm.ph.getSearchGroups( data, '<form[^>]+?name="loginform"[^>]+?action="([^"]+?)"') [0]) sts, data = self.getPage(url) if not sts: self.sessionEx.open(MessageBox, errMsg, type=MessageBox.TYPE_INFO, timeout=5) return data = self.cm.ph.getDataBeetwenMarkers( data, '<form', '</form>')[1] loginUrl = self.getFullUrl( self.cm.ph.getSearchGroups(data, 'action="([^"]+?)"')[0]) data = re.compile( '<input[^>]+?name="([^"]+?)"[^>]+?value="([^"]+?)"' ).findall(data) post_data = {} for item in data: post_data[item[0]] = item[1] post_data.update({ 'user': login, 'password': passwd, 'remember': 'on' }) sts, data = self.getPage(loginUrl, post_data=post_data) if not sts: self.sessionEx.open(MessageBox, errMsg, type=MessageBox.TYPE_INFO, timeout=5) elif 'logout' not in data: self.sessionEx.open( MessageBox, _('Failed to log in user "%s". Please check your login and password.' ) % login, type=MessageBox.TYPE_INFO, timeout=5) self.logedIn = False else: if self.searchURL == '': self.searchURL = self.cm.ph.getSearchGroups( data, '<form[^>]+?"searchform"[^>]+?action="([^"]+?)"' )[0] printDBG(">> SEARCH URL: " + self.searchURL) self.logedIn = True elif logoutUrl != '': sts, data = self.getPage(logoutUrl) if not sts: self.sessionEx.open(MessageBox, errMsg, type=MessageBox.TYPE_INFO, timeout=5) return
def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_("Localization"), config.plugins.iptvplayer.dailymotion_localization)) return optionList
from Plugins.Extensions.IPTVPlayer.libs import ph ################################################### ################################################### # FOREIGN import ################################################### from datetime import timedelta import urllib import time from Components.config import config, ConfigSelection, getConfigListEntry ################################################### ################################################### # Config options for HOST ################################################### config.plugins.iptvplayer.dailymotion_localization = ConfigSelection(default="auto", choices=[("auto", _("auto")), ("ar_AA", "\xd8\xa7\xd9\x84\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a\xd8\xa9"), ("es_AR", "Argentina"), ("en_AU", "Australia"), ("de_AT", "\xc3\x96sterreich"), ("nl_BE", "Belgi\xc3\xab"), ("fr_BE", "Belgique"), ("pt_BR", "Brasil"), ("en_CA", "Canada"), ("fr_CA", "Canada"), ("zh_CN", "\xe4\xb8\xad\xe5\x9b\xbd"), ("fr_FR", "France"), ("de_DE", "Deutschland"), ("el_GR", "\xce\x95\xce\xbb\xce\xbb\xce\xac\xce\xb4\xce\xb1"), ("en_IN", "India"), ("id_ID", "Indonesia"), ("en_EN", "International"), ("en_IE", "Ireland"), ("it_IT", "Italia"), ("ja_JP", "\xe6\x97\xa5\xe6\x9c\xac"), ("ms_MY", "Malaysia"), ("es_MX", "M\xc3\xa9xico"), ("fr_MA", "Maroc"), ("nl_NL", "Nederland"), ("en_PK", "Pakistan"), ("en_PH", "Pilipinas"), ("pl_PL", "Polska"), ("pt_PT", "Portugal"), ("ro_RO", "Rom\xc3\xa2nia"), ("ru_RU", "\xd0\xa0\xd0\xbe\xd1\x81\xd1\x81\xd0\xb8\xd1\x8f"), ("en_SG", "Singapore"), ("ko_KR", "\xeb\x8c\x80\xed\x95\x9c\xeb\xaf\xbc\xea\xb5\xad"), ("es_ES", "Espa\xc3\xb1a"), ("fr_CH", "Suisse"), ("it_CH", "Svizzera"), ("de_CH", "Schweiz"), ("fr_TN", "Tunisie"), ("tr_TR", "T\xc3\xbcrkiye"), ("en_GB", "United Kingdom"), ("en_US", "United States"), ("vi_VN", "Vi\xe1\xbb\x87t Nam")]) def GetConfigList(): optionList = [] optionList.append(getConfigListEntry(_("Localization"), config.plugins.iptvplayer.dailymotion_localization)) return optionList ################################################### def gettytul(): return 'http://dailymotion.com/' class Dailymotion(CBaseHostClass):
def addNextPage(self, cItem, nextPage, page): if nextPage: params = dict(cItem) params.update({'title': _('Next page'), 'page': page + 1}) self.addDir(params)
class GameTrailers(CBaseHostClass): HEADER = {'User-Agent': 'Mozilla/5.0', 'Accept': 'text/html'} AJAX_HEADER = dict(HEADER) AJAX_HEADER.update({'X-Requested-With': 'XMLHttpRequest'}) MAIN_URL = "http://www.gametrailers.com/" SEARCH_URL = MAIN_URL + "search" GAMES_OF_MONTH_URL = MAIN_URL + 'games/dk31tx/gt-release-calendar/videos-trailers' MAIN_ICON = "http://images.eurogamer.net/2012/articles//a/1/4/9/4/8/9/0/GT_Logo_Front.jpg/EG11/thumbnail/360x200/" MAIN_CAT_TAB = [{ 'category': 'filters', 'mode': '', 'title': 'Videos', 'url': MAIN_URL + 'videos-trailers', 'icon': MAIN_ICON }, { 'category': 'shows', 'mode': 'shows', 'title': 'Shows', 'url': MAIN_URL + 'shows', 'icon': MAIN_ICON }, { 'category': 'filters', 'mode': '', 'title': 'Reviews', 'url': MAIN_URL + 'reviews', 'icon': MAIN_ICON }, { 'category': 'filters', 'mode': '', 'title': 'Games of the month', 'url': GAMES_OF_MONTH_URL, 'icon': MAIN_ICON }, { 'category': 'platforms', 'mode': '', 'title': 'Platforms', 'url': MAIN_URL, 'icon': MAIN_ICON }, { 'category': 'search', 'title': _('Search'), 'search_item': True }, { 'category': 'search_history', 'title': _('Search history') }] SORT_BY_TAB = [{ 'title': 'Most Viewed', 'sort_by': 'most_viewed' }, { 'title': 'Most Recent', 'sort_by': 'most_recent' }] IMAGE_QUALITY = 'width=160&height=90&crop=true&quality=.91' def __init__(self): CBaseHostClass.__init__(self, { 'history': 'GameTrailers', 'cookie': 'gametrailers.cookie' }) self.defaultParams = { 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE } def _getFullUrl(self, url, mode): if url.startswith('//'): url = 'http:' + url elif 0 < len(url) and not url.startswith('http'): url = self.MAIN_URLS[mode] + url if self.MAIN_URLS[mode].startswith('https://'): url = url.replace('https://', 'http://') return url def _getValue(self, item, name): return self.cm.ph.getSearchGroups( item, '<meta itemprop="%s" content="([^"]+?)"' % name)[0] def addIconQuality(self, iconUrl): printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [%s]" % iconUrl) if iconUrl.startswith('http') and iconUrl.endswith('?'): return iconUrl + self.IMAGE_QUALITY return '' def cleanHtmlStr(self, data): data = data.replace(' ', ' ') data = data.replace(' ', ' ') return CBaseHostClass.cleanHtmlStr(data) def listsTab(self, tab, cItem, type='dir'): printDBG("GameTrailers.listsTab") for item in tab: params = dict(cItem) params.update(item) params['name'] = 'category' if type == 'dir': self.addDir(params) else: self.addVideo(params) def listPlatforms(self, cItem, nextCategory): printDBG("GameTrailers.listPlatforms") sts, data = self.cm.getPage(cItem['url']) if not sts: return data = self.cm.ph.getDataBeetwenMarkers(data, '<ul class="platform_nav">', '</ul>', False)[1] data = re.compile('<a[^>]*?href="([^"]+?)"[^>]*?>(.+?)</a>').findall( data) for item in data: if 'mobile-apps' in item[0]: continue params = dict(cItem) params.update({ 'title': self.cleanHtmlStr(item[1]), 'category': nextCategory, 'url': item[0] }) self.addDir(params) def getFilters(self, cItem, nextCategory): printDBG("GameTrailers.getFilters") if 'filters' in cItem: for item in cItem['filters']: params = dict(cItem) params.update({ 'title': item['title'], 'category': nextCategory, 'sub_items': item['sub_items'] }) self.addDir(params) return sts, data = self.cm.getPage(cItem['url']) if not sts: return baseUrl = self.cm.ph.getDataBeetwenMarkers( data, 'line_listing_results.init("', '"', False)[1] cItem = dict(cItem) cItem['base_url'] = baseUrl printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [%s]" % baseUrl) data = self.cm.ph.getDataBeetwenMarkers(data, 'class="filter_main_type">', '</div>', False)[1] data = data.split('class="filter_main_type">') mainFiltersTab = [] for mainFilter in data: mainTitle = self.cm.ph.getDataBeetwenMarkers( mainFilter, '<h5>', '</h5>', False)[1] if '<ul class="sub_filter_group">' in mainFilter: subFilterData = mainFilter.split('<li class="facet_wrapper">') if len(subFilterData) > 0: del subFilterData[0] else: subFilterData = [mainFilter] subFiltersTab = [] for subFilter in subFilterData: #printDBG("====================================================") #printDBG(subFilter) #printDBG("====================================================") subTitle = self.cm.ph.getDataBeetwenMarkers( subFilter, '<h6>', '</h6>', False)[1] subItems = re.compile( '<span class="[^"]+?" name="([^"]+?)" value="([^"]+?)">([^<]+?)<span>' ).findall(subFilter) subItemsTab = [] for item in subItems: subItemsTab.append({ "_name": item[0], "_value": item[1], "title": item[2] }) if len(subItemsTab): subFiltersTab.append({ 'title': subTitle, 'sub_items': subItemsTab }) if len(subFiltersTab) == 1: params = dict(cItem) params.update({ 'title': mainTitle, 'category': nextCategory, 'sub_items': subItemsTab }) self.addDir(params) elif len(subFiltersTab) > 0: params = dict(cItem) params.update({'title': mainTitle, 'filters': subFiltersTab}) self.addDir(params) def listShows(self, cItem, nextCategory): printDBG("GameTrailers.listPlatforms") sts, data = self.cm.getPage(cItem['url']) if not sts: return data = self.cm.ph.getDataBeetwenMarkers(data, '<span class="latest_item">', '<div id="mod_"', False)[1] data = data.split('<span class="latest_item">') for item in data: params = dict(cItem) params['category'] = nextCategory params['title'] = self._getValue(item, 'name') params['url'] = self._getValue(item, 'url') params['icon'] = self.addIconQuality(self._getValue(item, 'image')) params['desc'] = self.cleanHtmlStr(item) self.addDir(params) def listShowItems(self, cItem): printDBG("GameTrailers.listShowItems") if 'base_url' not in cItem: sts, data = self.cm.getPage(cItem['url']) if not sts: return baseUrl = self.cm.ph.getDataBeetwenMarkers(data, 'data-url="', '"', False)[1] cItem = dict(cItem) cItem['base_url'] = baseUrl printDBG( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [%s]" % baseUrl) self.listItems(cItem) def listItems(self, cItem, nextCategory=None): printDBG("GameTrailers.listItems") page = cItem.get('page', 1) url = cItem['base_url'] if '&' in url: url += '&' else: url += '?' if 1 == page: url += 'sortBy={0}'.format(cItem.get('sort_by', 'undefined')) if '_name' in cItem: url += '&{0}={1}'.format(cItem['_name'], cItem['_value']) elif '_name_value' in cItem: url += '&{0}'.format(cItem['_name_value']) else: url += 'currentPage={0}'.format(page) cItem = dict(cItem) cItem['Referer'] = url post_data = cItem.get('post_data', None) httpParams = dict(self.defaultParams) ContentType = cItem.get('Content-Type', None) Referer = cItem.get('Referer', None) if None != Referer: httpParams['header'] = { 'Referer': Referer, 'User-Agent': self.cm.HOST } else: {'User-Agent': self.cm.HOST} sts, data = self.cm.getPage(url, httpParams, post_data) if not sts: return p1 = '<li class="pagination_holder">' p2 = '<div class="pagination">' if p1 in data: data = data.split(p1) else: data = data.split(p2) nextPage = False if len(data) > 1: if 'href="?currentPage={0}"'.format(page + 1) in data[1]: nextPage = True data = data[0] if 'search' == cItem.get('mode', ''): if 'user_movies' == cItem['search_tab']: m1 = '<div class="content"' else: m1 = '<div class="holder"' self.listSearchVideoItems(cItem, data, m1) else: self.listVideoItems(cItem, data) if nextPage: params = dict(cItem) params.update({'title': _("Next page"), 'page': page + 1}) self.addDir(params) def listSearchVideoItems(self, cItem, data, m1): data = data.split(m1) if len(data): del data[0] for item in data: params = self._mapItemBase('<' + item) if '' == params['url']: continue self.addVideo(params) def listVideoItems(self, cItem, data): data = data.split('</li>') if len(data): del data[-1] for item in data: params = self._mapItemBase(item) if '' == params['url']: continue self.addVideo(params) def _mapItemBase(self, item): params = {} url = self.cm.ph.getSearchGroups( item, '<a href="([^"]+?)" class="thumbnail">')[0] if '' == url: url = self.cm.ph.getSearchGroups( item, '<a class="watch[^"]*?" href="([^"]+?)"')[0] params['url'] = url params['title'] = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<h3>', '</h3>', False)[1] + ' ' + self.cm.ph.getDataBeetwenMarkers(item, '<h4>', '</h4>', False)[1]) if '' == params['title']: params['title'] = self._getValue(item, "name") icon = self.addIconQuality(self._getValue(item, "thumbnailUrl")) if '' == icon: icon = self.cm.ph.getSearchGroups( item, '<img class="thumbnail" src="([^"]+?)"')[0] if '' == icon: icon = self.addIconQuality(self._getValue(item, "image")) if '' == icon: icon = self.cm.ph.getSearchGroups(item, '<img src="([^"]+?)"')[0] if '' == icon: icon = self.MAIN_ICON params['icon'] = icon params['desc'] = self.cleanHtmlStr(item) return params def listSearchResult(self, cItem, searchPattern, searchType): printDBG( "GameTrailers.listSearchResult cItem[%s], searchPattern[%s] searchType[%s]" % (cItem, searchPattern, searchType)) url = self.SEARCH_URL + '?keywords=' + urllib.quote_plus(searchPattern) post_data = cItem.get('post_data', None) httpParams = dict(self.defaultParams) ContentType = cItem.get('Content-Type', None) Referer = cItem.get('Referer', None) if None != Referer: httpParams['header'] = { 'Referer': Referer, 'User-Agent': self.cm.HOST } else: {'User-Agent': self.cm.HOST} sts, data = self.cm.getPage(url, httpParams, post_data) if not sts: return promotionId = self.cm.ph.getSearchGroups( data, 'promotionId=([^/]+?)/')[0].replace('"', '').replace( "'", "") + '/' data = self.cm.ph.getDataBeetwenMarkers(data, '<ul class="module_tabs">', '</ul>', False)[1] data = data.split('</a>') for item in data: sts, tab = self.cm.ph.getDataBeetwenMarkers( item, 'class="tab_', '"', False) if not sts: continue if tab not in ['videos', 'reviews', 'user_movies']: continue title = self.cleanHtmlStr(item) baseUrl = self.MAIN_URL + 'feeds/search/child/{0}/?keywords={1}&tabName={2}'.format( promotionId, urllib.quote_plus(searchPattern), tab) params = { 'name': 'category', 'base_url': baseUrl, 'title': title, 'mode': 'search', 'search_tab': tab } params['category'] = 'list_sort_by' self.addDir(params) def getLinksForVideo(self, cItem): printDBG("GameTrailers.getLinksForVideo [%s]" % cItem) urlTab = [] videoUrl = cItem['url'] urlTab = self.up.getVideoLinkExt(videoUrl) for idx in range(len(urlTab)): urlTab[idx]['need_resolve'] = 0 return urlTab def getFavouriteData(self, cItem): return json.dumps(cItem['url']) def getLinksForFavourite(self, fav_data): return self.getLinksForVideo(fav_data) def handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') filters = self.currItem.get("filters", {}) printDBG( "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] " % (name, category)) self.currList = [] #MAIN MENU cItem = self.currItem if name == None: self.listsTab(self.MAIN_CAT_TAB, {'name': 'category'}) elif category == 'filters': self.getFilters(self.currItem, 'list_filters') if 1 == len(self.currList): cItem = self.currList[0] self.currList = [] category = 'list_filters' if category == 'list_filters': self.listsTab( cItem.get('sub_items', []), { 'name': 'category', 'category': 'list_sort_by', 'icon': self.MAIN_ICON, 'base_url': cItem['base_url'] }) if 1 == len(self.currList): cItem = self.currList[0] self.currList = [] category = 'list_sort_by' if category == 'list_sort_by': cItem = dict(cItem) if 'shows' == cItem.get('mode', ''): cItem['category'] = 'list_show_items' else: cItem['category'] = 'list_videos' self.listsTab(self.SORT_BY_TAB, cItem) elif category == 'list_videos': self.listItems(self.currItem) elif category == 'shows': self.listShows(self.currItem, 'list_sort_by') elif category == 'list_show_items': self.listShowItems(self.currItem) elif category == 'platforms': self.listPlatforms(self.currItem, 'filters') elif category == 'list_episodes': self.listEpisodes(self.currItem) #SEARCH elif category in ["search", "search_next_page"]: cItem = dict(self.currItem) cItem.update({'search_item': False, 'name': 'category'}) self.listSearchResult(cItem, searchPattern, searchType) #HISTORIA SEARCH elif category == "search_history": self.listsHistory({ 'name': 'history', 'category': 'search' }, 'desc', _("Type: ")) else: printExc() CBaseHostClass.endHandleService(self, index, refresh)
def listItems(self, cItem, nextCategory): printDBG("<<<<<<<<<<<<< DSDA.listItems <<<<<<<<<<<<<<<<<<<<<<") printDBG("cItem<<<<< " + str(cItem)) page = cItem.get('page', 1) url = cItem.get('url', '') urlnext = url title = cItem.get('title', '') printDBG("title<<< " + title) if (title == "Search") or ("Next page" in title) or ( title == "Documentari Ultime uscite"): #don't do any think searchPattern = cItem.get('searchPattern', '') printDBG("searchPattern<<< " + searchPattern) printDBG("url<<< " + url) #https://documentari-streaming-da.com/?searchtype=movie&post_type=movie&s=squalo #url = "https://documentari-streaming-da.com/?searchtype=movie&post_type=movie&s="+searchPattern else: #https://documentari-streaming-da.com/page/3/?searchtype=movie&post_type=movie&sl=lasts&cat=seminari-e-conferenze&s= t = title.replace("Documentari ", "") t = t.replace(" ", "-") t = t.lower() if "serie" in t: t = "series" if "raccolte" in t: t = "groups" if "societ" in t: t = "societa" #t = title.replace("documentari-", "") printDBG("page<<< " + str(page)) url = self.MAIN_URL + "page/" + str( page ) + "/?searchtype=movie&post_type=movie&sl=lasts&cat=" + t + "&s" urlnext = url printDBG(url) sts, data = self.cm.getPage(url) if not sts: return tmp = self.cm.ph.getDataBeetwenMarkers( data, ('elementor-grid-1 elementor-posts--align-center'), ('<nav class="elementor-pagination'), False)[1] printDBG(tmp) #pntemp = re.findall('''elementor-grid-1 elementor-posts--align-center(.*?)<nav class="elementor-pagination''', data, re.S) pntemp = re.findall('''<article class(.*?)</article>''', tmp, re.S) #printDBG(pntemp) printDBG(str(pntemp)) for t in pntemp: #print(t) icon = re.findall('''src="(.*?)"''', t, re.S)[0] url = re.findall('''href="(.*?)"''', t, re.S)[0] title = re.findall('''/">\n\t\t\t\t(.*?)\t\t\t</a>\n\t\t</h3>''', t, re.S)[0] title = HTMLParser.HTMLParser().unescape(title).encode('utf-8') params = dict(cItem) params.update({ 'good_for_fav': True, 'category': nextCategory, 'title': title, 'url': url, 'icon': icon, 'desc': title }) printDBG(str(params)) self.addDir(params) #next page if "page-numbers next" in data: tmp = urlnext.split("/" + str(page)) printDBG("next page-numbers<<< ") printDBG("urlnext<<< " + urlnext) urlnext = tmp[0] + "/" + str(page + 1) + tmp[1] printDBG("urlnext<<< " + urlnext) params = dict(cItem) params.update({ 'title': _("Next page"), 'page': page + 1, 'url': urlnext }) self.addMore(params)
def listDownloadItems(self, cItem, nextCategory, data=None): printDBG("OpenSubtitles.listDownloadItems") if data == None: sts, data = self.getPage(cItem['url']) if not sts: return page = cItem.get('page', 1) nextPage = self.getFullUrl( self.cm.ph.getSearchGroups( data, '<link[^>]+?rel="next"[^>]+?href="([^"]+?)"')[0]) data = self.cm.ph.getDataBeetwenMarkers(data, '<tr onclick', '</tbody>')[1] data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<tr onclick', '</tr>') for item in data: url = self.cm.ph.getSearchGroups(item, 'href="([^"]+?/sub/[^"]+?)"')[0] title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers( item, '<td', '</td>')[1].split('<a rel="nofollow"')[0]) imdbid = self.cm.ph.getSearchGroups(item, '''/tt([0-9]+?)[^0-9]''')[0] lang = self.cm.ph.getSearchGroups(item, '''class="flag\s*([^"]+?)"''')[0] descTab = [] tmp = self.cm.ph.getAllItemsBeetwenMarkers(item, '<td', '</td>') if len(tmp) > 3: fps = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(tmp[3], '<span', '</span>')[1]) else: fps = '0' if len(tmp) > 4: format = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(tmp[4], '<span', '</span>')[1]) else: format = '0' for t in tmp: t = t.split('<a rel="nofollow"')[0] t = self.cleanHtmlStr(t) if t != '': descTab.append(t) params = dict(cItem) params.update({ 'category': nextCategory, 'lang': lang, 'fps': fps, 'format': format, 'title': '[%s | %s] %s' % (lang, format, title), 'imdbid': imdbid, 'url': self.getFullUrl(url), 'desc': ' | '.join(descTab) }) self.addDir(params) if self.cm.isValidUrl(nextPage): params = dict(cItem) params.update({'title': _('Next page'), 'page': page + 1}) self.addDir(params)
def listItems(self, cItem, nextCategory): printDBG("FilmixCO.listItems") page = cItem.get('page', 1) postData = cItem.get('post_data') urlParams = dict(self.defaultParams) if '/ajax/' in cItem['url']: urlParams['header'] = dict(self.AJAX_HEADER) urlParams['Referer'] = self.getMainUrl() sts, data = self.getPage(cItem['url'], urlParams, postData) if not sts: return nextPage = self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'navigation'), ('</div', '>'), False)[1] nextPage = self.cm.ph.getSearchGroups( nextPage, '''<a[^>]+?href=['"]([^'^"]+?)['"][^>]*?>%s</a>''' % (page + 1))[0] data = self.cm.ph.getAllItemsBeetwenNodes( data, ('<article', '>', 'itemtype'), ('</article', '>'), False) for item in data: icon = self.getFullIconUrl( self.cm.ph.getSearchGroups( item, '''<img[^>]+?src=['"]([^"^']+?)['"]''')[0]) tmp = self.cm.ph.getDataBeetwenNodes(item, ('<div', '>', 'name-block'), ('</div', '>'))[1] url = self.getFullUrl( self.cm.ph.getSearchGroups(tmp, '''href=['"]([^"^']+?)['"]''')[0]) title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(tmp, '<h2', '</h2>')[1]) titleOrg = self.cleanHtmlStr( self.cm.ph.getDataBeetwenNodes(item, ('<div', '>', 'origin-name'), ('</div', '>'))[1]) if titleOrg != '': if title == '': title = titleOrg else: title += ' / %s' % titleOrg desc = [] tmp = self.cm.ph.getAllItemsBeetwenNodes(item, ('<div', '>', '"item'), ('</div', '>')) tmp.append(self.cm.ph.getDataBeetwenMarkers(item, '<p', '</p>')[1]) for t in tmp: t = self.cleanHtmlStr(t) if t != '': desc.append(t.replace(' , ', ', ')) if url != '': params = dict(cItem) params.update({ 'category': nextCategory, 'good_for_fav': True, 'title': title, 'url': url, 'desc': '[/br]'.join(desc), 'icon': icon }) self.addDir(params) if nextPage != '': params = dict(cItem) params.pop('post_data', None) params.pop('desc', None) params.update({ 'title': _("Next page"), 'url': nextPage, 'page': page + 1 }) self.addDir(params)
def getList(self, cItem): printDBG("CanlitvliveIoApi.getList") itemsList = [] category = cItem.get('priv_category', None) if category == None: itemsList.append({'name':cItem['name'], 'priv_category':'tv', 'type':'dir', 'title':_('TV'), 'url':self.MAIN_URL_TV, 'desc':self.MAIN_URL_TV, 'icon':self.DEFAULT_ICON_URL}) itemsList.append({'name':cItem['name'], 'priv_category':'radio', 'type':'dir', 'title':_('RADIO'), 'url':self.MAIN_URL_RADIO, 'desc':self.MAIN_URL_RADIO, 'icon':self.DEFAULT_ICON_URL}) return itemsList elif category == 'tv': self.MAIN_URL = self.MAIN_URL_TV return self.getCategories(cItem, 'priv_list_channels') elif category == 'radio': self.MAIN_URL = self.MAIN_URL_RADIO return self.getCategories(cItem, 'priv_list_channels') elif category == 'priv_list_channels': return self.getChannelsList(cItem) return itemsList
def fillCacheFilters(self): printDBG("StreamLiveTo.fillCacheFilters") self.cacheFilters = {} self.cacheFiltersKeys = [] sts, data = self.getPage(self._getFullUrl('channels'), self.defaultParams) #sts, data = self.getPage(self.MAIN_URL, self.defaultParams) if not sts: return tmpTab = [] tmp = self.cm.ph.getDataBeetwenMarkers(data, '<select name="category"', '</select>', False)[1] tmp = re.compile( '<option [^>]*?value="([^"]*?)"[^>]*?>([^<]+?)</option>').findall( tmp) for item in tmp: tmpTab.append({'title': item[1], 'f_cat': urllib.quote(item[0])}) if len(tmpTab): self.cacheFilters['f_cat'] = tmpTab self.cacheFiltersKeys.append('f_cat') tmpTab = [] tmp = self.cm.ph.getDataBeetwenMarkers(data, '<select name="language"', '</select>', False)[1] tmp = re.compile( '<option [^>]*?value="([^"]*?)"[^>]*?>([^<]+?)</option>').findall( tmp) for item in tmp: tmpTab.append({'title': item[1], 'f_lang': item[0]}) if len(tmpTab): self.cacheFilters['f_lang'] = tmpTab self.cacheFiltersKeys.append('f_lang') tmpTab = [] tmp = self.cm.ph.getDataBeetwenMarkers(data, '<select name="sortBy"', '</select>', False)[1] tmp = re.compile( '<option [^>]*?value="([^"]*?)"[^>]*?>([^<]+?)</option>').findall( tmp) for item in tmp: tmpTab.append({'title': item[1], 'f_sort': item[0]}) if len(tmpTab): self.cacheFilters['f_sort'] = tmpTab self.cacheFiltersKeys.append('f_sort') sts, data = self.getPage(self._getFullUrl('channelsPages.php'), self.defaultParams) if not sts: return data = self.cm.ph.getDataBeetwenMarkers(data, '<h2', '</h2>')[1] data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<a', '</a>') tmpTab = [] for item in data: val = self.cm.ph.getSearchGroups( item, '''[\?&]list=([^'^"^&]+?)['"&]''')[0] title = self.cleanHtmlStr(item) tmpTab.append({'title': title, 'f_type': val}) if len(tmpTab) == 0: for item in [(_('Any'), ''), (_('Free'), 'free'), (_('Premium'), 'premium')]: tmpTab.append({'title': item[0], 'f_type': item[1]}) if len(tmpTab): self.cacheFilters['f_type'] = tmpTab self.cacheFiltersKeys.insert(0, 'f_type')
def tryTologin(self): printDBG('tryTologin start') self.selectDomain() if None == self.loggedIn or self.login != config.plugins.iptvplayer.filmixco_login.value or\ self.password != config.plugins.iptvplayer.filmixco_password.value: loginCookie = GetCookieDir('filmix.co.login') self.login = config.plugins.iptvplayer.filmixco_login.value self.password = config.plugins.iptvplayer.filmixco_password.value sts, data = self.getPage(self.getMainUrl()) if sts: self.setMainUrl(self.cm.meta['url']) freshSession = False if sts and 'action=logout' in data: printDBG("Check hash") hash = hexlify( md5('%s@***@%s' % (self.login, self.password)).digest()) prevHash = ReadTextFile(loginCookie)[1].strip() printDBG("$hash[%s] $prevHash[%s]" % (hash, prevHash)) if hash == prevHash: self.loggedIn = True return else: freshSession = True rm(loginCookie) rm(self.COOKIE_FILE) if freshSession: sts, data = self.getPage( self.getMainUrl(), MergeDicts(self.defaultParams, {'use_new_session': True})) self.loggedIn = False if '' == self.login.strip() or '' == self.password.strip(): return False msgTab = [_('Login failed.')] if sts: actionUrl = self.getFullUrl('/engine/ajax/user_auth.php') post_data = { 'login_name': self.login, 'login_password': self.password, 'login_not_save': '1', 'login': '******' } httpParams = dict(self.defaultParams) httpParams['header'] = MergeDicts( httpParams['header'], { 'Referer': self.cm.meta['url'], 'Accept': '*/*', 'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }) sts, data = self.getPage(actionUrl, httpParams, post_data) printDBG(data) if sts: msgTab.append(ph.clean_html(data)) sts, data = self.getPage(self.getMainUrl()) if sts and 'action=logout' in data: printDBG('tryTologin OK') self.loggedIn = True else: printDBG(data) self.sessionEx.waitForFinishOpen(MessageBox, '\n'.join(msgTab), type=MessageBox.TYPE_ERROR, timeout=10) printDBG('tryTologin failed') if self.loggedIn: hash = hexlify( md5('%s@***@%s' % (self.login, self.password)).digest()) WriteTextFile(loginCookie, hash) return self.loggedIn
def getName(self): return _('HDFull Suggestions')
def listFilters(self, cItem, nextCategory): printDBG("FilmixCO.listFilters") idx = cItem.get('f_idx', 0) if idx < len(self.cacheFilters): filter = self.cacheFilters[idx] if 'values' not in filter and 'type' in filter: # separate request is needed to get filter values values = [] if 'rating' == filter['type']: for i in range(9, 0, -1): values.append({ 'title': '%s-%s' % (str(i).zfill(2), str(i + 1).zfill(2)), ('f_%s' % filter['scope']): '%s%s' % (str(i).zfill(2), str(i + 1).zfill(2)) }) if len(values): values.insert(0, {'title': _('--Any--')}) else: url = self.getFullUrl('/engine/ajax/get_filter.php') urlParams = dict(self.defaultParams) urlParams['header'] = dict(self.AJAX_HEADER) urlParams['Referer'] = self.getMainUrl() sts, data = self.getPage(url, urlParams, { 'scope': 'cat', 'type': filter['type'] }) if not sts: return try: printDBG(data) data = json_loads('[%s]' % data.replace('":"', '","')[1:-1]) for i in range(0, len(data), 2): title = self.cleanHtmlStr(data[i + 1]) value = data[i] if value.startswith('f'): value = value[1:] values.append({ 'title': title, ('f_%s' % filter['scope']): value }) if len(values): if 'years' == filter['type']: values.reverse() values.insert(0, {'title': _('--Any--')}) filter['values'] = values except Exception: printExc() elif 'values' in filter: values = filter['values'] cItem = dict(cItem) idx += 1 if idx < len(self.cacheFilters): cItem['f_idx'] = idx else: cItem['category'] = nextCategory for item in values: params = dict(cItem) params.update(item) params['url'] = self.getFilterUrl(params) self.addDir(params) else: printExc("Should not happen")
def listMain(self, cItem): printDBG('HDFull.listMain') sts, data = self.getPage(self.getMainUrl()) printDBG(data) if not sts: return self.setMainUrl(self.cm.meta['url']) reObj = re.compile('<ul[^>]*?>') data = self.cm.ph.getAllItemsBeetwenNodes(data, ('<li', '>', 'dropdown'), ('</ul', '>'), False) for menuData in data: menuData = reObj.split(menuData, 1) menuUrl = self.getFullUrl( self.cm.ph.getSearchGroups(menuData[0], '\\shref=[\'"]([^\'^"]+?)[\'"]')[0]) category = menuUrl.rsplit('/')[-1] if category in ('tv-shows', 'series'): category = 'list_sort_series' elif category in ('peliculas', 'movies'): category = 'list_sort_movies' elif category == '#': category = '' else: continue menuTitle = self.cleanHtmlStr(menuData[0]) menuData = self.cm.ph.getAllItemsBeetwenMarkers( menuData[-1], '<li', '</li>') subItems = [] if category: subItems = [ MergeDicts(cItem, { 'url': menuUrl, 'title': _('All'), 'category': category }) ] for item in menuData: title = self.cleanHtmlStr(item) url = self.getFullUrl( self.cm.ph.getSearchGroups( item, '\\shref=[\'"]([^\'^"]+?)[\'"]')[0]) params = {'url': url, 'title': title} if category: params['category'] = category else: tmp = url.split('#', 1) if len(tmp) == 2: params.update({ 'category': 'list_episodes_langs', 'url': tmp[0], 'f_action': tmp[1] }) else: params['category'] = 'list_items' subItems.append(MergeDicts(cItem, params)) if len(subItems): self.addDir( MergeDicts( cItem, { 'url': menuUrl, 'title': menuTitle, 'category': 'sub_items', 'sub_items': subItems })) MAIN_CAT_TAB = [{ 'category': 'search', 'title': _('Search'), 'search_item': True }, { 'category': 'search_history', 'title': _('Search history') }] self.listsTab(MAIN_CAT_TAB, cItem)
def exploreItem(self, cItem, nextCategory): printDBG('HDFull.exploreItem') self.cacheLinks = {} sts, data = self.getPage(cItem['url']) if not sts: return cUrl = self.getFullUrl(self.cm.meta['url']) self.setMainUrl(cUrl) desc = [] descObj = self.getArticleContent(cItem, data)[0] for item in descObj['other_info']['custom_items_list']: desc.append(item[1]) desc = ' | '.join(desc) + '[/br]' + descObj['text'] trailer = self.getFullUrl( self.cm.ph.getSearchGroups( data, 'var\\s+?trailer\\s*?=\\s*?[\'"]([^\'^"]+?)[\'"]', 1, True)[0], cUrl) if trailer: params = dict(cItem) params.update({ 'good_for_fav': False, 'title': '%s - %s' % (cItem['title'], _('trailer')), 'url': strwithmeta(trailer, {'Referer': cUrl}), 'desc': desc, 'prev_url': cUrl }) self.addVideo(params) linksTab = self._getLinks(cUrl, data) if len(linksTab): self.cacheLinks[cUrl] = linksTab params = dict(cItem) params.update({ 'good_for_fav': False, 'url': cUrl, 'desc': desc, 'prev_url': cUrl }) self.addVideo(params) else: data = self.cm.ph.getAllItemsBeetwenNodes( data, ('<div', '>', 'itemprop="season"'), ('</div', '>')) for item in data: url = self.getFullUrl( self.cm.ph.getSearchGroups(item, 'href=[\'"]([^"^\']+?)["\']', 1, True)[0]) icon = self.getFullIconUrl( self.cm.ph.getSearchGroups(item, 'src=[\'"]([^"^\']+?)["\']', 1, True)[0]) title = self.cleanHtmlStr(item) params = dict(cItem) params.update({ 'good_for_fav': True, 'category': nextCategory, 's_title': cItem['title'], 'title': title, 'url': url, 'icon': icon, 'prev_url': cUrl, 'desc': desc }) self.addDir(params)
def getArticleContent(self, cItem, data=None): printDBG('HDFull.getArticleContent [%s]' % cItem) retTab = [] url = cItem.get('prev_url', cItem['url']) if data == None: self.tryTologin() sts, data = self.getPage(url) if not sts: data = '' data = self.cm.ph.getDataBeetwenNodes( data, ('<div', '>', 'summary-title'), ('<div', '>', 'breakaway-wrapper'), False)[1] title = self.cleanHtmlStr(data[:data.find('</div')]) icon = self.cm.ph.getSearchGroups( data, '<img([^>]+?video\\-page\\-thumbnail[^>]+?)>')[0] icon = self.getFullIconUrl( self.cm.ph.getSearchGroups( icon, 'src=[\'"]([^"^\']+?\\.jpe?g(?:\\?[^\'^"]*?)?)[\'"]')[0]) tmp = self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'description'), ('</div', '>'), False)[1].split('<br', 1) desc = self.cleanHtmlStr(tmp[0]) itemsList = [] value = self.cm.ph.getSearchGroups(data, '<([^>]+?datePublished[^>]+?)>')[0] value = self.cleanHtmlStr( self.cm.ph.getSearchGroups(value, 'content=[\'"]([^"^\']+?)[\'"]')[0]) if value: itemsList.append((_('Published:'), value)) item = tmp[-1] tmp = self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'details'), ('</div', '>'), False)[1].split('</p>') tmp.append(item) for item in tmp: header = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<span', '</span>')[1]) if header == '': continue value = self._desc(item) if value == '': continue itemsList.append((header, value)) if title == '': title = cItem['title'] if icon == '': icon = cItem.get('icon', self.DEFAULT_ICON_URL) if desc == '': desc = cItem.get('desc', '') return [{ 'title': self.cleanHtmlStr(title), 'text': self.cleanHtmlStr(desc), 'images': [{ 'title': '', 'url': self.getFullUrl(icon) }], 'other_info': { 'custom_items_list': itemsList } }]
def listItems(self, cItem, nextCategory): printDBG("Casacinema.listItems") url = cItem['url'] page = cItem.get('page', 1) if page > 1: tmp = url.split('?') url = tmp[0] if not url.endswith('/'): url += '/' url += 'page/%s/' % (page) if len(tmp) == 2: url += '?' + tmp[1] sts, data = self.getPage(url) if not sts: return if 'page/{0}/'.format(page + 1) in data: nextPage = True else: nextPage = False if '?s=' in url: data = self.cm.ph.getAllItemsBeetwenNodes( data, ('<div', '>', 'film film-2'), ('<div', '</div>', 'class="descriere"')) else: if page == 1: tmp = self.cm.ph.getDataBeetwenMarkers( data, '<h1 class="page-title">', '</body>', withMarkers=False)[1] else: tmp = self.cm.ph.rgetDataBeetwenMarkers2( data, '</body>', '<h1 class="page-title">', withMarkers=False)[1] if tmp == '': tmp = data data = self.cm.ph.getAllItemsBeetwenMarkers( tmp, '<div class="mediaWrap', '</span>', withMarkers=True) for item in data: idx = item.find('</h2>') if idx > 0: item = item[:idx] url = self.cm.ph.getSearchGroups(item, '''href=['"]([^'^"]+?)['"]''')[0] if '/film-di-natale-streaming/' in url: continue if 'saghe/' in url: continue title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<div class="title-film', '</a>')[1]) if title.endswith('streaming'): title = title[:-9].strip() icon = self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0] desc = self.cleanHtmlStr(item.replace('</p>', '[/br]')) try: raiting = str( int(((float( self.cm.ph.getSearchGroups( item, '''data\-rateit\-value=['"]([^'^"]+?)['"]''') [0]) * 5) / 3) * 10) / 10.0) + '/5' desc = raiting + ' | ' + desc except Exception: pass params = { 'good_for_fav': True, 'category': nextCategory, 'title': title, 'url': self.getFullUrl(url), 'icon': self.getFullIconUrl(icon), 'desc': desc } self.addDir(params) if nextPage: params = dict(cItem) params.update({ 'good_for_fav': False, 'title': _('Next page'), 'page': page + 1 }) self.addMore(params)
class HDFilmeTV(CBaseHostClass): USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36' MAIN_URL = 'https://hdfilme.cx/' SEARCH_URL = MAIN_URL + 'movie-search' DEFAULT_ICON = "https://raw.githubusercontent.com/StoneOffStones/plugin.video.xstream/c88b2a6953febf6e46cf77f891d550a3c2ee5eea/resources/art/sites/hdfilme.png" #"http://hdfilme.tv/public/site/images/logo.png" MAIN_CAT_TAB = [{'icon':DEFAULT_ICON, 'category':'list_filters', 'filter':'genre', 'title': _('Movies'), 'url' : MAIN_URL + 'filme1'}, {'icon':DEFAULT_ICON, 'category':'list_filters', 'filter':'genre', 'title': _('Series'), 'url' : MAIN_URL + 'serien1'}, {'icon':DEFAULT_ICON, 'category':'list_filters', 'filter':'genre', 'title': _('Trailers'),'url' : MAIN_URL + 'trailer'}, {'icon':DEFAULT_ICON, 'category':'search', 'title': _('Search'), 'search_item':True}, {'icon':DEFAULT_ICON, 'category':'search_history', 'title': _('Search history')} ] def __init__(self): CBaseHostClass.__init__(self, {'history':' HDFilmeTV.cc', 'cookie':'hdfilmenet.cookie'}) self.defaultParams = {'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE} self.filtersCache = {'genre':[], 'country':[], 'sort':[]} self.seasonCache = {} self.cacheLinks = {} def c_int(self,n): if n.isdigit(): return int(n) else: return 0 def getFullUrl(self, url): return CBaseHostClass.getFullUrl(self, url) def getPage(self, baseUrl, params={}, post_data=None): if params == {}: params = self.defaultParams return self.cm.getPage(baseUrl, params, post_data) def getPageCF(self, baseUrl, params={}, post_data=None): if params == {}: params = self.defaultParams params['cloudflare_params'] = {'domain':'hdfilme.cx', 'cookie_file':self.COOKIE_FILE, 'User-Agent':self.USER_AGENT, 'full_url_handle':self.getFullUrl} return self.cm.getPageCFProtection(baseUrl, params, post_data) def getIconUrl(self, url): url = self.getFullUrl(url) if url == '': return '' cookieHeader = self.cm.getCookieHeader(self.COOKIE_FILE) return strwithmeta(url, {'Cookie':cookieHeader, 'User-Agent':self.USER_AGENT}) def getMovieDatainJS(self, data): printDBG("HDFilmeTV.getMovieDatainJs") # example: # var movieData = { # id : 13810, # name : "The Super", # url : "https://hdfilme.cx/the-super-13810-stream" # }; movieData={} code = self.cm.ph.getDataBeetwenMarkers(data, 'var movieData = {', '}', False)[1] printDBG("movie data code: -----------------") printDBG(code) printDBG("-----------------") movie_id = self.cm.ph.getSearchGroups(code, "id : ([0-9]+?),")[0] movie_name = self.cm.ph.getSearchGroups(code, '''name : ['"]([^'^"]+?)['"]''')[0] movie_url= self.cm.ph.getSearchGroups(code, '''url : ['"]([^'^"]+?)['"]''')[0] movieData = { 'id' : movie_id , 'name': movie_name, 'url': movie_url } printDBG(str(movieData)) return movieData def getTrailerUrlinJS(self, data, movieData): printDBG("HDFilmeTV.getTrailerUrlinJs") # function load_trailer() { # $( "#play-area-wrapper" ).load( "/movie/load-trailer/" + movieData.id + "/0?trailer=bEplMVBHYVRHNDJoNjFWRWNXMFNiNm1zc0NvbllFNG1XU3JYM2xPbWVCcHVGMHNBU3FPRzJlTGdCWTBqcjZ5bg==", function() { # $("html, body").animate({ scrollTop: $('#play-area-wrapper').offset().top }, 1000); # console.log( "Load was performed." ); # # }); # } trailerUrl='' code = self.cm.ph.getDataBeetwenMarkers(data, 'function load_trailer() {', '}', False)[1] printDBG("load_trailer code: -----------------") printDBG(code) printDBG("-----------------") trailerUrl = self.cm.ph.getSearchGroups(code, ".load\( \"(.*?)\",")[0] trailerUrl = self.getFullUrl(trailerUrl.replace("\" + movieData.id + \"", movieData['id'])) return trailerUrl def fillFiltersCache(self, cItem): printDBG("HDFilmeTV.fillFiltersCache") self.filtersCache = {'genre':[], 'country':[], 'sort':[]} params = MergeDicts(self.defaultParams, {'user-agent': self.USER_AGENT, 'referer': self.MAIN_URL, "accept-encoding" : "gzip", "accept" : "text/html"}) printDBG("^^^^^^^^^^^^^^^^^^^^^^^") printDBG(str(params)) sts, data = self.getPageCF(cItem['url'], params) if not sts: return for filter in [{'m':'name="category"', 'key':'genre'}, {'m':'name="country"', 'key':'country'}, {'m':'name="sort"', 'key':'sort'}]: filterData = [] filterData = ph.findall(data, '<select class="orderby" ' + filter['m'] + '>', '</select>') #printDBG("^^^^^^^^^^^^^^^^^^") #printDBG(filterData[0]) optionsData = [] optionsData = ph.findall(filterData[0] , ('<option', '>'), '</option>') #printDBG("^^^^^^^^^^^^^^^^^^") #printDBG(str(optionsData)) optionsData.sort() #printDBG(str(optionsData)) #printDBG("^^^^^^^^^^^^^^^^^^") #printDBG("^^^^^^^^^^^^^^^^^^") old_value="" for item in optionsData: title = self.cleanHtmlStr(item) value = self.cm.ph.getSearchGroups(item, '''value=['"]([^'^"]+?)['"]''')[0] if value == '': continue if value != old_value: old_value = value self.filtersCache[filter['key']].append({'title':title, filter['key']:value}) if len(self.filtersCache[filter['key']]) and filter['key'] != 'sort': self.filtersCache[filter['key']].insert(0, {'title':_('--All--'), filter['key']:''}) # add sort_type to sort filter orderLen = len(self.filtersCache['sort']) for idx in range(orderLen): item = deepcopy(self.filtersCache['sort'][idx]) # desc self.filtersCache['sort'][idx].update({'title':'\xe2\x86\x93 ' + self.filtersCache['sort'][idx]['title'], 'sort_type':'desc'}) # asc item.update({'title': '\xe2\x86\x91 ' + item['title'], 'sort_type':'asc'}) self.filtersCache['sort'].append(item) def listFilters(self, cItem, nextCategory, nextFilter): filter = cItem.get('filter', '') printDBG("HDFilmeTV.listFilters filter[%s] nextFilter[%s]" % (filter, nextFilter)) tab = self.filtersCache.get(filter, []) if len(tab) == 0: self.fillFiltersCache(cItem) tab = self.filtersCache.get(filter, []) params = dict(cItem) params['category'] = nextCategory params['filter'] = nextFilter self.listsTab(tab, params) def listItems(self, cItem, nextCategory): printDBG("HDFilmeTV.listItems") itemsPerPage = 50 page = cItem.get('page', 1) url = cItem['url'] params = MergeDicts(self.defaultParams, { 'header': {'User-Agent': self.USER_AGENT, "Accept-Encoding" : "gzip", "Accept" : "text/html", "content-length":"14", "content-type": "application/x-www-form-urlencoded; charset=UTF-8", "Origin" : self.MAIN_URL, "Referer": url, "x-requested-with":"XMLHttpRequest"}}) query={} if 'search_pattern' in cItem: query={'key':cItem['search_pattern'],'page': page} else: query={'page': page, 'category':cItem['genre'],'country': cItem['country'], 'sort': cItem['sort'], 'sort_type': cItem['sort_type']} url += "?" + urllib.urlencode(query) sts, data = self.getPageCF(url, params, post_data = {'load':'full-page'}) #printDBG(data) if not sts: return nextPage = self.cm.ph.getDataBeetwenMarkers(data, '<ul class="pagination', '</ul>', False)[1] if 'data-page="{0}"'.format(page+1) in nextPage: #printDBG("Next page found!") nextPage = True else: nextPage = False numOfItems = 0 data = self.cm.ph.getDataBeetwenMarkers(data, '<ul class="products row">', '</ul>')[1] data = ph.findall(data, '<li>', '</li>') #printDBG(str(data)) for item in data: # icon icon = self.cm.ph.getSearchGroups(item, '''data-src=['"]([^'^"]+?)['"]''')[0] if icon == '': icon = cItem['icon'] # url url = self.cm.ph.getSearchGroups(item, '''href=['"]([^'^"]+?)['"]''')[0] if url == '': continue #title title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<div class="title-product">', '</div>')[1] ) if title == '': title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<h3 ', '</h3>')[1] ) #desc desc = self.cleanHtmlStr(item) params = dict(cItem) params.update({'good_for_fav': True, 'category':nextCategory, 'title':title, 'url':self.getFullUrl(url), 'icon':self.getIconUrl(icon), 'desc':desc}) #printDBG("----> movie item ------> " + str(params)) self.addDir(params) numOfItems += 1 if nextPage or numOfItems >= itemsPerPage: params = dict(cItem) params.update({'good_for_fav': False, 'title':_('Next page'), 'page': (page+1)}) self.addMore(params) def exploreItem(self, cItem): printDBG("HDFilmeTV.exploreItem") params = MergeDicts(self.defaultParams, {'user-agent': self.USER_AGENT, 'referer': self.MAIN_URL, "accept-encoding" : "gzip", "accept" : "text/html"}) sts, data = self.getPageCF(cItem['url'], params) #printDBG(data) if not sts: return movieId = self.cm.ph.getSearchGroups(data, '''data-movie-id=['"]([^'^"]+?)['"]''')[0] printDBG("movieId ------->" + movieId) trailerUrl = '' linksPageUrl = '' links = re.findall('''<a[^>]*?class="btn btn-xemnow pull-right"[^>]*?href=['"]([^'^"]+?)['"][^>]*?>(.*?)</a>''', data, re.S) for l in links: if 'Trailer' in l[1]: trailerUrl = l[0] elif 'STREAM' in l[1]: linksPageUrl = l[0] # trailer section if trailerUrl: if trailerUrl == "javascript:": # find url in javascript code printDBG("HDFilmeTV.exploreItem. Find trailer url in javascript code") movieData = self.getMovieDatainJS(data) if 'id' in movieData: trailerUrl = self.getTrailerUrlinJS(data, movieData) printDBG("trailerUrl: \"%s\" " % trailerUrl) params['referer'] = movieData['url'] sts, trailer_data = self.getPageCF(trailerUrl, params) if not sts: return #printDBG(data) # find url in iframe #<iframe class="film-screen-content" width="100%" height="100%" frameborder="0" allowfullscreen="" allow="autoplay" src="https://www.youtube.com/embed/JH0WldpM8Hw?autohide=1&fs=1&modestbranding=1&iv_load_policy=3&rel=0&showinfo=0&version=2&hd=0&fs=0&enablejsapi=1&playerapiid=ytplayer&autoplay=1&loop=1"></iframe> tmp = self.cm.ph.getDataBeetwenMarkers(trailer_data, '<iframe', '</iframe>')[1] trailerUrl = self.cm.ph.getSearchGroups(tmp, '''src=['"]([^'^"]+?)['"]''')[0] params = dict(cItem) params.update({'good_for_fav': False, 'title':'%s [%s]' % (cItem['title'], _('Trailer')), 'urls':[{'name':'trailer', 'url': strwithmeta(trailerUrl.replace('&', '&'), {'trailer': 1}), 'need_resolve':1}]}) self.addVideo(params) else: trailerUrl = self.getFullUrl(trailerUrl) params = dict(cItem) params.update({'good_for_fav': False, 'title':'%s [%s]' % (cItem['title'], _('Trailer')), 'urls':[{'name':'trailer', 'url' : strwithmeta(trailerUrl.replace('&', '&'), {'trailer': 1}), 'need_resolve':1}]}) self.addVideo(params) # find links page url # example #<a title="The Ranch staffel 4 Stream" class="btn btn-xemnow pull-right" style="margin-left:5px" href="https://hdfilme.cx/the-ranch-staffel-4-13803-stream/folge-1"> printDBG("HDFilmeTV.exploreItem. Find url of page with links - often url + '/deutsch' ") sts, linkspage_data = self.getPageCF(linksPageUrl, params) if not sts: return #printDBG(data) #printDBG(">>>>>>>>>>>>>>>>>>>>>>>>") episodesTab = [] episodesLinks = {} data=[] parts = self.cm.ph.getAllItemsBeetwenMarkers(linkspage_data, '<section class="box">', '</section>') for part in parts: data_part = self.cm.ph.getAllItemsBeetwenMarkers(part, '<i class="fa fa-chevron-right">', '</ul>') #'<ul class="list-inline list-film"' if data_part: data.extend(data_part) for server in data: serverName = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(server, '<i ', '</div>')[1] ) serverData = ph.findall(server, '<li>', '</li>') for link in serverData: #printDBG("----->" + link) episodeName = self.cleanHtmlStr( link ) episodeUrl = self.getFullUrl( self.cm.ph.getSearchGroups(link, '''href=['"]([^'^"]+?)['"]''')[0] ) episodeId = self.cm.ph.getSearchGroups(link, '''data-episode-id=['"]([^'^"]+?)['"]''')[0] if not episodeUrl.startswith('http'): continue if episodeName not in episodesTab: episodesTab.append(episodeName) episodesLinks[episodeName] = [] params={'name':serverName, 'url': strwithmeta(episodeUrl.replace('&', '&'), {'episodeId':episodeId, 'movieId': movieId}) , 'need_resolve':1} #printDBG("------------->" + str(params)) episodesLinks[episodeName].append(params) baseTitleReObj = re.compile('''staffel\s*[0-9]+?$''', flags=re.IGNORECASE) baseTitle = cItem['title'] season = self.cm.ph.getSearchGroups(cItem['url'], '''staf[f]+?el-([0-9]+?)-''')[0] if season == '': season = self.cm.ph.getSearchGroups(baseTitle, '''staffel\s*([0-9]+?)$''', ignoreCase=True)[0] if season != '': baseTitle = baseTitleReObj.sub('', baseTitle, 1).strip() try: episodesTab.sort(key=lambda item: self.c_int(item)) except Exception: printExc() for episode in episodesTab: title = baseTitle if season != '': title += ': ' + 's%se%s'% (season.zfill(2), episode.zfill(2)) elif len(episodesTab) > 1: title += ': ' + 'e%s'% (episode.zfill(2)) params = dict(cItem) params.update({'good_for_fav': False, 'title':title, 'urls': episodesLinks[episode]}) self.addVideo(params) def getLinksForVideo(self, cItem): printDBG("HDFilmeTV.getLinksForVideo [%s]" % cItem) return cItem.get('urls', []) def getVideoLinks(self, videoUrl): printDBG("HDFilmeTV.getVideoLinks [%s]" % videoUrl) urlTab = [] if isinstance(videoUrl, strwithmeta): if 'trailer' in videoUrl.meta: printDBG("--------> Trailer Url: %s" % videoUrl) return self.up.getVideoLinkExt(videoUrl) if 'episodeId' in videoUrl.meta: episode_id = videoUrl.meta['episodeId'] if 'movieId' in videoUrl.meta: movie_id = videoUrl.meta['movieId'] else: movie_id = '' params = MergeDicts(self.defaultParams, {'user-agent': self.USER_AGENT, 'referer': videoUrl, "accept-encoding" : "gzip", "accept" : "text/html"}) sts, data = self.getPageCF(videoUrl, params) printDBG(data) if not sts: return [] url = self.cm.ph.getDataBeetwenMarkers(data, '$( "#play-area-wrapper" ).load( "', '"', False)[1] if len(url) > 1: if movie_id == '': url=self.getFullUrl(url + episode_id + "?") else: url=self.getFullUrl(url + movie_id + '/' + episode_id + "?") printDBG("video link---->" + url) sts, tmp = self.getPage( url, params) #printDBG (tmp) #printDBG ("+++++++++++++++++") if sts: url = self.cm.ph.getDataBeetwenMarkers(tmp, 'window.urlVideo = "', '"', False)[1] url = strwithmeta(url, {'Accept':'*/*', 'Referer': self.getMainUrl(), 'Origin': self.getMainUrl()[:-1], 'User-Agent': self.USER_AGENT}) url.meta['iptv_m3u8_seg_download_retry'] = 10 urlTab.extend(getDirectM3U8Playlist(url, checkExt=False, checkContent=True, sortWithMaxBitrate=999999999)) printDBG ("------->" + url) ''' url = strwithmeta(url, {'Accept':'*/*', 'Referer':self.getMainUrl(), 'Origin':self.getMainUrl()[:-1], 'User-Agent':self.defaultParams['header']['User-Agent']}) printDBG(">> TYPE: " + type) if 'mp4' in type or 'flv' in type: urlTab.append({'name':str(item['label']), 'url':url}) elif 'hls' in type or 'm3u8' in type: url.meta['iptv_m3u8_seg_download_retry'] = 10 urlTab.extend(getDirectM3U8Playlist(url, checkExt=False, checkContent=True, sortWithMaxBitrate=999999999)) if len(urlTab): return urlTab ''' return urlTab def getFavouriteData(self, cItem): printDBG('HDFilmeTV.getFavouriteData') return json.dumps(cItem) def getLinksForFavourite(self, fav_data): printDBG('HDFilmeTV.getLinksForFavourite') links = [] try: cItem = byteify(json.loads(fav_data)) links = self.getLinksForVideo(cItem) except Exception: printExc() return links def setInitListFromFavouriteItem(self, fav_data): printDBG('HDFilmeTV.setInitListFromFavouriteItem') try: params = byteify(json.loads(fav_data)) except Exception: params = {} printExc() self.addDir(params) return True def listSearchResult(self, cItem, searchPattern, searchType): printDBG("HDFilmeTV.listSearchResult cItem[%s], searchPattern[%s] searchType[%s]" % (cItem, searchPattern, searchType)) cItem = dict(cItem) cItem['search_pattern'] = urllib.quote(searchPattern) cItem['url'] = self.SEARCH_URL self.listItems(cItem, 'explore_item') def getArticleContent(self, cItem): printDBG("HDFilmeTV.getArticleContent [%s]" % cItem) retTab = [] sts, data = self.getPage(cItem['url'], self.defaultParams) if not sts: return retTab data = self.cm.ph.getDataBeetwenMarkers(data, '<div id="main">', '<div class="row">')[1] icon = self.getFullUrl(self.cm.ph.getSearchGroups(data, '''src=['"]([^'^"]+?)['"]''')[0]) if icon == '': icon = cItem.get('icon', '') title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(data, '<b class="text-blue title-film">', '</b>', False)[1] ) if title == '': title = cItem['title'] desc = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(data, '<div class="caption">', '</div>', False)[1] ) descData = self.cm.ph.getDataBeetwenMarkers(data, '<div class="movie-info pull-left">', '</div>', False)[1] descData = self.cm.ph.getAllItemsBeetwenMarkers(descData, '<p', '</p>', caseSensitive=False) descTabMap = {"Genre": "genre", "IMDB": "rating", "Bewertung": "rated", "Veröffentlichungsjahr": "year", "Regisseur": "director", "Schauspieler": "actors", "Staat": "country", "Zeit": "duration", } otherInfo = {} for item in descData: item = item.split('</span>') if len(item) < 2: continue key = self.cleanHtmlStr( item[0] ).replace(':', '').strip() val = self.cleanHtmlStr( item[1] ) for dKey in descTabMap: if dKey in key: if descTabMap[dKey] == 'rating': val += ' IMDB' otherInfo[descTabMap[dKey]] = val break views = self.cm.ph.getSearchGroups(data, '''Aufrufe[^>]*?([0-9]+?)[^0-9]''')[0] if views != '': otherInfo['views'] = views return [{'title':self.cleanHtmlStr( title ), 'text': desc, 'images':[{'title':'', 'url':self.getIconUrl(icon)}], 'other_info':otherInfo}] def handleService(self, index, refresh = 0, searchPattern = '', searchType = ''): printDBG('handleService start') CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') mode = self.currItem.get("mode", '') filter = self.currItem.get("filter", '') printDBG( "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] " % (name, category) ) self.currList = [] #MAIN MENU if name == None: self.listsTab(self.MAIN_CAT_TAB, {'name':'category'}) elif category == 'list_filters': if filter == 'genre': nextFilter = 'country' nextCategory = 'list_filters' elif filter == 'country': nextFilter = 'sort' nextCategory = 'list_filters' else: nextFilter = '' nextCategory = 'list_items' self.listFilters(self.currItem, nextCategory, nextFilter) elif category == 'list_items': self.listItems(self.currItem, 'explore_item') elif category == 'explore_item': self.exploreItem(self.currItem) #SEARCH elif category in ["search", "search_next_page"]: cItem = dict(self.currItem) cItem.update({'search_item':False, 'name':'category'}) self.listSearchResult(cItem, searchPattern, searchType) #HISTORIA SEARCH elif category == "search_history": self.listsHistory({'name':'history', 'category': 'search'}, 'desc', _("Type: ")) else: printExc() CBaseHostClass.endHandleService(self, index, refresh)
def listCategory(self, cItem, searchMode=False): printDBG("Youtube.listCategory cItem[%s]" % cItem) sortList = True filespath = config.plugins.iptvplayer.Sciezkaurllist.value groupList = True if 'sub_file_category' not in cItem: self.currFileHost = IPTVFileHost() self.currFileHost.addFile(filespath + self.UTLIST_FILE, encoding='utf-8') tmpList = self.currFileHost.getGroups(sortList) if 0 < len(tmpList): params = dict(cItem) params.update({ 'sub_file_category': 'all', 'group': 'all', 'title': _("--All--") }) self.addDir(params) for item in tmpList: if '' == item: title = _("--Other--") else: title = item params = dict(cItem) params.update({ 'sub_file_category': 'group', 'title': title, 'group': item }) self.addDir(params) else: if 'all' == cItem['sub_file_category']: tmpList = self.currFileHost.getAllItems(sortList) for item in tmpList: params = dict(cItem) category = self._getCategory(item['url']) params.update({ 'good_for_fav': True, 'title': item['full_title'], 'url': item['url'], 'desc': item['url'], 'category': category }) if 'video' == category: self.addVideo(params) else: self.addDir(params) elif 'group' == cItem['sub_file_category']: tmpList = self.currFileHost.getItemsInGroup( cItem['group'], sortList) for item in tmpList: if '' == item['title_in_group']: title = item['full_title'] else: title = item['title_in_group'] params = dict(cItem) category = self._getCategory(item['url']) params.update({ 'good_for_fav': True, 'title': title, 'url': item['url'], 'desc': item['url'], 'category': category }) if 'video' == category: self.addVideo(params) else: self.addDir(params)
from Plugins.Extensions.IPTVPlayer.components.iptvplayerinit import TranslateTXT as _ from Plugins.Extensions.IPTVPlayer.components.ihost import CHostBase, CBaseHostClass from Plugins.Extensions.IPTVPlayer.components.recaptcha_v2helper import CaptchaHelper from Plugins.Extensions.IPTVPlayer.tools.e2ijs import js_execute_ext, is_js_cached from Plugins.Extensions.IPTVPlayer.tools.iptvtools import printDBG, printExc, MergeDicts, rm, GetCookieDir, ReadTextFile, WriteTextFile from Plugins.Extensions.IPTVPlayer.tools.iptvtypes import strwithmeta from Plugins.Extensions.IPTVPlayer.libs.pCommon import common from Plugins.Extensions.IPTVPlayer.libs.e2ijson import loads as json_loads from binascii import hexlify from hashlib import md5 import time import re from Components.config import config, ConfigText, ConfigSelection, getConfigListEntry from Screens.MessageBox import MessageBox config.plugins.iptvplayer.hdfull_language = ConfigSelection( default='es', choices=[('es', _('Spanish')), ('en', _('English'))]) config.plugins.iptvplayer.hdfull_login = ConfigText(default='', fixed_size=False) config.plugins.iptvplayer.hdfull_password = ConfigText(default='', fixed_size=False) def GetConfigList(): optionList = [] optionList.append( getConfigListEntry(_('Language'), config.plugins.iptvplayer.hdfull_language)) optionList.append( getConfigListEntry(_('login'), config.plugins.iptvplayer.hdfull_login)) optionList.append( getConfigListEntry(_('password'),
class StreamLiveTo(CBaseHostClass): HTTP_HEADER = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0', 'Accept': 'text/html' } HTTP_MOBILE_HEADER = { 'User-Agent': 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10', 'Accept': 'text/html' } MAIN_URL = 'https://www.streamlive.to/' MAIN_CAT_TAB = [{ 'category': 'list_filters', 'title': 'Live Channels', 'icon': '' }, { 'category': 'search', 'title': _('Search'), 'search_item': True }, { 'category': 'search_history', 'title': _('Search history') }] def __init__(self): CBaseHostClass.__init__(self, { 'history': 'StreamLiveTo.tv', 'cookie': 'streamliveto.cookie' }) self.defaultParams = { 'header': self.HTTP_HEADER, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE } self.cacheFilters = {} self.cacheFiltersKeys = [] self.DEFAULT_ICON_URL = self.MAIN_URL + 'images/logo.png' def _getFullUrl(self, url): if 0 < len(url): if url.startswith('//'): url = 'https:' + url elif not url.startswith('http'): url = self.MAIN_URL + url return url def getPage(self, url, params={}, post_data=None): return self.cm.getPage(url, params, post_data) return self.checkBotProtection(url, params) def cleanHtmlStr(self, data): data = data.replace(' ', ' ') data = data.replace(' ', ' ') return CBaseHostClass.cleanHtmlStr(data) def listsTab(self, tab, cItem, type='dir'): printDBG("StreamLiveTo.listsTab") for item in tab: params = dict(cItem) params.update(item) params['name'] = 'category' if type == 'dir': self.addDir(params) else: self.addVideo(params) def fillCacheFilters(self): printDBG("StreamLiveTo.fillCacheFilters") self.cacheFilters = {} self.cacheFiltersKeys = [] sts, data = self.getPage(self._getFullUrl('channels'), self.defaultParams) #sts, data = self.getPage(self.MAIN_URL, self.defaultParams) if not sts: return tmpTab = [] tmp = self.cm.ph.getDataBeetwenMarkers(data, '<select name="category"', '</select>', False)[1] tmp = re.compile( '<option [^>]*?value="([^"]*?)"[^>]*?>([^<]+?)</option>').findall( tmp) for item in tmp: tmpTab.append({'title': item[1], 'f_cat': urllib.quote(item[0])}) if len(tmpTab): self.cacheFilters['f_cat'] = tmpTab self.cacheFiltersKeys.append('f_cat') tmpTab = [] tmp = self.cm.ph.getDataBeetwenMarkers(data, '<select name="language"', '</select>', False)[1] tmp = re.compile( '<option [^>]*?value="([^"]*?)"[^>]*?>([^<]+?)</option>').findall( tmp) for item in tmp: tmpTab.append({'title': item[1], 'f_lang': item[0]}) if len(tmpTab): self.cacheFilters['f_lang'] = tmpTab self.cacheFiltersKeys.append('f_lang') tmpTab = [] tmp = self.cm.ph.getDataBeetwenMarkers(data, '<select name="sortBy"', '</select>', False)[1] tmp = re.compile( '<option [^>]*?value="([^"]*?)"[^>]*?>([^<]+?)</option>').findall( tmp) for item in tmp: tmpTab.append({'title': item[1], 'f_sort': item[0]}) if len(tmpTab): self.cacheFilters['f_sort'] = tmpTab self.cacheFiltersKeys.append('f_sort') sts, data = self.getPage(self._getFullUrl('channelsPages.php'), self.defaultParams) if not sts: return data = self.cm.ph.getDataBeetwenMarkers(data, '<h2', '</h2>')[1] data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<a', '</a>') tmpTab = [] for item in data: val = self.cm.ph.getSearchGroups( item, '''[\?&]list=([^'^"^&]+?)['"&]''')[0] title = self.cleanHtmlStr(item) tmpTab.append({'title': title, 'f_type': val}) if len(tmpTab) == 0: for item in [(_('Any'), ''), (_('Free'), 'free'), (_('Premium'), 'premium')]: tmpTab.append({'title': item[0], 'f_type': item[1]}) if len(tmpTab): self.cacheFilters['f_type'] = tmpTab self.cacheFiltersKeys.insert(0, 'f_type') def listFilters(self, cItem, nextCategory): printDBG("StreamLiveTo.listFilters") cItem = dict(cItem) f_idx = cItem.get('f_idx', 0) if f_idx == 0: self.fillCacheFilters() if f_idx >= len(self.cacheFiltersKeys): return filter = self.cacheFiltersKeys[f_idx] f_idx += 1 cItem['f_idx'] = f_idx if f_idx == len(self.cacheFiltersKeys): cItem['category'] = nextCategory self.listsTab(self.cacheFilters.get(filter, []), cItem) def listChannels(self, cItem): printDBG("StreamLiveTo.listChannels") page = cItem.get('page', 1) post_data = {'page': page} keysMap = { 'cat': 'category', 'lang': 'language', 'sort': 'sortBy', 'q': 'query', 'type': 'list' } if 'f_q' in cItem: keys = ['f_q'] else: keys = [] keys.extend(self.cacheFiltersKeys) for item in keys: if item not in cItem: continue key = keysMap.get(item[2:], item[2:]) post_data[key] = cItem[item] url = self.getFullUrl('channelsPages.php') sts, data = self.getPage(url, self.defaultParams, post_data) if not sts: return if 'data-page="{0}"'.format(page + 1) in data: nextPage = True else: nextPage = False data = self.cm.ph.rgetAllItemsBeetwenNodes( data.split('<nav>', 1)[0], ('</div', '>'), ('<div', '>', 'item')) for item in data: url = self._getFullUrl( self.cm.ph.getSearchGroups(item, 'href="([^"]+?)"')[0]) icon = self._getFullUrl( self.cm.ph.getSearchGroups(item, 'src="([^"]+?)"')[0]) title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<strong>', '</strong>', False)[1]) if '' == title: title = self.cleanHtmlStr( self.cm.ph.getSearchGroups(item, 'title="([^"]+?)"')[0]) if 'class="premium_only"' in item or 'Premium Only' in item: postfix = 'PREMIUM ONLY' elif 'glyphicon-king' in item: postfix = 'KING' else: postfix = '' if postfix != '': title += ' [%s]' % postfix desc = [] tmp = self.cm.ph.getAllItemsBeetwenNodes(item, ('<div', '>', '"jt'), ('</div', '>')) for t in tmp: if 'bottom' in t: continue t = self.cleanHtmlStr(t) if t != '': desc.append(t) desc = ' | '.join(desc) tmp = self.cm.ph.getAllItemsBeetwenNodes(item, ('<div', '>', 'block'), ('</div', '>'), False) for t in tmp: t = self.cleanHtmlStr(t) if t != '': desc += '[/br]' + t if self.cm.isValidUrl(url): params = { 'title': title, 'url': url, 'desc': desc, 'icon': icon } self.addVideo(params) if nextPage: params = dict(cItem) params.update({'title': _("Next page"), 'page': page + 1}) self.addDir(params) def listSearchResult(self, cItem, searchPattern, searchType): printDBG( "StreamLiveTo.listSearchResult cItem[%s], searchPattern[%s] searchType[%s]" % (cItem, searchPattern, searchType)) cItem = dict(cItem) cItem['f_q'] = urllib.quote(searchPattern) self.listChannels(cItem) def getLinksForVideo(self, cItem): printDBG("StreamLiveTo.getLinksForVideo [%s]" % cItem) urlTab = [] videoUrl = cItem['url'] if videoUrl.startswith('http'): ''' httpParams = dict(self.defaultParams) httpParams['header'] = dict(self.HTTP_HEADER) httpParams['header']['Referer'] = videoUrl _url_re = re.compile("http(s)?://(\w+\.)?(ilive.to|streamlive.to)/.*/(?P<channel>\d+)") channel = _url_re.match(videoUrl).group("channel") sts, data = self.getPage('http://www.streamlive.to/view/%s' % channel, httpParams) sts, data = self.getPage(videoUrl, self.defaultParams) if not sts: [] ''' while True: urlTab = self.up.getVideoLinkExt(videoUrl) for idx in range(len(urlTab)): urlTab[idx]['need_resolve'] = 0 if 0 == len( urlTab ) and 'get more FREE credits' in GetIPTVPlayerLastHostError( False): ret = -1 while ret == -1: ret = self.listGetFreeCredits() if ret == 1: continue break return urlTab def getFavouriteData(self, cItem): return cItem['url'] def getLinksForFavourite(self, fav_data): return self.getLinksForVideo({'url': fav_data}) def listGetFreeCredits(self): printDBG("StreamLiveTo.listGetFreeCredits") baseUrl = self._getFullUrl('get_free_credits') httpParams = dict(self.defaultParams) httpParams['header'] = dict(self.HTTP_HEADER) httpParams['header']['Referer'] = baseUrl sts, data = self.getPage(baseUrl, httpParams) if not sts: SetIPTVPlayerLastHostError(_('Fail to get "%s".') % baseUrl) return 0 sts, data = self.cm.ph.getDataBeetwenMarkers(data, '<form method="post">', '</form>') m1 = 'recaptcha_challenge_field' m2 = 'recaptcha_response_field' errMsg1 = _('Fail to get captcha data.') if sts: captchaUrl = self.cm.ph.getSearchGroups( data, '''['"](http[^"']+?recaptcha/api[^"']*?)["']''')[0] if not sts or '' == captchaUrl or m1 not in data or m2 not in data: SetIPTVPlayerLastHostError(errMsg1) return 0 sts, data = self.getPage(captchaUrl, httpParams) if not sts: SetIPTVPlayerLastHostError(_('Fail to get "%s".') % captchaUrl) return 0 challenge = self.cm.ph.getSearchGroups( data, '''challenge\s*:\s*['"]([^'^"]+?)['"]''')[0] lang = self.cm.ph.getSearchGroups( data, '''lang\s*:\s*['"]([^'^"]+?)['"]''')[0] server = self.cm.ph.getSearchGroups( data, '''server\s*:\s*['"]([^'^"]+?)['"]''')[0] site = self.cm.ph.getSearchGroups( data, '''site\s*:\s*['"]([^'^"]+?)['"]''')[0] if '' == challenge or '' == lang or '' == server or '' == site: SetIPTVPlayerLastHostError(errMsg1) return 0 captchaUrl = server + 'reload?c=%s&k=%s&reason=i&type=image&lang=%s&th=' % ( challenge, site, lang) sts, data = self.getPage(captchaUrl, httpParams) if not sts: SetIPTVPlayerLastHostError(_('Fail to get "%s".') % captchaUrl) return 0 sts, challenge = self.cm.ph.getDataBeetwenMarkers( data, "finish_reload('", "'", False) if not sts: SetIPTVPlayerLastHostError(errMsg1) return 0 imgUrl = 'http://www.google.com/recaptcha/api/image?c=' + challenge #return params = { 'maintype': 'image', 'subtypes': ['jpeg'], 'check_first_bytes': ['\xFF\xD8', '\xFF\xD9'] } filePath = GetTmpDir('.iptvplayer_captcha.jpg') ret = self.cm.saveWebFile(filePath, imgUrl, params) if not ret.get('sts'): SetIPTVPlayerLastHostError(_('Fail to get "%s".') % imgUrl) return 0 from copy import deepcopy params = deepcopy(IPTVMultipleInputBox.DEF_PARAMS) params['accep_label'] = _('Send') params['title'] = _('Answer') params['list'] = [] item = deepcopy(IPTVMultipleInputBox.DEF_INPUT_PARAMS) item['label_size'] = (300, 57) item['input_size'] = (300, 25) item['icon_path'] = filePath item['input']['text'] = '' params['list'].append(item) ret = 0 retArg = self.sessionEx.waitForFinishOpen(IPTVMultipleInputBox, params) printDBG(retArg) if retArg and len(retArg) and retArg[0]: printDBG(retArg[0]) sts, data = self.cm.getPage( baseUrl, httpParams, { 'recaptcha_challenge_field': challenge, 'recaptcha_response_field': retArg[0], 'submit': 'Get Free 10 Credits' }) printDBG(data) if 'got free' in data: ret = 1 elif 'incorrect' in data: ret = -1 if sts: msg = self.cm.ph.getDataBeetwenMarkers(data, '<div style="color:', '</div>')[1] SetIPTVPlayerLastHostError(self.cleanHtmlStr(msg)) else: SetIPTVPlayerLastHostError(_('Fail to get "%s".') % baseUrl) else: SetIPTVPlayerLastHostError(_('Wrong answer.')) return ret def checkBotProtection(self, url, httpParams): printDBG("StreamLiveTo.checkBotProtection") captchaMarker = 'name="captcha"' sts, data = self.cm.getPage(url, httpParams) if not sts: return False, None if captchaMarker not in data: return True, data data = self.cm.ph.getDataBeetwenReMarkers(data, re.compile('<form [^>]+?>'), re.compile('</form>'), True)[1] title = self.cm.ph.getDataBeetwenMarkers(data, '<h1>', '</h1>')[1] question = self.cm.ph.getDataBeetwenReMarkers(data, re.compile('</h1>'), re.compile('</form>'), True)[1] title = self.cleanHtmlStr(title) question = self.cleanHtmlStr(question) from copy import deepcopy params = deepcopy(IPTVMultipleInputBox.DEF_PARAMS) params['accep_label'] = _('Send') params['title'] = title params['list'] = [] item = deepcopy(IPTVMultipleInputBox.DEF_INPUT_PARAMS) item['label_size'] = (550, 50 + 25 * question.count('\n')) item['title'] = question item['input']['text'] = '' params['list'].append(item) retArg = self.sessionEx.waitForFinishOpen(IPTVMultipleInputBox, params) printDBG(retArg) if retArg and 1 == len(retArg) and retArg[0] and 1 == len(retArg[0]): answer = '%s' % retArg[0][0] newHttpParams = dict(httpParams) newHeader = dict(self.HTTP_HEADER) newHeader['Referer'] = url newHttpParams['header'] = newHttpParams sts, data = self.cm.getPage(url, newHttpParams, {'captcha': answer}) if not sts: return False, None resultMarker = 'Your answer is wrong.' if resultMarker in data: self.sessionEx.open(MessageBox, resultMarker, type=MessageBox.TYPE_ERROR, timeout=10) else: return True, data return False, None def doLogin(self, login, password): logged = False HTTP_HEADER = dict(self.HTTP_MOBILE_HEADER) HTTP_HEADER.update({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest' }) post_data = { 'username': login, 'password': password, 'accessed_by': 'web', 'submit': 'Login', 'x': 0, 'y': 0 } params = { 'header': HTTP_HEADER, 'cookiefile': self.COOKIE_FILE, 'save_cookie': True } loginUrl = 'https://www.streamlive.to/login.php' sts, data = self.cm.getPage(loginUrl, params, post_data) if sts and ('/logout"' in data or '/logout.php"' in data): logged = True return logged def handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') mode = self.currItem.get("mode", '') printDBG( "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] " % (name, category)) self.currList = [] #MAIN MENU if name == None: login = config.plugins.iptvplayer.streamliveto_login.value passwd = config.plugins.iptvplayer.streamliveto_password.value logged = False if '' != login.strip() and '' != passwd.strip(): logged = self.doLogin(login, passwd) if not logged: self.sessionEx.open(MessageBox, _('Login failed.'), type=MessageBox.TYPE_INFO, timeout=10) self.listsTab(self.MAIN_CAT_TAB, {'name': 'category'}) #if logged: # self.addDir({'name':'category', 'title':_('Get free credits'), 'category':'get_free_credits'}) elif category == 'get_free_credits': self.listGetFreeCredits() elif category == 'list_filters': self.listFilters(self.currItem, 'list_channels') elif category == 'list_channels': self.listChannels(self.currItem) #SEARCH elif category in ["search", "search_next_page"]: cItem = dict(self.currItem) cItem.update({'search_item': False, 'name': 'category'}) self.listSearchResult(cItem, searchPattern, searchType) #HISTORIA SEARCH elif category == "search_history": self.listsHistory({ 'name': 'history', 'category': 'search' }, 'desc', _("Type: ")) else: printExc() CBaseHostClass.endHandleService(self, index, refresh)
def exploreItem(self, cItem): printDBG("HDFilmeTV.exploreItem") params = MergeDicts(self.defaultParams, {'user-agent': self.USER_AGENT, 'referer': self.MAIN_URL, "accept-encoding" : "gzip", "accept" : "text/html"}) sts, data = self.getPageCF(cItem['url'], params) #printDBG(data) if not sts: return movieId = self.cm.ph.getSearchGroups(data, '''data-movie-id=['"]([^'^"]+?)['"]''')[0] printDBG("movieId ------->" + movieId) trailerUrl = '' linksPageUrl = '' links = re.findall('''<a[^>]*?class="btn btn-xemnow pull-right"[^>]*?href=['"]([^'^"]+?)['"][^>]*?>(.*?)</a>''', data, re.S) for l in links: if 'Trailer' in l[1]: trailerUrl = l[0] elif 'STREAM' in l[1]: linksPageUrl = l[0] # trailer section if trailerUrl: if trailerUrl == "javascript:": # find url in javascript code printDBG("HDFilmeTV.exploreItem. Find trailer url in javascript code") movieData = self.getMovieDatainJS(data) if 'id' in movieData: trailerUrl = self.getTrailerUrlinJS(data, movieData) printDBG("trailerUrl: \"%s\" " % trailerUrl) params['referer'] = movieData['url'] sts, trailer_data = self.getPageCF(trailerUrl, params) if not sts: return #printDBG(data) # find url in iframe #<iframe class="film-screen-content" width="100%" height="100%" frameborder="0" allowfullscreen="" allow="autoplay" src="https://www.youtube.com/embed/JH0WldpM8Hw?autohide=1&fs=1&modestbranding=1&iv_load_policy=3&rel=0&showinfo=0&version=2&hd=0&fs=0&enablejsapi=1&playerapiid=ytplayer&autoplay=1&loop=1"></iframe> tmp = self.cm.ph.getDataBeetwenMarkers(trailer_data, '<iframe', '</iframe>')[1] trailerUrl = self.cm.ph.getSearchGroups(tmp, '''src=['"]([^'^"]+?)['"]''')[0] params = dict(cItem) params.update({'good_for_fav': False, 'title':'%s [%s]' % (cItem['title'], _('Trailer')), 'urls':[{'name':'trailer', 'url': strwithmeta(trailerUrl.replace('&', '&'), {'trailer': 1}), 'need_resolve':1}]}) self.addVideo(params) else: trailerUrl = self.getFullUrl(trailerUrl) params = dict(cItem) params.update({'good_for_fav': False, 'title':'%s [%s]' % (cItem['title'], _('Trailer')), 'urls':[{'name':'trailer', 'url' : strwithmeta(trailerUrl.replace('&', '&'), {'trailer': 1}), 'need_resolve':1}]}) self.addVideo(params) # find links page url # example #<a title="The Ranch staffel 4 Stream" class="btn btn-xemnow pull-right" style="margin-left:5px" href="https://hdfilme.cx/the-ranch-staffel-4-13803-stream/folge-1"> printDBG("HDFilmeTV.exploreItem. Find url of page with links - often url + '/deutsch' ") sts, linkspage_data = self.getPageCF(linksPageUrl, params) if not sts: return #printDBG(data) #printDBG(">>>>>>>>>>>>>>>>>>>>>>>>") episodesTab = [] episodesLinks = {} data=[] parts = self.cm.ph.getAllItemsBeetwenMarkers(linkspage_data, '<section class="box">', '</section>') for part in parts: data_part = self.cm.ph.getAllItemsBeetwenMarkers(part, '<i class="fa fa-chevron-right">', '</ul>') #'<ul class="list-inline list-film"' if data_part: data.extend(data_part) for server in data: serverName = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(server, '<i ', '</div>')[1] ) serverData = ph.findall(server, '<li>', '</li>') for link in serverData: #printDBG("----->" + link) episodeName = self.cleanHtmlStr( link ) episodeUrl = self.getFullUrl( self.cm.ph.getSearchGroups(link, '''href=['"]([^'^"]+?)['"]''')[0] ) episodeId = self.cm.ph.getSearchGroups(link, '''data-episode-id=['"]([^'^"]+?)['"]''')[0] if not episodeUrl.startswith('http'): continue if episodeName not in episodesTab: episodesTab.append(episodeName) episodesLinks[episodeName] = [] params={'name':serverName, 'url': strwithmeta(episodeUrl.replace('&', '&'), {'episodeId':episodeId, 'movieId': movieId}) , 'need_resolve':1} #printDBG("------------->" + str(params)) episodesLinks[episodeName].append(params) baseTitleReObj = re.compile('''staffel\s*[0-9]+?$''', flags=re.IGNORECASE) baseTitle = cItem['title'] season = self.cm.ph.getSearchGroups(cItem['url'], '''staf[f]+?el-([0-9]+?)-''')[0] if season == '': season = self.cm.ph.getSearchGroups(baseTitle, '''staffel\s*([0-9]+?)$''', ignoreCase=True)[0] if season != '': baseTitle = baseTitleReObj.sub('', baseTitle, 1).strip() try: episodesTab.sort(key=lambda item: self.c_int(item)) except Exception: printExc() for episode in episodesTab: title = baseTitle if season != '': title += ': ' + 's%se%s'% (season.zfill(2), episode.zfill(2)) elif len(episodesTab) > 1: title += ': ' + 'e%s'% (episode.zfill(2)) params = dict(cItem) params.update({'good_for_fav': False, 'title':title, 'urls': episodesLinks[episode]}) self.addVideo(params)
def listGetFreeCredits(self): printDBG("StreamLiveTo.listGetFreeCredits") baseUrl = self._getFullUrl('get_free_credits') httpParams = dict(self.defaultParams) httpParams['header'] = dict(self.HTTP_HEADER) httpParams['header']['Referer'] = baseUrl sts, data = self.getPage(baseUrl, httpParams) if not sts: SetIPTVPlayerLastHostError(_('Fail to get "%s".') % baseUrl) return 0 sts, data = self.cm.ph.getDataBeetwenMarkers(data, '<form method="post">', '</form>') m1 = 'recaptcha_challenge_field' m2 = 'recaptcha_response_field' errMsg1 = _('Fail to get captcha data.') if sts: captchaUrl = self.cm.ph.getSearchGroups( data, '''['"](http[^"']+?recaptcha/api[^"']*?)["']''')[0] if not sts or '' == captchaUrl or m1 not in data or m2 not in data: SetIPTVPlayerLastHostError(errMsg1) return 0 sts, data = self.getPage(captchaUrl, httpParams) if not sts: SetIPTVPlayerLastHostError(_('Fail to get "%s".') % captchaUrl) return 0 challenge = self.cm.ph.getSearchGroups( data, '''challenge\s*:\s*['"]([^'^"]+?)['"]''')[0] lang = self.cm.ph.getSearchGroups( data, '''lang\s*:\s*['"]([^'^"]+?)['"]''')[0] server = self.cm.ph.getSearchGroups( data, '''server\s*:\s*['"]([^'^"]+?)['"]''')[0] site = self.cm.ph.getSearchGroups( data, '''site\s*:\s*['"]([^'^"]+?)['"]''')[0] if '' == challenge or '' == lang or '' == server or '' == site: SetIPTVPlayerLastHostError(errMsg1) return 0 captchaUrl = server + 'reload?c=%s&k=%s&reason=i&type=image&lang=%s&th=' % ( challenge, site, lang) sts, data = self.getPage(captchaUrl, httpParams) if not sts: SetIPTVPlayerLastHostError(_('Fail to get "%s".') % captchaUrl) return 0 sts, challenge = self.cm.ph.getDataBeetwenMarkers( data, "finish_reload('", "'", False) if not sts: SetIPTVPlayerLastHostError(errMsg1) return 0 imgUrl = 'http://www.google.com/recaptcha/api/image?c=' + challenge #return params = { 'maintype': 'image', 'subtypes': ['jpeg'], 'check_first_bytes': ['\xFF\xD8', '\xFF\xD9'] } filePath = GetTmpDir('.iptvplayer_captcha.jpg') ret = self.cm.saveWebFile(filePath, imgUrl, params) if not ret.get('sts'): SetIPTVPlayerLastHostError(_('Fail to get "%s".') % imgUrl) return 0 from copy import deepcopy params = deepcopy(IPTVMultipleInputBox.DEF_PARAMS) params['accep_label'] = _('Send') params['title'] = _('Answer') params['list'] = [] item = deepcopy(IPTVMultipleInputBox.DEF_INPUT_PARAMS) item['label_size'] = (300, 57) item['input_size'] = (300, 25) item['icon_path'] = filePath item['input']['text'] = '' params['list'].append(item) ret = 0 retArg = self.sessionEx.waitForFinishOpen(IPTVMultipleInputBox, params) printDBG(retArg) if retArg and len(retArg) and retArg[0]: printDBG(retArg[0]) sts, data = self.cm.getPage( baseUrl, httpParams, { 'recaptcha_challenge_field': challenge, 'recaptcha_response_field': retArg[0], 'submit': 'Get Free 10 Credits' }) printDBG(data) if 'got free' in data: ret = 1 elif 'incorrect' in data: ret = -1 if sts: msg = self.cm.ph.getDataBeetwenMarkers(data, '<div style="color:', '</div>')[1] SetIPTVPlayerLastHostError(self.cleanHtmlStr(msg)) else: SetIPTVPlayerLastHostError(_('Fail to get "%s".') % baseUrl) else: SetIPTVPlayerLastHostError(_('Wrong answer.')) return ret
def handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') filters = self.currItem.get("filters", {}) printDBG( "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] " % (name, category)) self.currList = [] #MAIN MENU cItem = self.currItem if name == None: self.listsTab(self.MAIN_CAT_TAB, {'name': 'category'}) elif category == 'filters': self.getFilters(self.currItem, 'list_filters') if 1 == len(self.currList): cItem = self.currList[0] self.currList = [] category = 'list_filters' if category == 'list_filters': self.listsTab( cItem.get('sub_items', []), { 'name': 'category', 'category': 'list_sort_by', 'icon': self.MAIN_ICON, 'base_url': cItem['base_url'] }) if 1 == len(self.currList): cItem = self.currList[0] self.currList = [] category = 'list_sort_by' if category == 'list_sort_by': cItem = dict(cItem) if 'shows' == cItem.get('mode', ''): cItem['category'] = 'list_show_items' else: cItem['category'] = 'list_videos' self.listsTab(self.SORT_BY_TAB, cItem) elif category == 'list_videos': self.listItems(self.currItem) elif category == 'shows': self.listShows(self.currItem, 'list_sort_by') elif category == 'list_show_items': self.listShowItems(self.currItem) elif category == 'platforms': self.listPlatforms(self.currItem, 'filters') elif category == 'list_episodes': self.listEpisodes(self.currItem) #SEARCH elif category in ["search", "search_next_page"]: cItem = dict(self.currItem) cItem.update({'search_item': False, 'name': 'category'}) self.listSearchResult(cItem, searchPattern, searchType) #HISTORIA SEARCH elif category == "search_history": self.listsHistory({ 'name': 'history', 'category': 'search' }, 'desc', _("Type: ")) else: printExc() CBaseHostClass.endHandleService(self, index, refresh)