Ejemplo n.º 1
0
    def listCategory(self, cItem, searchMode = False):
        printDBG('Urllist.listCategory cItem[%s]' % cItem)
        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in ['all',
         Urllist.URLLIST_BLOG,
         Urllist.URRLIST_STREAMS,
         Urllist.URRLIST_USER]:
            self.currFileHost = IPTVFileHost()
            if cItem['category'] in ['all', Urllist.URLLIST_BLOG]:
                self.currFileHost.addFile(filespath + Urllist.URLLIST_BLOG, encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding='utf-8')
            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item:
                        title = _('BOXTVMANIA')
                    else:
                        title = item
                    params = {'name': 'category',
                     'category': 'group',
                     'title': title,
                     'group': item}
                    self.addDir(params)

            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    desc = _('Hosting: %s, Boxtvmania.blog') % (self._getHostingName(item['url']))
                    if item['desc'] != '':
                        desc = item['desc']
                    params = {'title': item['full_title'],
                     'url': item['url'],
                     'desc': desc,
                     'icon': item['icon']}
                    self.addVideo(params)

        elif 'group' in cItem:
            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']
                desc = _('Hosting: %s, ColomboTeam') % (self._getHostingName(item['url']))
                if item.get('desc', '') != '':
                    desc = item['desc']
                params = {'title': title,
                 'url': item['url'],
                 'desc': desc,
                 'icon': item.get('icon', '')}
                self.addVideo(params)
Ejemplo n.º 2
0
 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)
                 elif 'more' == category:
                     self.addMore(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)
                 elif 'more' == category:
                     self.addMore(params)
                 else:
                     self.addDir(params)
Ejemplo n.º 3
0
 def listCategory(self, cItem, searchMode=False):
     printDBG("Urllist.listCategory cItem[%s]" % cItem)
     
     sortList = config.plugins.iptvplayer.sortuj.value
     filespath = config.plugins.iptvplayer.Sciezkaurllist.value
     groupList = config.plugins.iptvplayer.grupujurllist.value
     if cItem['category'] in ['all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS, Urllist.URRLIST_USER, Urllist.RAFALCOOL1_FILE]:
         self.currFileHost = IPTVFileHost()
         if cItem['category'] in ['all', Urllist.RAFALCOOL1_FILE] and config.plugins.iptvplayer.urllist_showrafalcool1.value:
             self.updateRafalcoolFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
             self.currFileHost.addFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
         
         if cItem['category'] in ['all', Urllist.URLLIST_FILE]: 
             self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE, encoding='utf-8')
         if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]: 
             self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding='utf-8')
         if cItem['category'] in ['all', Urllist.URRLIST_USER]:
             self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding='utf-8')
         
         if 'all' != cItem['category'] and groupList:
             tmpList = self.currFileHost.getGroups(sortList)
             for item in tmpList:
                 if '' == item: title = (_("Other"))
                 else:          title = item
                 params = {'name': 'category', 'category':'group', 'title':title, 'group':item}
                 self.addDir(params)
         else:
             tmpList = self.currFileHost.getAllItems(sortList)
             for item in tmpList:
                 desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                 if item['desc'] != '':
                     desc = item['desc']
                 params = {'title':item['full_title'], 'url':item['url'], 'desc':desc, 'icon':item['icon']}
                 self.addVideo(params)
     elif 'group' in cItem:
         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']
             desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
             if item.get('desc', '') != '':
                 desc = item['desc']
             params = {'title':title, 'url':item['url'], 'desc': desc, 'icon':item.get('icon', '')}
             self.addVideo(params)
Ejemplo n.º 4
0
 def listCategory(self, cItem, searchMode=False):
     printDBG("Urllist.listCategory cItem[%s]" % cItem)
     
     sortList = config.plugins.iptvplayer.sortuj.value
     filespath = config.plugins.iptvplayer.Sciezkaurllist.value
     groupList = config.plugins.iptvplayer.grupujurllist.value
     if cItem['category'] in ['all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS, Urllist.URRLIST_USER, Urllist.RAFALCOOL1_FILE]:
         self.currFileHost = IPTVFileHost()
         if cItem['category'] in ['all', Urllist.RAFALCOOL1_FILE] and config.plugins.iptvplayer.urllist_showrafalcool1.value:
             self.updateRafalcoolFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
             self.currFileHost.addFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
         
         if cItem['category'] in ['all', Urllist.URLLIST_FILE]: 
             self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE, encoding='utf-8')
         if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]: 
             self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding='utf-8')
         if cItem['category'] in ['all', Urllist.URRLIST_USER]:
             self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding='utf-8')
         
         if 'all' != cItem['category'] and groupList:
             tmpList = self.currFileHost.getGroups(sortList)
             for item in tmpList:
                 if '' == item: title = (_("Other"))
                 else:          title = item
                 params = {'name': 'category', 'category':'group', 'title':title, 'group':item}
                 self.addDir(params)
         else:
             tmpList = self.currFileHost.getAllItems(sortList)
             for item in tmpList:
                 desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                 if item['desc'] != '':
                     desc = item['desc']
                 params = {'title':item['full_title'], 'url':item['url'], 'desc':desc, 'icon':item['icon']}
                 self.addVideo(params)
     elif 'group' in cItem:
         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']
             desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
             if item.get('desc', '') != '':
                 desc = item['desc']
             params = {'title':title, 'url':item['url'], 'desc': desc, 'icon':item.get('icon', '')}
             self.addVideo(params)
Ejemplo n.º 5
0
    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)

        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem["category"] in ["all", Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS, Urllist.URRLIST_USER]:
            self.currFileHost = IPTVFileHost()
            if cItem["category"] in ["all", Urllist.URLLIST_FILE]:
                self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE, encoding="utf-8")
            if cItem["category"] in ["all", Urllist.URRLIST_STREAMS]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding="utf-8")
            if cItem["category"] in ["all", Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding="utf-8")

            if "all" != cItem["category"] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if "" == item:
                        title = _("Other")
                    else:
                        title = item
                    params = {"name": "category", "category": "group", "title": title, "group": item}
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    params = {
                        "title": item["full_title"],
                        "url": item["url"],
                        "desc": (_("Hosting: %s, %s")) % (self._getHostingName(item["url"]), item["url"]),
                    }
                    self.addVideo(params)
        elif "group" in cItem:
            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 = {
                    "title": title,
                    "url": item["url"],
                    "desc": (_("Hosting: %s, %s")) % (self._getHostingName(item["url"]), item["url"]),
                }
                self.addVideo(params)
Ejemplo n.º 6
0
 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 + Youtube.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({'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({'title':title, 'url':item['url'], 'desc': item['url'], 'category': category})
                 if 'video' == category:
                     self.addVideo(params)
                 else:
                     self.addDir(params)
Ejemplo n.º 7
0
 def listCategory(self, cItem, searchMode=False):
     printDBG("Urllist.listCategory cItem[%s]" % cItem)
     
     sortList = config.plugins.iptvplayer.sortuj.value
     filespath = config.plugins.iptvplayer.Sciezkaurllist.value
     groupList = config.plugins.iptvplayer.grupujurllist.value
     if cItem['category'] in ['all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS, Urllist.URRLIST_USER, Urllist.RAFALCOOL1_FILE]:
         self.currFileHost = IPTVFileHost()
         if cItem['category'] in ['all', Urllist.RAFALCOOL1_FILE] and config.plugins.iptvplayer.urllist_showrafalcool1.value:
             self.updateRafalcoolFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
             self.currFileHost.addFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
         
         if cItem['category'] in ['all', Urllist.URLLIST_FILE]: 
             self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE, encoding='utf-8')
         if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]: 
             self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding='utf-8')
         if cItem['category'] in ['all', Urllist.URRLIST_USER]:
             self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding='utf-8')
         
         if 'all' != cItem['category'] and groupList:
             tmpList = self.currFileHost.getGroups(sortList)
             for item in tmpList:
                 if '' == item: title = (_("Other"))
                 else:          title = item
                 params = {'name': 'category', 'category':'group', 'title':title, 'group':item}
                 self.addDir(params)
         else:
             tmpList = self.currFileHost.getAllItems(sortList)
             for item in tmpList:
                 desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                 if item['desc'] != '':
                     desc = item['desc']
                 params = {'title':item['full_title'], 'url':item['url'], 'desc':desc, 'icon':item['icon']}
                 self.addVideo(params)
     elif 'group' in cItem:
         tmpList = self.currFileHost.getItemsInGroup(cItem['group'], sortList)
         if 'j00zekFork' in globals():
             if iptvtools_FreeSpace(config.plugins.iptvplayer.SciezkaCache.value, 10):
                 downloadPath = config.plugins.iptvplayer.SciezkaCache.value
                 cacheTMDB = True
             else:
                 downloadPath = config.plugins.iptvplayer.NaszaTMP.value
                 cacheTMDB = False
         for item in tmpList:
             if '' == item['title_in_group']:
                 title = item['full_title']
             else:
                 title = item['title_in_group']
             if 'j00zekFork' in globals():
                 if item.get('desc', '') == '' and item.get('icon', '') == '' and config.plugins.iptvplayer.useTMDB.value == True:
                     desc, cover = downloadData(item['url'], title, config.plugins.iptvplayer.wgetpath.value, downloadPath, cacheTMDB )
                 else:
                     desc = item.get('desc', '')
                     cover = item.get('icon', '')
                 params = {'title':title, 'url':item['url'], 'desc': desc, 'icon':cover}
             else:
                 desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                 if item.get('desc', '') != '':
                     desc = item['desc']
                 params = {'title':title, 'url':item['url'], 'desc': desc, 'icon':item.get('icon', '')}
             self.addVideo(params)
Ejemplo n.º 8
0
class Urllist(CBaseHostClass):
    RAFALCOOL1_FILE  = 'urllist.rafalcool1'
    URLLIST_FILE     = 'urllist.txt'
    URRLIST_STREAMS  = 'urllist.stream'
    URRLIST_USER     = '******'
    
    def __init__(self):
        printDBG("Urllist.__init__")
        
        self.MAIN_GROUPED_TAB = [{'category': 'all', 'title': (_("All in one")), 'desc': (_("Links are videos and messages, without division into categories")), 'icon':'http://osvita.mediasapiens.ua/content/news/001000-002000/shyfrovanie_dannyh_1415.jpg'}]
        if config.plugins.iptvplayer.urllist_showrafalcool1.value:
            self.MAIN_GROUPED_TAB.append({'category': Urllist.RAFALCOOL1_FILE,  'title': (_("Recommended by Rafalcool1")), 'desc': (_("List of movies prepared by Rafalcool1")),                     'icon':'http://s1.bild.me/bilder/030315/3925071iconFilm.jpg'})        
        self.MAIN_GROUPED_TAB.extend( [{'category': Urllist.URLLIST_FILE,       'title': (_("Videos")),                    'desc': (_("Links to the video files from the file urllist.txt")),        'icon':'http://mohov.h15.ru/logotip_kino.jpg'}, \
                                       {'category': Urllist.URRLIST_STREAMS,    'title': (_("live transfers")),            'desc': (_("Live broadcasts from the file urllist.stream")),              'icon':'http://asiamh.ru.images.1c-bitrix-cdn.ru/images/media_logo.jpg?136879146733721'}, \
                                       {'category': Urllist.URRLIST_USER,       'title': (_("User files")),                'desc': (_("Favorite addresses are stored under the file urllist.user")), 'icon':'http://kinovesti.ru/uploads/posts/2014-12/1419918660_1404722920_02.jpg'}])
        CBaseHostClass.__init__(self)               
        self.currFileHost = None 
    
    def _cleanHtmlStr(self, str):
            str = self.cm.ph.replaceHtmlTags(str, ' ').replace('\n', ' ')
            return clean_html(self.cm.ph.removeDoubles(str, ' ').replace(' )', ')').strip())
            
    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 _uriIsValid(self, url):
        if '://' in url:
            return True
        return False
        
    def updateRafalcoolFile(self, filePath, encoding):
        printDBG("Urllist.updateRafalcoolFile filePath[%s]" % filePath)
        remoteVersion = -1
        localVersion = -1
        # get version from file
        try:
            with codecs.open(filePath, 'r', encoding, 'replace') as fp:
                # version should be in first line
                line = fp.readline()
                localVersion = int(self.cm.ph.getSearchGroups(line + '|', '#file_version=([0-9]+?)[^0-9]')[0])
        except:
            printExc()
        
        # generate timestamp to add to url to skip possible cacheing
        timestamp = str(time.time())
        
        # if we have loacal version get remote version for comparison
        if localVersion != '':
            sts, data = self.cm.getPage("http://hybrid.xunil.pl/IPTVPlayer_resources/UsersFiles/urllist.txt.version")
            if sts:
                try:
                    remoteVersion = int(data.strip())
                except:
                    printExc()
        # uaktualnij versje
        printDBG('Urllist.updateRafalcoolFile localVersion[%d] remoteVersion[%d]' % (localVersion, remoteVersion))
        if remoteVersion > -1 and localVersion < remoteVersion:
            sts, data = self.cm.getPage("http://hybrid.xunil.pl/IPTVPlayer_resources/UsersFiles/urllist.txt?t=" + timestamp)
            if sts:
                # confirm version
                line = data[0:data.find('\n')]
                try:
                    newVersion = int(self.cm.ph.getSearchGroups(line + '|', '#file_version=([0-9]+?)[^0-9]')[0])
                    if newVersion != remoteVersion:
                        printDBG("Version mismatches localVersion[%d], remoteVersion[%d], newVersion[%d]" % (localVersion, remoteVersion, newVersion) )
                    file = open(filePath, 'wb')
                    file.write(data)
                    file.close()
                except:
                    printExc()
        
    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)
        
        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in ['all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS, Urllist.URRLIST_USER, Urllist.RAFALCOOL1_FILE]:
            self.currFileHost = IPTVFileHost()
            if cItem['category'] in ['all', Urllist.RAFALCOOL1_FILE] and config.plugins.iptvplayer.urllist_showrafalcool1.value:
                self.updateRafalcoolFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
                self.currFileHost.addFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
            
            if cItem['category'] in ['all', Urllist.URLLIST_FILE]: 
                self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE, encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]: 
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding='utf-8')
            
            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item: title = (_("Other"))
                    else:          title = item
                    params = {'name': 'category', 'category':'group', 'title':title, 'group':item}
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                    if item['desc'] != '':
                        desc = item['desc']
                    params = {'title':item['full_title'], 'url':item['url'], 'desc':desc, 'icon':item['icon']}
                    self.addVideo(params)
        elif 'group' in cItem:
            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']
                desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                if item.get('desc', '') != '':
                    desc = item['desc']
                params = {'title':title, 'url':item['url'], 'desc': desc, 'icon':item.get('icon', '')}
                self.addVideo(params)
                
    def getLinksForVideo(self, cItem):
        printDBG("Urllist.getLinksForVideo url[%s]" % cItem['url'])
        videoUrls = []
        uri, params   = DMHelper.getDownloaderParamFromUrl(cItem['url'])
        printDBG(params)
        uri = urlparser.decorateUrl(uri, params)
        
        urlSupport = self.up.checkHostSupport( uri )
        if 1 == urlSupport:
            retTab = self.up.getVideoLinkExt( uri )
            videoUrls.extend(retTab)
        elif 0 == urlSupport and self._uriIsValid(uri):
            if uri.split('?')[0].endswith('.m3u8'):
                retTab = getDirectM3U8Playlist(uri)
                videoUrls.extend(retTab)
            elif uri.split('?')[0].endswith('.f4m'):
                retTab = getF4MLinksWithMeta(uri)
                videoUrls.extend(retTab)
            else:
                videoUrls.append({'name':'direct link', 'url':uri})
        return videoUrls
    
    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Urllist.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType)
        name     = self.currItem.get("name", None)
        category = self.currItem.get("category", '')
        printDBG( "Urllist.handleService: ---------> name[%s], category[%s] " % (name, category) )
        self.currList = []
        
        if None == name:
            self.listsTab(self.MAIN_GROUPED_TAB, self.currItem)
        else:
            self.listCategory(self.currItem)
        
        CBaseHostClass.endHandleService(self, index, refresh)
Ejemplo n.º 9
0
class Youtube(CBaseHostClass):
    UTLIST_FILE      = 'ytlist.txt'
    MAIN_GROUPED_TAB = [{'category': 'from_file',             'title': _("User links"),     'desc': _("User links stored in the ytlist.txt file.")}, \
                        {'category': 'Wyszukaj',              'title': _("Search"),         'desc': _("Search youtube materials "), 'search_item':True}, \
                        {'category': 'Historia wyszukiwania', 'title': _("Search history"), 'desc': _("History of searched phrases.")}]
    SEARCH_TYPES = [  (_("Video"),    "video"   ), 
                      (_("Channel"),  "channel" ),
                      (_("Playlist"), "playlist"),
                      (_("Movie"),    "movie"   ),
                      (_("Live"),     "live"    ) ]
                      #("Program",            "show"    ),
                      #("traylist",           "traylist"),
        
    def __init__(self):
        printDBG("Youtube.__init__")
        CBaseHostClass.__init__(self, {'history':'ytlist', 'cookie':'youtube.cookie'})            
        self.ytp = YouTubeParser()
        self.currFileHost = None
    
    def _cleanHtmlStr(self, str):
            str = self.cm.ph.replaceHtmlTags(str, ' ').replace('\n', ' ')
            return clean_html(self.cm.ph.removeDoubles(str, ' ').replace(' )', ')').strip())
            
    def _getCategory(self, url):
        printDBG("Youtube._getCategory")
        if '/playlist?list=' in url:
            category = 'playlist'
        elif None != re.search('/watch\?v=[^\&]+?\&list=',  url):
            category = 'traylist'
        elif 'user/' in url or 'channel/' in url:
            category = 'channel'
        else:
            category = 'video'
        return category
        
    def listsMainMenu(self):
        printDBG("Youtube.listsMainMenu")
        for item in Youtube.MAIN_GROUPED_TAB:
            params = {'name': 'category'}
            params.update(item)
            self.addDir(params)
        
    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 + Youtube.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({'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({'title':title, 'url':item['url'], 'desc': item['url'], 'category': category})
                    if 'video' == category:
                        self.addVideo(params)
                    else:
                        self.addDir(params)
                        
    def getVideos(self, cItem):
        printDBG('Youtube.getVideos cItem[%s]' % (cItem))
        
        category = cItem.get("category", '')
        url      = cItem.get("url", '')
        page     = cItem.get("page", '1')
                
        if "channel" == category:
            if -1 == url.find('browse_ajax'):
                if url.endswith('/videos'): 
                    url = url + '?flow=list&view=0&sort=dd'
                else:
                    url = url + '/videos?flow=list&view=0&sort=dd'
            self.currList = self.ytp.getVideosFromChannelList(url, category, page, cItem)
        elif "playlist" == category:
            self.currList = self.ytp.getVideosFromPlaylist(url, category, page, cItem)   
        elif "traylist" == category:
            self.currList = self.ytp.getVideosFromTraylist(url, category, page, cItem)
        else:
            printDBG('YTlist.getVideos Error unknown category[%s]' % category)
            
    def getSearchResult(self, cItem, pattern, searchType):
        page = self.currItem.get("page", '1')
        tmpList =  self.ytp.getSearchResult(pattern, searchType, page, 'Wyszukaj', config.plugins.iptvplayer.ytSortBy.value)
        for item in tmpList:
            item.update({'name':'category'})
            if 'video' == item['type']:
                self.addVideo(item)
            else:
                self.addDir(item)
                
    def getLinksForVideo(self, url):
        printDBG("Youtube.getLinksForVideo url[%s]" % url)
        ytformats = config.plugins.iptvplayer.ytformat.value
        maxRes    = int(config.plugins.iptvplayer.ytDefaultformat.value) * 1.1
        dash      = config.plugins.iptvplayer.ytShowDash.value

        if not url.startswith("http://") and not url.startswith("https://") :
            url = 'http://www.youtube.com/' + url
        tmpTab, dashTab = self.ytp.getDirectLinks(url, ytformats, dash, dashSepareteList = True)
        
        def __getLinkQuality( itemLink ):
            tab = itemLink['format'].split('x')
            return int(tab[0])
        tmpTab = CSelOneLink(tmpTab, __getLinkQuality, maxRes).getSortedLinks()
        if config.plugins.iptvplayer.ytUseDF.value and 0 < len(tmpTab):
            tmpTab = [tmpTab[0]]
        
        videoUrls = []
        for item in tmpTab:
            videoUrls.append({'name': item['format'] + ' | ' + item['ext'] , 'url':item['url']})
        for item in dashTab:
            videoUrls.append({'name': _("[dash] ") + item['format'] + ' | ' + item['ext'] , 'url':item['url']})
        return videoUrls
        
    def getFavouriteData(self, cItem):
        return cItem['url']
        
    def getLinksForFavourite(self, fav_data):
        return self.getLinksForVideo(fav_data)
    
    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Youtube.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType)
        name     = self.currItem.get("name", None)
        category = self.currItem.get("category", '')
        printDBG( "Youtube.handleService: ---------> name[%s], category[%s] " % (name, category) )
        self.currList = []
        
        if None == name:
            self.listsMainMenu()
        elif 'from_file' == category :
            self.listCategory(self.currItem)
        elif category in ["channel","playlist","movie","traylist"]:
            self.getVideos(self.currItem)
    #WYSZUKAJ
        elif category == 'Wyszukaj':
            pattern = urllib.quote_plus(searchPattern)
            printDBG("Wyszukaj pattern[%s], type[%s]" % (pattern, searchType))
            self.getSearchResult(self.currItem, pattern, searchType)
    #HISTORIA WYSZUKIWANIAmain_item
        elif category == 'Historia wyszukiwania':
            self.listsHistory()
Ejemplo n.º 10
0
class Youtube(CBaseHostClass):
    def __init__(self):
        printDBG("Youtube.__init__")
        CBaseHostClass.__init__(self, {
            'history': 'ytlist',
            'cookie': 'youtube.cookie'
        })
        self.UTLIST_FILE = 'ytlist.txt'
        self.DEFAULT_ICON_URL = 'https://www.vippng.com/png/full/85-853653_patreon-logo-png-transparent-background-youtube-logo.png'
        self.MAIN_GROUPED_TAB = [{
            'category':
            'from_file',
            'title':
            _("User links"),
            'desc':
            _("User links stored in the ytlist.txt file.")
        }, {
            'category': 'search',
            'title': _("Search"),
            'desc': _("Search youtube materials "),
            'search_item': True
        }, {
            'category': 'feeds',
            'title': _("Trending"),
            'desc': _("Browse youtube trending feeds")
        }, {
            'category': 'search_history',
            'title': _("Search history"),
            'desc': _("History of searched phrases.")
        }]

        self.SEARCH_TYPES = [
            (_("Video"), "video"),
            (_("Channel"), "channel"),
            (_("Playlist"), "playlist"),
            #(_("Movie"),    "movie"   ),
            (_("Live"), "live")
        ]
        #("Program",            "show"    ),
        #("traylist",           "traylist"),
        self.ytp = YouTubeParser()
        self.currFileHost = None

    def _getCategory(self, url):
        printDBG("Youtube._getCategory")
        if '/playlist?list=' in url:
            category = 'playlist'
        elif url.split('?')[0].endswith('/playlists'):
            category = 'playlists'
        elif None != re.search('/watch\?v=[^\&]+?\&list=', url):
            category = 'traylist'
        elif 'user/' in url or (('channel/' in url or '/c/' in url)
                                and not url.endswith('/live')):
            category = 'channel'
        else:
            category = 'video'
        return category

    def listMainMenu(self):
        printDBG("Youtube.listsMainMenu")
        for item in self.MAIN_GROUPED_TAB:
            params = {'name': 'category'}
            params.update(item)
            self.addDir(params)

    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)
                    elif 'more' == category:
                        self.addMore(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)
                    elif 'more' == category:
                        self.addMore(params)
                    else:
                        self.addDir(params)

    def listItems(self, cItem):
        printDBG('Youtube.listItems cItem[%s]' % (cItem))
        category = cItem.get("category", '')
        url = cItem.get("url", '')
        page = cItem.get("page", '1')

        if "playlists" == category:
            self.currList = self.ytp.getListPlaylistsItems(
                url, category, page, cItem)

        for idx in range(len(self.currList)):
            if self.currList[idx]['category'] in [
                    "channel", "playlist", "movie", "traylist"
            ]:
                self.currList[idx]['good_for_fav'] = True

    def listFeeds(self, cItem):
        printDBG('Youtube.listFeeds cItem[%s]' % (cItem))
        if cItem['category'] == "feeds_video":
            sts, data = self.cm.getPage(cItem['url'])
            data2 = self.cm.ph.getAllItemsBeetwenMarkers(
                data, "videoRenderer", "watchEndpoint")
            for item in data2:
                url = "https://www.youtube.com/watch?v=" + self.cm.ph.getDataBeetwenMarkers(
                    item, 'videoId":"', '","thumbnail":', False)[1]
                icon = self.cm.ph.getDataBeetwenMarkers(
                    item, '},{"url":"', '==', False)[1]
                title = self.cm.ph.getDataBeetwenMarkers(
                    item, '"title":{"runs":[{"text":"', '"}]', False)[1]
                desc = _("Channel") + ': ' + self.cm.ph.getDataBeetwenMarkers(
                    item, 'longBylineText":{"runs":[{"text":"',
                    '","navigationEndpoint"', False
                )[1] + "\n" + _(
                    "Release:"
                ) + ' ' + self.cm.ph.getDataBeetwenMarkers(
                    item, '"publishedTimeText":{"simpleText":"',
                    '"},"lengthText":', False
                )[1] + "\n" + _(
                    "Duration:"
                ) + ' ' + self.cm.ph.getDataBeetwenMarkers(
                    item,
                    '"lengthText":{"accessibility":{"accessibilityData":{"label":"',
                    '"}},"simpleText":',
                    False)[1] + "\n" + self.cm.ph.getDataBeetwenMarkers(
                        item, '"viewCountText":{"simpleText":"',
                        '"},"navigationEndpoint":', False)[1]
                params = {
                    'title': title,
                    'url': url,
                    'icon': icon,
                    'desc': desc
                }
                self.addVideo(params)
        else:
            title = _("Trending")
            url = "https://www.youtube.com/feed/trending"
            params = {'category': 'feeds_video', 'title': title, 'url': url}
            self.addDir(params)
            title = _("Music")
            url = "https://www.youtube.com/feed/trending?bp=4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
            params = {'category': 'feeds_video', 'title': title, 'url': url}
            self.addDir(params)
            title = _("Games")
            url = "https://www.youtube.com/feed/trending?bp=4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
            params = {'category': 'feeds_video', 'title': title, 'url': url}
            self.addDir(params)
            title = _("Movies")
            url = "https://www.youtube.com/feed/trending?bp=4gIKGgh0cmFpbGVycw%3D%3D"
            params = {'category': 'feeds_video', 'title': title, 'url': url}
            self.addDir(params)

    def getVideos(self, cItem):
        printDBG('Youtube.getVideos cItem[%s]' % (cItem))

        category = cItem.get("category", '')
        url = strwithmeta(cItem.get("url", ''))
        page = cItem.get("page", '1')

        if "channel" == category:
            if not ('browse' in url) and (not 'ctoken' in url):
                if url.endswith('/videos'):
                    url = url + '?flow=list&view=0&sort=dd'
                else:
                    url = url + '/videos?flow=list&view=0&sort=dd'
            self.currList = self.ytp.getVideosFromChannelList(
                url, category, page, cItem)
        elif "playlist" == category:
            self.currList = self.ytp.getVideosFromPlaylist(
                url, category, page, cItem)
        elif "traylist" == category:
            self.currList = self.ytp.getVideosFromTraylist(
                url, category, page, cItem)
        else:
            printDBG('YTlist.getVideos Error unknown category[%s]' % category)

    def listSearchResult(self, cItem, pattern, searchType):
        page = cItem.get("page", '1')
        url = cItem.get("url", "")

        if url:
            printDBG("URL ricerca -----------> %s" % url)
            tmpList = self.ytp.getSearchResult(
                urllib.quote_plus(pattern), searchType, page, 'search',
                config.plugins.iptvplayer.ytSortBy.value, url)
        else:
            tmpList = self.ytp.getSearchResult(
                urllib.quote_plus(pattern), searchType, page, 'search',
                config.plugins.iptvplayer.ytSortBy.value)

        for item in tmpList:
            item.update({'name': 'category'})
            if 'video' == item['type']:
                self.addVideo(item)
            elif 'more' == item['type']:
                self.addMore(item)
            else:
                if item['category'] in [
                        "channel", "playlist", "movie", "traylist"
                ]:
                    item['good_for_fav'] = True
                self.addDir(item)

    def getLinksForVideo(self, cItem):
        printDBG("Youtube.getLinksForVideo cItem[%s]" % cItem)
        urlTab = self.up.getVideoLinkExt(cItem['url'])
        if config.plugins.iptvplayer.ytUseDF.value and 0 < len(urlTab):
            return [urlTab[0]]
        return urlTab

    def getFavouriteData(self, cItem):
        printDBG('Youtube.getFavouriteData')
        return json.dumps(cItem)

    def getLinksForFavourite(self, fav_data):
        printDBG('Youtube.getLinksForFavourite')
        links = []
        try:
            cItem = byteify(json.loads(fav_data))
            links = self.getLinksForVideo(cItem)
        except Exception:
            printExc()
            return self.getLinksForVideo({'url': fav_data})
        return links

    def setInitListFromFavouriteItem(self, fav_data):
        printDBG('Youtube.setInitListFromFavouriteItem')
        try:
            params = byteify(json.loads(fav_data))
        except Exception:
            params = {}
            printExc()
        self.addDir(params)
        return True

    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Youtube.handleService start')

        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)

        name = self.currItem.get("name", '')
        category = self.currItem.get("category", '')
        printDBG("Youtube.handleService: ---------> name[%s], category[%s] " %
                 (name, category))
        self.currList = []

        if None == name:
            self.listMainMenu()
        elif 'from_file' == category:
            self.listCategory(self.currItem)
        elif category in ["channel", "playlist", "movie", "traylist"]:
            self.getVideos(self.currItem)
        elif category.startswith("feeds"):
            self.listFeeds(self.currItem)
        elif category == 'playlists':
            self.listItems(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 getSuggestionsProvider(self, index):
        printDBG('Youtube.getSuggestionsProvider')
        from Plugins.Extensions.IPTVPlayer.suggestions.google import SuggestionsProvider
        return SuggestionsProvider(True)
Ejemplo n.º 11
0
class Urllist(CBaseHostClass):
    RAFALCOOL1_FILE  = 'urllist.rafalcool1'
    URLLIST_FILE     = 'urllist.txt'
    URRLIST_STREAMS  = 'urllist.stream'
    URRLIST_USER     = '******'
    
    def __init__(self):
        printDBG("Urllist.__init__")
        
        self.MAIN_GROUPED_TAB = [{'category': 'all', 'title': (_("All in one")), 'desc': (_("Links are videos and messages, without division into categories")), 'icon':'http://osvita.mediasapiens.ua/content/news/001000-002000/shyfrovanie_dannyh_1415.jpg'}]
        if config.plugins.iptvplayer.urllist_showrafalcool1.value:
            self.MAIN_GROUPED_TAB.append({'category': Urllist.RAFALCOOL1_FILE,  'title': (_("Recommended by Rafalcool1")), 'desc': (_("List of movies prepared by Rafalcool1")),                     'icon':'http://s1.bild.me/bilder/030315/3925071iconFilm.jpg'})        
        self.MAIN_GROUPED_TAB.extend( [{'category': Urllist.URLLIST_FILE,       'title': (_("Videos")),                    'desc': (_("Links to the video files from the file urllist.txt")),        'icon':'http://mohov.h15.ru/logotip_kino.jpg'}, \
                                       {'category': Urllist.URRLIST_STREAMS,    'title': (_("live transfers")),            'desc': (_("Live broadcasts from the file urllist.stream")),              'icon':'http://asiamh.ru.images.1c-bitrix-cdn.ru/images/media_logo.jpg?136879146733721'}, \
                                       {'category': Urllist.URRLIST_USER,       'title': (_("User files")),                'desc': (_("Favorite addresses are stored under the file urllist.user")), 'icon':'http://kinovesti.ru/uploads/posts/2014-12/1419918660_1404722920_02.jpg'}])
        CBaseHostClass.__init__(self)               
        self.currFileHost = None 
    
    def _cleanHtmlStr(self, str):
            str = self.cm.ph.replaceHtmlTags(str, ' ').replace('\n', ' ')
            return clean_html(self.cm.ph.removeDoubles(str, ' ').replace(' )', ')').strip())
            
    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 _uriIsValid(self, url):
        if '://' in url:
            return True
        return False
        
    def updateRafalcoolFile(self, filePath, encoding):
        printDBG("Urllist.updateRafalcoolFile filePath[%s]" % filePath)
        remoteVersion = -1
        localVersion = -1
        # get version from file
        try:
            with codecs.open(filePath, 'r', encoding, 'replace') as fp:
                # version should be in first line
                line = fp.readline()
                localVersion = int(self.cm.ph.getSearchGroups(line + '|', '#file_version=([0-9]+?)[^0-9]')[0])
        except Exception:
            printExc()
        
        # generate timestamp to add to url to skip possible cacheing
        timestamp = str(time.time())
        
        # if we have loacal version get remote version for comparison
        if localVersion != '':
            sts, data = self.cm.getPage("http://hybrid.xunil.pl/IPTVPlayer_resources/UsersFiles/urllist.txt.version?t=" + timestamp)
            if sts:
                try:
                    remoteVersion = int(data.strip())
                except Exception:
                    printExc()
        # uaktualnij versje
        printDBG('Urllist.updateRafalcoolFile localVersion[%d] remoteVersion[%d]' % (localVersion, remoteVersion))
        if remoteVersion > -1 and localVersion < remoteVersion:
            sts, data = self.cm.getPage("http://hybrid.xunil.pl/IPTVPlayer_resources/UsersFiles/urllist.txt?t=" + timestamp)
            if sts:
                # confirm version
                line = data[0:data.find('\n')]
                try:
                    newVersion = int(self.cm.ph.getSearchGroups(line + '|', '#file_version=([0-9]+?)[^0-9]')[0])
                    if newVersion != remoteVersion:
                        printDBG("Version mismatches localVersion[%d], remoteVersion[%d], newVersion[%d]" % (localVersion, remoteVersion, newVersion) )
                    file = open(filePath, 'wb')
                    file.write(data)
                    file.close()
                except Exception:
                    printExc()
        
    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)
        
        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in ['all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS, Urllist.URRLIST_USER, Urllist.RAFALCOOL1_FILE]:
            self.currFileHost = IPTVFileHost()
            if cItem['category'] in ['all', Urllist.RAFALCOOL1_FILE] and config.plugins.iptvplayer.urllist_showrafalcool1.value:
                self.updateRafalcoolFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
                self.currFileHost.addFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
            
            if cItem['category'] in ['all', Urllist.URLLIST_FILE]: 
                self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE, encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]: 
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding='utf-8')
            
            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item: title = (_("Other"))
                    else:          title = item
                    params = {'name': 'category', 'category':'group', 'title':title, 'group':item}
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                    if item['desc'] != '':
                        desc = item['desc']
                    params = {'title':item['full_title'], 'url':item['url'], 'desc':desc, 'icon':item['icon']}
                    self.addVideo(params)
        elif 'group' in cItem:
            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']
                desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                if item.get('desc', '') != '':
                    desc = item['desc']
                params = {'title':title, 'url':item['url'], 'desc': desc, 'icon':item.get('icon', '')}
                self.addVideo(params)
                
    def getLinksForVideo(self, cItem):
        printDBG("Urllist.getLinksForVideo url[%s]" % cItem['url'])
        videoUrls = []
        uri, params   = DMHelper.getDownloaderParamFromUrl(cItem['url'])
        printDBG(params)
        uri = urlparser.decorateUrl(uri, params)
        uri = urlparser.decorateParamsFromUrl(uri)
        
        urlSupport = self.up.checkHostSupport( uri )
        if 1 == urlSupport:
            retTab = self.up.getVideoLinkExt( uri )
            videoUrls.extend(retTab)
        elif 0 == urlSupport and self._uriIsValid(uri):
            if uri.split('?')[0].endswith('.m3u8'):
                retTab = getDirectM3U8Playlist(uri)
                videoUrls.extend(retTab)
            elif uri.split('?')[0].endswith('.f4m'):
                retTab = getF4MLinksWithMeta(uri)
                videoUrls.extend(retTab)
            else:
                videoUrls.append({'name':'direct link', 'url':uri})
        return videoUrls
    
    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Urllist.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType)
        name     = self.currItem.get("name", None)
        category = self.currItem.get("category", '')
        printDBG( "Urllist.handleService: ---------> name[%s], category[%s] " % (name, category) )
        self.currList = []
        
        if None == name:
            self.listsTab(self.MAIN_GROUPED_TAB, self.currItem)
        else:
            self.listCategory(self.currItem)
        
        CBaseHostClass.endHandleService(self, index, refresh)
Ejemplo n.º 12
0
class Youtube(CBaseHostClass):
    def __init__(self):
        printDBG("Youtube.__init__")
        CBaseHostClass.__init__(self, {
            'history': 'ytlist',
            'cookie': 'youtube.cookie'
        })
        self.UTLIST_FILE = 'ytlist.txt'
        self.DEFAULT_ICON_URL = 'https://www.mm229.com/images/youtube-button-psd-450203.png'
        self.yeah = self.lenhistory()
        self.MAIN_GROUPED_TAB = [{
            'category':
            'from_file',
            'title':
            _('User links'),
            'desc':
            _('User links stored in the ytlist.txt file.')
        }, {
            'category': 'search',
            'title': _('Search'),
            'desc': _('Search youtube materials '),
            'search_item': True
        }, {
            'category': 'feeds',
            'title': _('Explore'),
            'desc': _('Popular trending videos')
        }, {
            'category': 'search_history',
            'title': _('Search history'),
            'desc': _('History of searched phrases.')
        }, {
            'category': 'delete_history',
            'title': _('Delete search history'),
            'desc': self.yeah
        }]

        self.SEARCH_TYPES = [
            (_("Video"), "video"),
            (_("Channel"), "channel"),
            (_("Playlist"), "playlist"),
            #(_("Movie"),    "movie"   ),
            (_("Live"), "live")
        ]
        #("Program",            "show"    ),
        #("traylist",           "traylist"),
        self.ytp = YouTubeParser()
        self.HTTP_HEADER = {
            'User-Agent':
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36',
            'X-YouTube-Client-Name': '1',
            'X-YouTube-Client-Version': '2.20211019.01.00',
            'X-Requested-With': 'XMLHttpRequest'
        }
        self.http_params = {'header': self.HTTP_HEADER, 'return_data': True}
        self.currFileHost = None

    def _getCategory(self, url):
        printDBG("Youtube._getCategory")
        if '/playlist?list=' in url:
            category = 'playlist'
        elif url.split('?')[0].endswith('/playlists'):
            category = 'playlists'
        elif None != re.search('/watch\?v=[^\&]+?\&list=', url):
            category = 'traylist'
        elif 'user/' in url or ('channel/' in url
                                and not url.endswith('/live')):
            category = 'channel'
        else:
            category = 'video'
        return category

    def listMainMenu(self):
        printDBG("Youtube.listsMainMenu")
        for item in self.MAIN_GROUPED_TAB:
            params = {'name': 'category'}
            params.update(item)
            self.addDir(params)

    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)
                    elif 'more' == category:
                        self.addMore(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)
                    elif 'more' == category:
                        self.addMore(params)
                    else:
                        self.addDir(params)

    def listItems(self, cItem):
        printDBG('Youtube.listItems cItem[%s]' % (cItem))
        category = cItem.get("category", '')
        url = strwithmeta(cItem.get("url", ''))
        page = cItem.get("page", '1')

        if "playlists" == category:
            self.currList = self.ytp.getListPlaylistsItems(
                url, category, page, cItem)

        for idx in range(len(self.currList)):
            if self.currList[idx]['category'] in [
                    "channel", "playlist", "movie", "traylist"
            ]:
                self.currList[idx]['good_for_fav'] = True

    def listFeeds(self, cItem):
        printDBG('Youtube.listFeeds cItem[%s]' % (cItem))
        if cItem['category'] == "feeds_video":
            sts, data = self.cm.getPage(cItem['url'], self.http_params)
            data2 = self.cm.ph.getAllItemsBeetwenMarkers(
                data, "videoRenderer", "watchEndpoint")
            for item in data2:
                url = "https://www.youtube.com/watch?v=" + self.cm.ph.getDataBeetwenMarkers(
                    item, 'videoId":"', '","thumbnail":', False)[1]
                icon = self.cm.ph.getDataBeetwenMarkers(
                    item, '},{"url":"', '==', False)[1]
                title = self.cm.ph.getDataBeetwenMarkers(
                    item, '"title":{"runs":[{"text":"', '"}]', False)[1]
                desc = "Készítette: " + self.cm.ph.getDataBeetwenMarkers(
                    item, 'longBylineText":{"runs":[{"text":"',
                    '","navigationEndpoint"', False
                )[1] + "\n" + "Megjelent " + self.cm.ph.getDataBeetwenMarkers(
                    item, '"publishedTimeText":{"simpleText":"',
                    '"},"lengthText":', False
                )[1] + "\n" + "Videó hossza: " + self.cm.ph.getDataBeetwenMarkers(
                    item,
                    '"lengthText":{"accessibility":{"accessibilityData":{"label":"',
                    '"}},"simpleText":',
                    False)[1] + "\n" + self.cm.ph.getDataBeetwenMarkers(
                        item, '"viewCountText":{"simpleText":"',
                        '"},"navigationEndpoint":', False)[1]
                params = {
                    'title': title,
                    'url': url,
                    'icon': icon,
                    'desc': desc
                }
                self.addVideo(params)
        else:
            title = "Trending videos"
            url = "https://www.youtube.com/feed/trending"
            params = {'category': 'feeds_video', 'title': title, 'url': url}
            self.addDir(params)
            title = "Music"
            url = "https://www.youtube.com/feed/trending?bp=4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
            params = {'category': 'feeds_video', 'title': title, 'url': url}
            self.addDir(params)
            title = "Gaming"
            url = "https://www.youtube.com/feed/trending?bp=4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
            params = {'category': 'feeds_video', 'title': title, 'url': url}
            self.addDir(params)
            title = "Films"
            url = "https://www.youtube.com/feed/trending?bp=4gIKGgh0cmFpbGVycw%3D%3D"
            params = {'category': 'feeds_video', 'title': title, 'url': url}
            self.addDir(params)

    def getVideos(self, cItem):
        printDBG('Youtube.getVideos cItem[%s]' % (cItem))

        category = cItem.get("category", '')
        url = cItem.get("url", '')
        page = cItem.get("page", '1')

        if "channel" == category:
            if not ('browse' in url) and (not 'ctoken' in url):
                if url.endswith('/videos'):
                    url = url + '?flow=list&view=0&sort=dd'
                else:
                    url = url + '/videos?flow=list&view=0&sort=dd'
            self.currList = self.ytp.getVideosFromChannelList(
                url, category, page, cItem)
        elif "playlist" == category:
            self.currList = self.ytp.getVideosFromPlaylist(
                url, category, page, cItem)
        elif "traylist" == category:
            self.currList = self.ytp.getVideosFromTraylist(
                url, category, page, cItem)
        else:
            printDBG('YTlist.getVideos Error unknown category[%s]' % category)

    def listSearchResult(self, cItem, pattern, searchType):
        page = cItem.get("page", '1')
        url = cItem.get("url", "")

        if url:
            printDBG("URL ricerca -----------> %s" % url)
            tmpList = self.ytp.getSearchResult(
                urllib.quote_plus(pattern), searchType, page, 'search',
                config.plugins.iptvplayer.ytSortBy.value, url)
        else:
            tmpList = self.ytp.getSearchResult(
                urllib.quote_plus(pattern), searchType, page, 'search',
                config.plugins.iptvplayer.ytSortBy.value)

        for item in tmpList:
            item.update({'name': 'category'})
            if 'video' == item['type']:
                self.addVideo(item)
            elif 'more' == item['type']:
                self.addMore(item)
            else:
                if item['category'] in [
                        "channel", "playlist", "movie", "traylist"
                ]:
                    item['good_for_fav'] = True
                self.addDir(item)

    def getLinksForVideo(self, cItem):
        printDBG("Youtube.getLinksForVideo cItem[%s]" % cItem)
        urlTab = self.up.getVideoLinkExt(cItem['url'])
        if config.plugins.iptvplayer.ytUseDF.value and 0 < len(urlTab):
            return [urlTab[0]]
        return urlTab

    def getFavouriteData(self, cItem):
        printDBG('Youtube.getFavouriteData')
        return json.dumps(cItem)

    def getLinksForFavourite(self, fav_data):
        printDBG('Youtube.getLinksForFavourite')
        links = []
        try:
            cItem = byteify(json.loads(fav_data))
            links = self.getLinksForVideo(cItem)
        except Exception:
            printExc()
            return self.getLinksForVideo({'url': fav_data})
        return links

    def setInitListFromFavouriteItem(self, fav_data):
        printDBG('Youtube.setInitListFromFavouriteItem')
        try:
            params = byteify(json.loads(fav_data))
        except Exception:
            params = {}
            printExc()
        self.addDir(params)
        return True

    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Youtube.handleService start')

        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)

        name = self.currItem.get("name", '')
        category = self.currItem.get("category", '')
        printDBG("Youtube.handleService: ---------> name[%s], category[%s] " %
                 (name, category))
        self.currList = []

        if None == name:
            self.listMainMenu()
        elif 'from_file' == category:
            self.listCategory(self.currItem)
        elif category in ["channel", "playlist", "movie", "traylist"]:
            self.getVideos(self.currItem)
        elif category.startswith("feeds"):
            self.listFeeds(self.currItem)
        elif category == 'playlists':
            self.listItems(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: "))
        elif category == "delete_history":
            self.delhistory()
        else:
            printExc()
        self.yeah = self.lenhistory()

        CBaseHostClass.endHandleService(self, index, refresh)

    def delhistory(self):
        printDBG('Youtube.delhistory')
        msg = 'Are you sure you want to delete search history?'
        ret = self.sessionEx.waitForFinishOpen(MessageBox,
                                               msg,
                                               type=MessageBox.TYPE_YESNO,
                                               default=True)
        if ret[0]:
            self.doit()

    def doit(self):
        try:
            os.remove(GetSearchHistoryDir("ytlist.txt"))
            msg = 'Search History successfully deleted.'
            ret = self.sessionEx.waitForFinishOpen(MessageBox,
                                                   msg,
                                                   type=MessageBox.TYPE_INFO)
        except:
            msg = 'Unable to comply. Search History is empty.'
            ret = self.sessionEx.waitForFinishOpen(MessageBox,
                                                   msg,
                                                   type=MessageBox.TYPE_INFO)

    def lenhistory(self):
        num = 0

        try:
            file = codecs.open(GetSearchHistoryDir("ytlist.txt"), 'r', 'utf-8',
                               'ignore')
            for line in file:
                num = num + 1
            file.close()
        except:
            return ("Search History is empty.")
        return ("Number of items in search history: " + str(num))

    def getSuggestionsProvider(self, index):
        printDBG('Youtube.getSuggestionsProvider')
        from Plugins.Extensions.IPTVPlayer.suggestions.google import SuggestionsProvider
        return SuggestionsProvider(True)
Ejemplo n.º 13
0
class Urllist(CBaseHostClass):
    URLLIST_FILE = "urllist.txt"
    URRLIST_STREAMS = "urllist.stream"
    URRLIST_USER = "******"
    MAIN_GROUPED_TAB = [
        {
            "category": "all",
            "title": (_("All in one")),
            "desc": (_("Links are videos and messages, without division into categories")),
        },
        {
            "category": URLLIST_FILE,
            "title": (_("Videos")),
            "desc": (_("Links to the video files from the file urllist.txt")),
        },
        {
            "category": URRLIST_STREAMS,
            "title": (_("live transfers")),
            "desc": (_("Live broadcasts from the file urllist.stream")),
        },
        {
            "category": URRLIST_USER,
            "title": (_("User files")),
            "desc": (_("Favorite addresses are stored under the file urllist.user")),
        },
    ]

    def __init__(self):
        printDBG("Urllist.__init__")
        CBaseHostClass.__init__(self)
        self.currFileHost = None

    def _cleanHtmlStr(self, str):
        str = self.cm.ph.replaceHtmlTags(str, " ").replace("\n", " ")
        return clean_html(self.cm.ph.removeDoubles(str, " ").replace(" )", ")").strip())

    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 _uriIsValid(self, url):
        if "://" in url:
            return True
        return False

    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)

        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem["category"] in ["all", Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS, Urllist.URRLIST_USER]:
            self.currFileHost = IPTVFileHost()
            if cItem["category"] in ["all", Urllist.URLLIST_FILE]:
                self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE, encoding="utf-8")
            if cItem["category"] in ["all", Urllist.URRLIST_STREAMS]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding="utf-8")
            if cItem["category"] in ["all", Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding="utf-8")

            if "all" != cItem["category"] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if "" == item:
                        title = _("Other")
                    else:
                        title = item
                    params = {"name": "category", "category": "group", "title": title, "group": item}
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    params = {
                        "title": item["full_title"],
                        "url": item["url"],
                        "desc": (_("Hosting: %s, %s")) % (self._getHostingName(item["url"]), item["url"]),
                    }
                    self.addVideo(params)
        elif "group" in cItem:
            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 = {
                    "title": title,
                    "url": item["url"],
                    "desc": (_("Hosting: %s, %s")) % (self._getHostingName(item["url"]), item["url"]),
                }
                self.addVideo(params)

    def getLinksForVideo(self, cItem):
        printDBG("Urllist.getLinksForVideo url[%s]" % cItem["url"])
        videoUrls = []
        uri, params = DMHelper.getDownloaderParamFromUrl(cItem["url"])
        printDBG(params)
        uri = urlparser.decorateUrl(uri, params)

        urlSupport = self.up.checkHostSupport(uri)
        if 1 == urlSupport:
            retTab = self.up.getVideoLinkExt(uri)
            videoUrls.extend(retTab)
        elif 0 == urlSupport and self._uriIsValid(uri):
            if uri.split("?")[0].endswith(".m3u8"):
                retTab = getDirectM3U8Playlist(uri)
                videoUrls.extend(retTab)
            elif uri.split("?")[0].endswith(".f4m"):
                retTab = getF4MLinksWithMeta(uri)
                videoUrls.extend(retTab)
            else:
                videoUrls.append({"name": "direct link", "url": uri})
        return videoUrls

    def handleService(self, index, refresh=0, searchPattern="", searchType=""):
        printDBG("Urllist.handleService start")
        CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType)
        name = self.currItem.get("name", None)
        category = self.currItem.get("category", "")
        printDBG("Urllist.handleService: ---------> name[%s], category[%s] " % (name, category))
        self.currList = []

        if None == name:
            self.listsTab(Urllist.MAIN_GROUPED_TAB, self.currItem)
        else:
            self.listCategory(self.currItem)

        CBaseHostClass.endHandleService(self, index, refresh)
Ejemplo n.º 14
0
class Urllist(CBaseHostClass):
    URLLIST_FILE = 'urllist.txt'
    URRLIST_STREAMS = 'urllist.stream'
    URRLIST_USER = '******'
    MAIN_GROUPED_TAB = [{'category': 'all',           'title': (_("All in one")),        'desc': (_("Links are videos and messages, without division into categories"))}, \
                        {'category': URLLIST_FILE,    'title': (_("Videos")),            'desc': (_("Links to the video files from the file urllist.txt"))}, \
                        {'category': URRLIST_STREAMS, 'title': (_("live transfers")),    'desc': (_("Live broadcasts from the file urllist.stream"))}, \
                        {'category': URRLIST_USER,    'title': (_("User files")),        'desc': (_("Favorite addresses are stored under the file urllist.user"))}]

    def __init__(self):
        printDBG("Urllist.__init__")
        CBaseHostClass.__init__(self)
        self.currFileHost = None

    def _cleanHtmlStr(self, str):
        str = self.cm.ph.replaceHtmlTags(str, ' ').replace('\n', ' ')
        return clean_html(
            self.cm.ph.removeDoubles(str, ' ').replace(' )', ')').strip())

    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 _uriIsValid(self, url):
        if '://' in url:
            return True
        return False

    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)

        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in [
                'all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS,
                Urllist.URRLIST_USER
        ]:
            self.currFileHost = IPTVFileHost()
            if cItem['category'] in ['all', Urllist.URLLIST_FILE]:
                self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER,
                                          encoding='utf-8')

            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item: title = (_("Other"))
                    else: title = item
                    params = {
                        'name': 'category',
                        'category': 'group',
                        'title': title,
                        'group': item
                    }
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    params = {
                        'title':
                        item['full_title'],
                        'url':
                        item['url'],
                        'desc': (_("Hosting: %s, %s")) %
                        (self._getHostingName(item['url']), item['url'])
                    }
                    self.addVideo(params)
        elif 'group' in cItem:
            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 = {
                    'title':
                    title,
                    'url':
                    item['url'],
                    'desc': (_("Hosting: %s, %s")) %
                    (self._getHostingName(item['url']), item['url'])
                }
                self.addVideo(params)

    def getLinksForVideo(self, cItem):
        printDBG("Urllist.getLinksForVideo url[%s]" % cItem['url'])
        videoUrls = []
        uri, params = DMHelper.getDownloaderParamFromUrl(cItem['url'])
        printDBG(params)
        uri = urlparser.decorateUrl(uri, params)

        urlSupport = self.up.checkHostSupport(uri)
        if 1 == urlSupport:
            retTab = self.up.getVideoLinkExt(uri)
            videoUrls.extend(retTab)
        elif 0 == urlSupport and self._uriIsValid(uri):
            if uri.split('?')[0].endswith('.m3u8'):
                retTab = getDirectM3U8Playlist(uri)
                videoUrls.extend(retTab)
            elif uri.split('?')[0].endswith('.f4m'):
                retTab = getF4MLinksWithMeta(uri)
                videoUrls.extend(retTab)
            else:
                videoUrls.append({'name': 'direct link', 'url': uri})
        return videoUrls

    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Urllist.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)
        name = self.currItem.get("name", None)
        category = self.currItem.get("category", '')
        printDBG("Urllist.handleService: ---------> name[%s], category[%s] " %
                 (name, category))
        self.currList = []

        if None == name:
            self.listsTab(Urllist.MAIN_GROUPED_TAB, self.currItem)
        else:
            self.listCategory(self.currItem)

        CBaseHostClass.endHandleService(self, index, refresh)
Ejemplo n.º 15
0
class Youtube(CBaseHostClass):
    UTLIST_FILE = 'ytlist.txt'
    MAIN_GROUPED_TAB = [{'category': 'from_file',             'title': _("User links"),     'desc': _("User links stored in the ytlist.txt file.")}, \
                        {'category': 'Wyszukaj',              'title': _("Search"),         'desc': _("Search youtube materials "), 'search_item':True}, \
                        {'category': 'Historia wyszukiwania', 'title': _("Search history"), 'desc': _("History of searched phrases.")}]
    SEARCH_TYPES = [(_("Video"), "video"), (_("Channel"), "channel"),
                    (_("Playlist"), "playlist"), (_("Movie"), "movie"),
                    (_("Live"), "live")]

    #("Program",            "show"    ),
    #("traylist",           "traylist"),

    def __init__(self):
        printDBG("Youtube.__init__")
        CBaseHostClass.__init__(self, {
            'history': 'ytlist',
            'cookie': 'youtube.cookie'
        })
        self.ytp = YouTubeParser()
        self.currFileHost = None

    def _cleanHtmlStr(self, str):
        str = self.cm.ph.replaceHtmlTags(str, ' ').replace('\n', ' ')
        return clean_html(
            self.cm.ph.removeDoubles(str, ' ').replace(' )', ')').strip())

    def _getCategory(self, url):
        printDBG("Youtube._getCategory")
        if '/playlist?list=' in url:
            category = 'playlist'
        elif None != re.search('/watch\?v=[^\&]+?\&list=', url):
            category = 'traylist'
        elif 'user/' in url or 'channel/' in url:
            category = 'channel'
        else:
            category = 'video'
        return category

    def listsMainMenu(self):
        printDBG("Youtube.listsMainMenu")
        for item in Youtube.MAIN_GROUPED_TAB:
            params = {'name': 'category'}
            params.update(item)
            self.addDir(params)

    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 + Youtube.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({
                        '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({
                        'title': title,
                        'url': item['url'],
                        'desc': item['url'],
                        'category': category
                    })
                    if 'video' == category:
                        self.addVideo(params)
                    else:
                        self.addDir(params)

    def getVideos(self, cItem):
        printDBG('Youtube.getVideos cItem[%s]' % (cItem))

        category = cItem.get("category", '')
        url = cItem.get("url", '')
        page = cItem.get("page", '1')

        if "channel" == category:
            if -1 == url.find('browse_ajax'):
                if url.endswith('/videos'):
                    url = url + '?flow=list&view=0&sort=dd'
                else:
                    url = url + '/videos?flow=list&view=0&sort=dd'
            self.currList = self.ytp.getVideosFromChannelList(
                url, category, page, cItem)
        elif "playlist" == category:
            self.currList = self.ytp.getVideosFromPlaylist(
                url, category, page, cItem)
        elif "traylist" == category:
            self.currList = self.ytp.getVideosFromTraylist(
                url, category, page, cItem)
        else:
            printDBG('YTlist.getVideos Error unknown category[%s]' % category)

    def getSearchResult(self, cItem, pattern, searchType):
        page = self.currItem.get("page", '1')
        tmpList = self.ytp.getSearchResult(
            pattern, searchType, page, 'Wyszukaj',
            config.plugins.iptvplayer.ytSortBy.value)
        for item in tmpList:
            item.update({'name': 'category'})
            if 'video' == item['type']:
                self.addVideo(item)
            else:
                self.addDir(item)

    def getLinksForVideo(self, url):
        printDBG("Youtube.getLinksForVideo url[%s]" % url)
        ytformats = config.plugins.iptvplayer.ytformat.value
        maxRes = int(config.plugins.iptvplayer.ytDefaultformat.value) * 1.1
        dash = config.plugins.iptvplayer.ytShowDash.value

        if not url.startswith("http://") and not url.startswith("https://"):
            url = 'http://www.youtube.com/' + url
        tmpTab, dashTab = self.ytp.getDirectLinks(url,
                                                  ytformats,
                                                  dash,
                                                  dashSepareteList=True)

        def __getLinkQuality(itemLink):
            tab = itemLink['format'].split('x')
            return int(tab[0])

        tmpTab = CSelOneLink(tmpTab, __getLinkQuality, maxRes).getSortedLinks()
        if config.plugins.iptvplayer.ytUseDF.value and 0 < len(tmpTab):
            tmpTab = [tmpTab[0]]

        videoUrls = []
        for item in tmpTab:
            videoUrls.append({
                'name': item['format'] + ' | ' + item['ext'],
                'url': item['url']
            })
        for item in dashTab:
            videoUrls.append({
                'name':
                _("[dash] ") + item['format'] + ' | ' + item['ext'],
                'url':
                item['url']
            })
        return videoUrls

    def getFavouriteData(self, cItem):
        return cItem['url']

    def getLinksForFavourite(self, fav_data):
        return self.getLinksForVideo(fav_data)

    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Youtube.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)
        name = self.currItem.get("name", None)
        category = self.currItem.get("category", '')
        printDBG("Youtube.handleService: ---------> name[%s], category[%s] " %
                 (name, category))
        self.currList = []

        if None == name:
            self.listsMainMenu()
        elif 'from_file' == category:
            self.listCategory(self.currItem)
        elif category in ["channel", "playlist", "movie", "traylist"]:
            self.getVideos(self.currItem)
    #WYSZUKAJ
        elif category == 'Wyszukaj':
            pattern = urllib.quote_plus(searchPattern)
            printDBG("Wyszukaj pattern[%s], type[%s]" % (pattern, searchType))
            self.getSearchResult(self.currItem, pattern, searchType)

    #HISTORIA WYSZUKIWANIAmain_item
        elif category == 'Historia wyszukiwania':
            self.listsHistory()
Ejemplo n.º 16
0
class Urllist(CBaseHostClass):
    URLLIST_FILE = 'urllist.txt'
    URRLIST_STREAMS = 'urllist.stream'
    URRLIST_USER = '******'

    def __init__(self):
        printDBG("Urllist.__init__")
        path = config.plugins.iptvplayer.Sciezkaurllist.value + '/'

        self.MAIN_GROUPED_TAB = [{
            'category':
            'all',
            'title':
            _("All in one"),
            'desc':
            _("Links from all files without categories"),
            'icon':
            'https://mikeharwood.files.wordpress.com/2011/01/all-in-one-logo-on-blue.jpg'
        }]
        self.MAIN_GROUPED_TAB.extend( [{'category': Urllist.URLLIST_FILE,       'title': _("Videos"),                    'desc': _("Links from the file %s") % normpath(path + 'urllist.txt'),              'icon':'https://st2.depositphotos.com/3000465/12281/v/950/depositphotos_122812390-stock-illustration-video-play-sign-with-letter.jpg'}, \
                                       {'category': Urllist.URRLIST_STREAMS,    'title': _("Live streams"),              'desc': _("Links from the file %s") % normpath(path + 'urllist.stream'),           'icon':'http://asiamh.ru.images.1c-bitrix-cdn.ru/images/media_logo.jpg?136879146733721'}, \
                                       {'category': Urllist.URRLIST_USER,       'title': _("User files"),                'desc': _("Links from the file %s") % normpath(path + 'urllist.user'),             'icon':'http://kinovesti.ru/uploads/posts/2014-12/1419918660_1404722920_02.jpg'}])
        CBaseHostClass.__init__(self)
        self.currFileHost = None

    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 _uriIsValid(self, url):
        return '://' in url

    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)

        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in [
                'all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS,
                Urllist.URRLIST_USER
        ]:
            self.currFileHost = IPTVFileHost()

            if cItem['category'] in ['all', Urllist.URLLIST_FILE]:
                self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER,
                                          encoding='utf-8')

            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item: title = (_("Other"))
                    else: title = item
                    params = {
                        'name': 'category',
                        'category': 'group',
                        'title': title,
                        'group': item
                    }
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    desc = (_("Hosting: %s, %s")) % (self._getHostingName(
                        item['url']), item['url'])
                    if item['desc'] != '':
                        desc = item['desc']
                    params = {
                        'title': item['full_title'],
                        'url': item['url'],
                        'desc': desc,
                        'icon': item['icon']
                    }
                    self.addVideo(params)
        elif 'group' in cItem:
            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']
                desc = (_("Hosting: %s, %s")) % (self._getHostingName(
                    item['url']), item['url'])
                if item.get('desc', '') != '':
                    desc = item['desc']
                params = {
                    'title': title,
                    'url': item['url'],
                    'desc': desc,
                    'icon': item.get('icon', '')
                }
                self.addVideo(params)

    def getLinksForVideo(self, cItem):
        printDBG("Urllist.getLinksForVideo url[%s]" % cItem['url'])
        videoUrls = []
        uri = urlparser.decorateParamsFromUrl(cItem['url'])
        protocol = uri.meta.get('iptv_proto', '')

        printDBG("PROTOCOL [%s] " % protocol)

        urlSupport = self.up.checkHostSupport(uri)
        if 1 == urlSupport:
            retTab = self.up.getVideoLinkExt(uri)
            videoUrls.extend(retTab)
        elif 0 == urlSupport and self._uriIsValid(uri):
            if protocol == 'm3u8':
                retTab = getDirectM3U8Playlist(uri,
                                               checkExt=False,
                                               checkContent=True)
                videoUrls.extend(retTab)
            elif protocol == 'f4m':
                retTab = getF4MLinksWithMeta(uri)
                videoUrls.extend(retTab)
            elif protocol == 'mpd':
                retTab = getMPDLinksWithMeta(uri, False)
                videoUrls.extend(retTab)
            else:
                videoUrls.append({'name': 'direct link', 'url': uri})
        return videoUrls

    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Urllist.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)
        name = self.currItem.get("name", None)
        category = self.currItem.get("category", '')
        printDBG("Urllist.handleService: ---------> name[%s], category[%s] " %
                 (name, category))
        self.currList = []

        if None == name:
            self.listsTab(self.MAIN_GROUPED_TAB, self.currItem)
        else:
            self.listCategory(self.currItem)

        CBaseHostClass.endHandleService(self, index, refresh)
Ejemplo n.º 17
0
    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)

        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in [
                'all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS,
                Urllist.URRLIST_USER
        ]:
            self.currFileHost = IPTVFileHost()
            if cItem['category'] in ['all', Urllist.URLLIST_FILE]:
                self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER,
                                          encoding='utf-8')

            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item: title = 'Pozostałe'
                    else: title = item
                    params = {
                        'name': 'category',
                        'category': 'group',
                        'title': title,
                        'group': item
                    }
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    params = {
                        'title':
                        item['full_title'],
                        'url':
                        item['url'],
                        'desc':
                        'Hosting: %s, %s' %
                        (self._getHostingName(item['url']), item['url'])
                    }
                    self.addVideo(params)
        elif 'group' in cItem:
            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 = {
                    'title':
                    title,
                    'url':
                    item['url'],
                    'desc':
                    'Hosting: %s, %s' %
                    (self._getHostingName(item['url']), item['url'])
                }
                self.addVideo(params)
Ejemplo n.º 18
0
class Urllist(CBaseHostClass):
    URLLIST_FILE = 'urllist.txt'
    URRLIST_STREAMS = 'urllist.stream'
    URRLIST_USER = '******'
    MAIN_GROUPED_TAB = [{'category': 'all',           'title': 'All in one',        'desc': 'Linki to filmów i przekazów, bez podziału na kategorie'}, \
                        {'category': URLLIST_FILE,    'title': 'Pliki video',       'desc': 'Linki do plikow video z pliku urllist.txt'}, \
                        {'category': URRLIST_STREAMS, 'title': 'Przekazy live',     'desc': 'Przekazy na żywo z pliku urllist.stream'}, \
                        {'category': URRLIST_USER,    'title': 'Pliki użytkownika', 'desc': 'Ulubione adresy użytkownika zapisane w pliku urllist.user'}]

    def __init__(self):
        printDBG("Urllist.__init__")
        CBaseHostClass.__init__(self)
        self.currFileHost = None

    def _cleanHtmlStr(self, str):
        str = self.cm.ph.replaceHtmlTags(str, ' ').replace('\n', ' ')
        return clean_html(
            self.cm.ph.removeDoubles(str, ' ').replace(' )', ')').strip())

    def _getHostingName(self, url):
        if 0 != self.up.checkHostSupport(url):
            return self.up.getHostName(url)
        elif self._uriIsValid(url):
            return 'link bezpośredni'
        else:
            return 'nieznany'

    def _uriIsValid(self, url):
        if '://' in url:
            return True
        return False

    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)

        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in [
                'all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS,
                Urllist.URRLIST_USER
        ]:
            self.currFileHost = IPTVFileHost()
            if cItem['category'] in ['all', Urllist.URLLIST_FILE]:
                self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER,
                                          encoding='utf-8')

            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item: title = 'Pozostałe'
                    else: title = item
                    params = {
                        'name': 'category',
                        'category': 'group',
                        'title': title,
                        'group': item
                    }
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    params = {
                        'title':
                        item['full_title'],
                        'url':
                        item['url'],
                        'desc':
                        'Hosting: %s, %s' %
                        (self._getHostingName(item['url']), item['url'])
                    }
                    self.addVideo(params)
        elif 'group' in cItem:
            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 = {
                    'title':
                    title,
                    'url':
                    item['url'],
                    'desc':
                    'Hosting: %s, %s' %
                    (self._getHostingName(item['url']), item['url'])
                }
                self.addVideo(params)

    def getLinksForVideo(self, cItem):
        printDBG("Urllist.getLinksForVideo url[%s]" % cItem['url'])
        videoUrls = []
        uri = cItem['url']
        urlSupport = self.up.checkHostSupport(uri)
        if 1 == urlSupport:
            retTab = self.up.getVideoLinkExt(uri)
            videoUrls.extend(retTab)
        elif 0 == urlSupport and self._uriIsValid(uri):
            if uri.split('?')[0].endswith('.m3u8'):
                retTab = getDirectM3U8Playlist(uri)
                videoUrls.extend(retTab)
            elif uri.split('?')[0].endswith('.f4m'):
                retTab = getF4MLinksWithMeta(uri)
                videoUrls.extend(retTab)
            else:
                videoUrls.append({'name': 'direct link', 'url': uri})
        return videoUrls

    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Urllist.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)
        name = self.currItem.get("name", None)
        category = self.currItem.get("category", '')
        printDBG("Urllist.handleService: ---------> name[%s], category[%s] " %
                 (name, category))
        self.currList = []

        if None == name:
            self.listsTab(Urllist.MAIN_GROUPED_TAB, self.currItem)
        else:
            self.listCategory(self.currItem)

        CBaseHostClass.endHandleService(self, index, refresh)
Ejemplo n.º 19
0
class Urllist(CBaseHostClass):
    URLLIST_BLOG = 'urllist.blog'
    URRLIST_STREAMS = 'urllist.saga'
    URRLIST_USER = '******'

    def __init__(self):
        printDBG('Urllist.__init__')
        path = config.plugins.iptvplayer.Sciezkaurllist.value + '/'
		
#        self.MAIN_GROUPED_TAB = [{'category': 'all',
#          'title': _('All in one'),
#          'desc': _('Links from all files without categories'),
#          'icon': 'https://mikeharwood.files.wordpress.com/2011/01/all-in-one-logo-on-blue.jpg'}]
        self.MAIN_GROUPED_TAB = ([{'category': Urllist.URLLIST_BLOG,
          'title': _('BOXTVMANIA BLOG & REVIEWS'),
          'desc': _('Links from the file %s') % normpath(path + 'urllist.blog'),
          'icon': 'https://boxtvmania.files.wordpress.com/2018/08/cropped-bio_facebook.jpg'}])
          #'title': _('Iptv Channels'),
          #'desc': _('Links from the file %s') % normpath(path + 'urllist.iptv'),
          #'icon': 'http://elrinconenigma2.hol.es/E2iplayericons/iptv_spain.jpg'}, {'category': Urllist.URRLIST_USER,
          #'title': _('Tdt Channels'),
          #'desc': _('Links from the file %s') % normpath(path + 'urllist.user'),
          #'icon': 'http://elrinconenigma2.hol.es/E2iplayericons/tdtchannels100.png'}])
        CBaseHostClass.__init__(self)
        self.currFileHost = None
        return

    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 _uriIsValid(self, url):
        return '://' in url

    def listCategory(self, cItem, searchMode = False):
        printDBG('Urllist.listCategory cItem[%s]' % cItem)
        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in ['all',
         Urllist.URLLIST_BLOG,
         Urllist.URRLIST_STREAMS,
         Urllist.URRLIST_USER]:
            self.currFileHost = IPTVFileHost()
            if cItem['category'] in ['all', Urllist.URLLIST_BLOG]:
                self.currFileHost.addFile(filespath + Urllist.URLLIST_BLOG, encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding='utf-8')
            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item:
                        title = _('BOXTVMANIA')
                    else:
                        title = item
                    params = {'name': 'category',
                     'category': 'group',
                     'title': title,
                     'group': item}
                    self.addDir(params)

            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    desc = _('Hosting: %s, Boxtvmania.blog') % (self._getHostingName(item['url']))
                    if item['desc'] != '':
                        desc = item['desc']
                    params = {'title': item['full_title'],
                     'url': item['url'],
                     'desc': desc,
                     'icon': item['icon']}
                    self.addVideo(params)

        elif 'group' in cItem:
            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']
                desc = _('Hosting: %s, ColomboTeam') % (self._getHostingName(item['url']))
                if item.get('desc', '') != '':
                    desc = item['desc']
                params = {'title': title,
                 'url': item['url'],
                 'desc': desc,
                 'icon': item.get('icon', '')}
                self.addVideo(params)

    def getLinksForVideo(self, cItem):
        printDBG('Urllist.getLinksForVideo url[%s]' % cItem['url'])
        videoUrls = []
        uri = urlparser.decorateParamsFromUrl(cItem['url'])
        protocol = uri.meta.get('iptv_proto', '')
        printDBG('PROTOCOL [%s] ' % protocol)
        urlSupport = self.up.checkHostSupport(uri)
        if 1 == urlSupport:
            retTab = self.up.getVideoLinkExt(uri)
            videoUrls.extend(retTab)
        elif 0 == urlSupport and self._uriIsValid(uri):
            if protocol == 'm3u8':
                retTab = getDirectM3U8Playlist(uri, checkExt=False, checkContent=True)
                videoUrls.extend(retTab)
            elif protocol == 'f4m':
                retTab = getF4MLinksWithMeta(uri)
                videoUrls.extend(retTab)
            elif protocol == 'mpd':
                retTab = getMPDLinksWithMeta(uri, False)
                videoUrls.extend(retTab)
            else:
                videoUrls.append({'name': 'direct link',
                 'url': uri})
        return videoUrls

    def handleService(self, index, refresh = 0, searchPattern = '', searchType = ''):
        printDBG('Urllist.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType)
        name = self.currItem.get('name', None)
        category = self.currItem.get('category', '')
        printDBG('Urllist.handleService: ---------> name[%s], category[%s] ' % (name, category))
        self.currList = []
        if None == name:
            self.listsTab(self.MAIN_GROUPED_TAB, self.currItem)
        else:
            self.listCategory(self.currItem)
        CBaseHostClass.endHandleService(self, index, refresh)
        return
Ejemplo n.º 20
0
class Urllist(CBaseHostClass):
    URLLIST_FILE = 'urllist.txt'
    URRLIST_STREAMS = 'urllist.stream'
    URRLIST_USER = '******'

    def __init__(self):
        printDBG("Urllist.__init__")

        self.MAIN_GROUPED_TAB = [{
            'category':
            'all',
            'title': (_("All in one")),
            'desc':
            (_("Links are videos and messages, without division into categories"
               )),
            'icon':
            'http://osvita.mediasapiens.ua/content/news/001000-002000/shyfrovanie_dannyh_1415.jpg'
        }]
        self.MAIN_GROUPED_TAB.extend( [{'category': Urllist.URLLIST_FILE,       'title': (_("Videos")),                    'desc': (_("Links to the video files from the file urllist.txt")),        'icon':'http://mohov.h15.ru/logotip_kino.jpg'}, \
                                       {'category': Urllist.URRLIST_STREAMS,    'title': (_("live transfers")),            'desc': (_("Live broadcasts from the file urllist.stream")),              'icon':'http://asiamh.ru.images.1c-bitrix-cdn.ru/images/media_logo.jpg?136879146733721'}, \
                                       {'category': Urllist.URRLIST_USER,       'title': (_("User files")),                'desc': (_("Favorite addresses are stored under the file urllist.user")), 'icon':'http://kinovesti.ru/uploads/posts/2014-12/1419918660_1404722920_02.jpg'}])
        CBaseHostClass.__init__(self)
        self.currFileHost = None

    def _cleanHtmlStr(self, str):
        str = self.cm.ph.replaceHtmlTags(str, ' ').replace('\n', ' ')
        return clean_html(
            self.cm.ph.removeDoubles(str, ' ').replace(' )', ')').strip())

    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 _uriIsValid(self, url):
        if '://' in url:
            return True
        return False

    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)

        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in [
                'all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS,
                Urllist.URRLIST_USER
        ]:
            self.currFileHost = IPTVFileHost()

            if cItem['category'] in ['all', Urllist.URLLIST_FILE]:
                self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS,
                                          encoding='utf-8')
            if cItem['category'] in ['all', Urllist.URRLIST_USER]:
                self.currFileHost.addFile(filespath + Urllist.URRLIST_USER,
                                          encoding='utf-8')

            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item: title = (_("Other"))
                    else: title = item
                    params = {
                        'name': 'category',
                        'category': 'group',
                        'title': title,
                        'group': item
                    }
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    desc = (_("Hosting: %s, %s")) % (self._getHostingName(
                        item['url']), item['url'])
                    if item['desc'] != '':
                        desc = item['desc']
                    params = {
                        'title': item['full_title'],
                        'url': item['url'],
                        'desc': desc,
                        'icon': item['icon']
                    }
                    self.addVideo(params)
        elif 'group' in cItem:
            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']
                desc = (_("Hosting: %s, %s")) % (self._getHostingName(
                    item['url']), item['url'])
                if item.get('desc', '') != '':
                    desc = item['desc']
                params = {
                    'title': title,
                    'url': item['url'],
                    'desc': desc,
                    'icon': item.get('icon', '')
                }
                self.addVideo(params)

    def getLinksForVideo(self, cItem):
        printDBG("Urllist.getLinksForVideo url[%s]" % cItem['url'])
        videoUrls = []
        uri = urlparser.decorateParamsFromUrl(cItem['url'])
        protocol = uri.meta.get('iptv_proto', '')

        printDBG("PROTOCOL [%s] " % protocol)

        urlSupport = self.up.checkHostSupport(uri)
        if 1 == urlSupport:
            retTab = self.up.getVideoLinkExt(uri)
            videoUrls.extend(retTab)
        elif 0 == urlSupport and self._uriIsValid(uri):
            if protocol == 'm3u8':
                retTab = getDirectM3U8Playlist(uri,
                                               checkExt=False,
                                               checkContent=True)
                videoUrls.extend(retTab)
            elif protocol == 'f4m':
                retTab = getF4MLinksWithMeta(uri)
                videoUrls.extend(retTab)
            elif protocol == 'mpd':
                retTab = getMPDLinksWithMeta(uri, False)
                videoUrls.extend(retTab)
            else:
                videoUrls.append({'name': 'direct link', 'url': uri})
        return videoUrls

    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Urllist.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)
        name = self.currItem.get("name", None)
        category = self.currItem.get("category", '')
        printDBG("Urllist.handleService: ---------> name[%s], category[%s] " %
                 (name, category))
        self.currList = []

        if None == name:
            self.listsTab(self.MAIN_GROUPED_TAB, self.currItem)
        else:
            self.listCategory(self.currItem)

        CBaseHostClass.endHandleService(self, index, refresh)
Ejemplo n.º 21
0
class Youtube(CBaseHostClass):
    def __init__(self):
        printDBG("Youtube.__init__")
        CBaseHostClass.__init__(self, {
            'history': 'ytlist',
            'cookie': 'youtube.cookie'
        })
        self.UTLIST_FILE = 'ytlist.txt'
        self.DEFAULT_ICON_URL = 'http://www.mm229.com/images/youtube-button-psd-450203.png'
        self.MAIN_GROUPED_TAB = [{'category': 'from_file',             'title': _("User links"),     'desc': _("User links stored in the ytlist.txt file.")}, \
                                 {'category': 'search',                'title': _("Search"),         'desc': _("Search youtube materials "), 'search_item':True}, \
                                 {'category': 'search_history',        'title': _("Search history"), 'desc': _("History of searched phrases.")}]
        self.SEARCH_TYPES = [(_("Video"), "video"), (_("Channel"), "channel"),
                             (_("Playlist"), "playlist"),
                             (_("Movie"), "movie"), (_("Live"), "live")]
        #("Program",            "show"    ),
        #("traylist",           "traylist"),
        self.ytp = YouTubeParser()
        self.currFileHost = None

    def _getCategory(self, url):
        printDBG("Youtube._getCategory")
        if '/playlist?list=' in url:
            category = 'playlist'
        elif url.split('?')[0].endswith('/playlists'):
            category = 'playlists'
        elif None != re.search('/watch\?v=[^\&]+?\&list=', url):
            category = 'traylist'
        elif 'user/' in url or ('channel/' in url
                                and not url.endswith('/live')):
            category = 'channel'
        else:
            category = 'video'
        return category

    def listsMainMenu(self):
        printDBG("Youtube.listsMainMenu")
        for item in self.MAIN_GROUPED_TAB:
            params = {'name': 'category'}
            params.update(item)
            self.addDir(params)

    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)

    def listItems(self, cItem):
        printDBG('Youtube.listItems cItem[%s]' % (cItem))
        category = cItem.get("category", '')
        url = cItem.get("url", '')
        page = cItem.get("page", '1')

        if "playlists" == category:
            self.currList = self.ytp.getListPlaylistsItems(
                url, category, page, cItem)

        for idx in range(len(self.currList)):
            if self.currList[idx]['category'] in [
                    "channel", "playlist", "movie", "traylist"
            ]:
                self.currList[idx]['good_for_fav'] = True

    def getVideos(self, cItem):
        printDBG('Youtube.getVideos cItem[%s]' % (cItem))

        category = cItem.get("category", '')
        url = cItem.get("url", '')
        page = cItem.get("page", '1')

        if "channel" == category:
            if -1 == url.find('browse_ajax'):
                if url.endswith('/videos'):
                    url = url + '?flow=list&view=0&sort=dd'
                else:
                    url = url + '/videos?flow=list&view=0&sort=dd'
            self.currList = self.ytp.getVideosFromChannelList(
                url, category, page, cItem)
        elif "playlist" == category:
            self.currList = self.ytp.getVideosFromPlaylist(
                url, category, page, cItem)
        elif "traylist" == category:
            self.currList = self.ytp.getVideosFromTraylist(
                url, category, page, cItem)
        else:
            printDBG('YTlist.getVideos Error unknown category[%s]' % category)

    def listSearchResult(self, cItem, pattern, searchType):
        page = self.currItem.get("page", '1')
        tmpList = self.ytp.getSearchResult(
            urllib.quote_plus(pattern), searchType, page, 'search',
            config.plugins.iptvplayer.ytSortBy.value)
        for item in tmpList:
            item.update({'name': 'category'})
            if 'video' == item['type']:
                self.addVideo(item)
            else:
                if item['category'] in [
                        "channel", "playlist", "movie", "traylist"
                ]:
                    item['good_for_fav'] = True
                self.addDir(item)

    def getLinksForVideo(self, cItem):
        printDBG("Youtube.getLinksForVideo cItem[%s]" % cItem)
        urlTab = self.up.getVideoLinkExt(cItem['url'])
        if config.plugins.iptvplayer.ytUseDF.value and 0 < len(urlTab):
            return [urlTab[0]]
        return urlTab

    def getFavouriteData(self, cItem):
        printDBG('Youtube.getFavouriteData')
        return json.dumps(cItem)

    def getLinksForFavourite(self, fav_data):
        printDBG('Youtube.getLinksForFavourite')
        links = []
        try:
            cItem = byteify(json.loads(fav_data))
            links = self.getLinksForVideo(cItem)
        except Exception:
            printExc()
            return self.getLinksForVideo({'url': fav_data})
        return links

    def setInitListFromFavouriteItem(self, fav_data):
        printDBG('Youtube.setInitListFromFavouriteItem')
        try:
            params = byteify(json.loads(fav_data))
        except Exception:
            params = {}
            printExc()
        self.addDir(params)
        return True

    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Youtube.handleService start')

        CBaseHostClass.handleService(self, index, refresh, searchPattern,
                                     searchType)

        name = self.currItem.get("name", '')
        category = self.currItem.get("category", '')
        printDBG("Youtube.handleService: ---------> name[%s], category[%s] " %
                 (name, category))
        self.currList = []

        if None == name:
            self.listsMainMenu()
        elif 'from_file' == category:
            self.listCategory(self.currItem)
        elif category in ["channel", "playlist", "movie", "traylist"]:
            self.getVideos(self.currItem)
        elif category == 'playlists':
            self.listItems(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)
class Urllist(CBaseHostClass):
    RAFALCOOL1_FILE  = 'urllist_hostrafalcool1.txt'
    URLLIST_FILE     = 'urllist_hostrafalcool1.pin'
    URRLIST_STREAMS  = 'urllist_hostrafalcool1.stream'
    URRLIST_ADULT     = 'urllist_hostrafalcool1.XXX'
    
    def __init__(self):
        printDBG("Urllist.__init__")
        
        self.MAIN_GROUPED_TAB = [{'category': self.RAFALCOOL1_FILE,    'title': ("Propozycje Rafalcool1"),        'desc': ("Lista filmów wybranych przez kolegę Rafalcool1")}]
        if config.plugins.iptvplayer.showXXXlinks.value == True:
            self.MAIN_GROUPED_TAB.append( {'category': self.URRLIST_ADULT,    'title': ("Propozycje dla dorosłych..."),        'desc': ("Musisz podać prawidłowy PIN w konfiguracji hosta")})
        CBaseHostClass.__init__(self)               
        self.currFileHost = None 
    
    def _cleanHtmlStr(self, str):
            str = self.cm.ph.replaceHtmlTags(str, ' ').replace('\n', ' ')
            return clean_html(self.cm.ph.removeDoubles(str, ' ').replace(' )', ')').strip())
            
    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 _uriIsValid(self, url):
        if '://' in url:
            return True
        return False
        
    def updateRafalcoolFile(self, fileName, filePath, encoding):
        printDBG("Urllist.updateRafalcoolFile filePath[%s]" % filePath)
        remoteVersion = -1
        localVersion = -1
        # get version from file
        if path.exists(filePath):
            try:
                with codecs.open(filePath, 'r', encoding, 'replace') as fp:
                    # version should be in first line
                    line = fp.readline()
                    localVersion = int(self.cm.ph.getSearchGroups(line + '|', '#file_version=([0-9]+?)[^0-9]')[0])
            except:
                printExc()
        
        # generate timestamp to add to url to skip possible cacheing
        timestamp = str(time.time())
        
        # if we have loacal version get remote version for comparison
        if localVersion != '':
            sts, data = self.cm.getPage("http://hybrid.xunil.pl/IPTVPlayer_resources/UsersFiles/urllist_hostrafalcool1.version")
            if sts:
                try:
                    remoteVersion = int(data.strip())
                except:
                    printExc()
        # uaktualnij versje
        printDBG('Urllist.updateRafalcoolFile localVersion[%d] remoteVersion[%d]' % (localVersion, remoteVersion))
        if remoteVersion > -1 and localVersion < remoteVersion:
            sts, data = self.cm.getPage("http://hybrid.xunil.pl/IPTVPlayer_resources/UsersFiles/" + fileName + "?t=" + timestamp)
            if sts:
                # confirm version
                line = data[0:data.find('\n')]
                try:
                    newVersion = int(self.cm.ph.getSearchGroups(line + '|', '#file_version=([0-9]+?)[^0-9]')[0])
                    if newVersion != remoteVersion:
                        printDBG("Version mismatches localVersion[%d], remoteVersion[%d], newVersion[%d]" % (localVersion, remoteVersion, newVersion) )
                    file = open(filePath, 'wb')
                    file.write(data)
                    file.close()
                except:
                    printExc()
        
    def listCategory(self, cItem, searchMode=False):
        printDBG("Urllist.listCategory cItem[%s]" % cItem)
        
        sortList = config.plugins.iptvplayer.sortuj.value
        filespath = config.plugins.iptvplayer.Sciezkaurllist.value
        groupList = config.plugins.iptvplayer.grupujurllist.value
        if cItem['category'] in ['all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS, Urllist.URRLIST_ADULT, Urllist.RAFALCOOL1_FILE]:
            self.currFileHost = IPTVFileHost()
            if cItem['category'] in ['all', Urllist.RAFALCOOL1_FILE] and config.plugins.iptvplayer.urllist_showrafalcool1.value:
                self.updateRafalcoolFile(self.RAFALCOOL1_FILE, filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
                self.currFileHost.addFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8')
            
            #if cItem['category'] in ['all', Urllist.URLLIST_FILE]: 
            #    self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE, encoding='utf-8')
            #if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]: 
            #    self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding='utf-8')
                
            if cItem['category'] in ['all', Urllist.URRLIST_ADULT]:
                if config.plugins.iptvplayer.protectHostWithPin.value != 'xxx' or config.plugins.iptvplayer.XXXlinksPinEntered.value == config.plugins.iptvplayer.pin.value:
                    self.updateRafalcoolFile(self.URRLIST_ADULT, filespath + Urllist.URRLIST_ADULT, encoding='utf-8')
                    self.currFileHost.addFile(filespath + Urllist.URRLIST_ADULT, encoding='utf-8')
            
            if 'all' != cItem['category'] and groupList:
                tmpList = self.currFileHost.getGroups(sortList)
                for item in tmpList:
                    if '' == item: title = (_("Other"))
                    else:          title = item
                    params = {'name': 'category', 'category':'group', 'title':title, 'group':item}
                    self.addDir(params)
            else:
                tmpList = self.currFileHost.getAllItems(sortList)
                for item in tmpList:
                    desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                    if item['desc'] != '':
                        desc = item['desc']
                    params = {'title':item['full_title'], 'url':item['url'], 'desc':desc, 'icon':item['icon']}
                        
                    self.addVideo(params)
        elif 'group' in cItem:
            tmpList = self.currFileHost.getItemsInGroup(cItem['group'], sortList)
            if iptvtools_FreeSpace(config.plugins.iptvplayer.SciezkaCache.value, 10):
                downloadPath = config.plugins.iptvplayer.SciezkaCache.value
                cacheTMDB = True
            else:
                downloadPath = config.plugins.iptvplayer.NaszaTMP.value
                cacheTMDB = False
            for item in tmpList:
                if '' == item['title_in_group']:
                    title = item['full_title']
                else:
                    title = item['title_in_group']
                    
                #desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url'])
                #if item.get('desc', '') != '':
                #    desc = item['desc']
                if config.plugins.iptvplayer.excludeFromList.value == '' or not re.search(config.plugins.iptvplayer.excludeFromList.value, title, flags=re.I):
                    if item.get('desc', '') == '' and item.get('icon', '') == '' and config.plugins.iptvplayer.useTMDB.value == True:
                        desc, cover = downloadData(item['url'], title, config.plugins.iptvplayer.wgetpath.value, downloadPath, cacheTMDB )
                    else:
                        desc = item.get('desc', '')
                        cover = item.get('icon', '')
                    params = {'title':title, 'url':item['url'], 'desc': desc, 'icon': cover}
                    
                    self.addVideo(params)
                
    def getLinksForVideo(self, cItem):
        printDBG("Urllist.getLinksForVideo url[%s]" % cItem['url'])
        videoUrls = []
        uri, params   = DMHelper.getDownloaderParamFromUrl(cItem['url'])
        printDBG(params)
        uri = urlparser.decorateUrl(uri, params)
        
        urlSupport = self.up.checkHostSupport( uri )
        if 1 == urlSupport:
            retTab = self.up.getVideoLinkExt( uri )
            videoUrls.extend(retTab)
        elif 0 == urlSupport and self._uriIsValid(uri):
            if uri.split('?')[0].endswith('.m3u8'):
                retTab = getDirectM3U8Playlist(uri)
                videoUrls.extend(retTab)
            elif uri.split('?')[0].endswith('.f4m'):
                retTab = getF4MLinksWithMeta(uri)
                videoUrls.extend(retTab)
            else:
                videoUrls.append({'name':'direct link', 'url':uri})
        return videoUrls
    
    def handleService(self, index, refresh=0, searchPattern='', searchType=''):
        printDBG('Urllist.handleService start')
        CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType)
        name     = self.currItem.get("name", None)
        category = self.currItem.get("category", '')
        printDBG( "Urllist.handleService: ---------> name[%s], category[%s] " % (name, category) )
        self.currList = []
        
        if None == name:
            self.listsTab(self.MAIN_GROUPED_TAB, self.currItem)
        else:
            self.listCategory(self.currItem)
        
        CBaseHostClass.endHandleService(self, index, refresh)