def __init__(self): CBaseHostClass.__init__( self, { 'history': 'maxtvgo.com', 'cookie': 'maxtvgo.com.cookie', 'cookie_type': 'MozillaCookieJar', 'min_py_ver': (2, 7, 9) }) self.DEFAULT_ICON_URL = 'https://maxtvgo.com/images/logo_37.png' self.USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0' self.MAIN_URL = 'https://maxtvgo.com/' self.HTTP_HEADER = { 'User-Agent': self.USER_AGENT, 'DNT': '1', 'Accept': 'text/html', 'Accept-Encoding': 'gzip, deflate', 'Referer': self.getMainUrl(), 'Origin': self.getMainUrl() } self.AJAX_HEADER = dict(self.HTTP_HEADER) self.AJAX_HEADER.update({ 'X-Requested-With': 'XMLHttpRequest', 'Accept-Encoding': 'gzip, deflate', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Accept': 'application/json, text/javascript, */*; q=0.01' }) self.defaultParams = { 'header': self.HTTP_HEADER, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE } self.MAIN_CAT_TAB = [ { 'category': 'list_items', 'title': 'MaxTVGo', 'url': self.getFullUrl('/index.php') }, { 'category': 'list_yt_channel', 'title': 'Max Kolonko - MaxTV', 'url': 'https://www.youtube.com/user/Media2000Corp/videos' }, { 'category': 'list_yt_channel', 'title': 'MaxTVNews', 'url': 'https://www.youtube.com/user/MaxTVTUBE/videos' }, ] self.ytp = YouTubeParser() self.loggedIn = None self.login = '' self.password = ''
def __init__(self): printDBG("Youtube.__init__") CBaseHostClass.__init__(self, { 'history': 'ytlist', 'cookie': 'youtube.cookie' }) self.ytp = YouTubeParser() self.currFileHost = None
def __init__(self): self.cm = common() self.history = CSearchHistoryHelper('fighttube') self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value # temporary data self.currList = [] self.currItem = {}
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 __init__(self): self.up = urlparser.urlparser() self.cm = pCommon.common() self.sessionEx = MainSessionWrapper() self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value # Temporary data self.currList = [] self.currItem = {} # Login data self.COOKIEFILE = GetCookieDir('Diff-anime.cookie') self.usePremiumAccount = config.plugins.iptvplayer.diffanime_premium.value self.username = config.plugins.iptvplayer.diffanime_login.value self.password = config.plugins.iptvplayer.diffanime_password.value
def __init__(self): self.cm = common() self.ytp = YouTubeParser() self.ytformats = 'mp4' self.defaultParams = { 'header': { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0' }, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': AnyFilesVideoUrlExtractor.COOKIEFILE } self.logged = False
def getLinksForVideo(self, cItem): printDBG("getLinksForVideo cItem[%s]" % cItem) videoUrls = [] self.readYoutubeApiKey() if len(self.youtube_api_key) == 39: # quicker solution sts, data = self.cm.getPage( "https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&q=" + cItem.get('page', '') + "&type=Music&maxResults=1&key=" + self.youtube_api_key) if sts: match = re.compile('"videoId": "([^"]+?)"').findall(data) for item in match: video_path = "https://www.youtube.com/watch?v=" + item videoUrls = self._getLinksForVideo(video_path) if not videoUrls: # if apikey isn't present or previous search fails, use browser search (slower) search_list = YouTubeParser().getSearchResult( cItem.get('page', ''), "music", 1, '') if not search_list: return [] video_path = search_list[0]['url'] videoUrls = self._getLinksForVideo(video_path) return videoUrls
def __init__(self): CBaseHostClass.__init__(self) self.ytformats = config.plugins.iptvplayer.ytformat.value self.ytp = YouTubeParser() self.lastfm_username = config.plugins.iptvplayer.MusicBox_login.value self.usePremiumAccount = config.plugins.iptvplayer.MusicBox_premium.value self.DEFAULT_ICON_URL = 'http://www.darmowe-na-telefon.pl/uploads/tapeta_240x320_muzyka_23.jpg' self.BILLBOARD_URL = 'https://www.billboard.com/charts/' self.SERVICE_MENU_TABLE = [{'category':'itunes', 'title':"Itunes - Top songs by country", 'item':'song', 'url':'http://www.geonames.org/flags/x/'}, {'category':'itunes', 'title':"Itunes - Top albums by country", 'item':'album', 'url':'http://www.geonames.org/flags/x/'}, {'category':'beatport', 'title':"Beatport - Top 100", 'url':'https://pro.beatport.com/top-100'}, {'category':'billboard_charts', 'title':"Billboard - The Hot 100", 'url':self.BILLBOARD_URL + 'hot-100'}, {'category':'billboard_charts', 'title':"Billboard - 200", 'url':self.BILLBOARD_URL + 'billboard-200'}, {'category':'billboard_charts', 'title':"Billboard - Heatseekers Songs", 'url':self.BILLBOARD_URL + 'heatseekers-songs'}, {'category':'billboard_albums', 'title':"Billboard - Heatseekers Albums", 'url':self.BILLBOARD_URL + 'heatseekers-albums'}, {'category':'billboard_charts', 'title':"Billboard - Hot Pop Songs", 'url':self.BILLBOARD_URL + 'pop-songs'}, {'category':'billboard_charts', 'title':"Billboard - Hot Country Songs", 'url':self.BILLBOARD_URL + 'country-songs'}, {'category':'billboard_albums', 'title':"Billboard - Hot Country Albums", 'url':self.BILLBOARD_URL + 'country-albums'}, {'category':'billboard_charts', 'title':"Billboard - Hot Rock Songs", 'url':self.BILLBOARD_URL + 'rock-songs'}, {'category':'billboard_albums', 'title':"Billboard - Hot Rock Albums", 'url':self.BILLBOARD_URL + 'rock-albums'}, {'category':'billboard_charts', 'title':"Billboard - Hot R&B/Hip-Hop Songs", 'url':self.BILLBOARD_URL + 'r-b-hip-hop-songs'}, {'category':'billboard_albums', 'title':"Billboard - Hot R&B/Hip-Hop Albums", 'url':self.BILLBOARD_URL + 'r-b-hip-hop-albums'}, {'category':'billboard_charts', 'title':"Billboard - Hot Dance/Electronic Songs", 'url':self.BILLBOARD_URL + 'dance-electronic-songs'}, {'category':'billboard_albums', 'title':"Billboard - Hot Dance/Electronic Albums", 'url':self.BILLBOARD_URL + 'dance-electronic-albums'}, {'category':'billboard_charts', 'title':"Billboard - Hot Latin Songs", 'url':self.BILLBOARD_URL + 'latin-songs'}, {'category':'billboard_albums', 'title':"Billboard - Hot Latin Albums", 'url':self.BILLBOARD_URL + 'latin-albums'}, {'category':'lastfm', 'title':"Last.fm - " + _("My list")}, ]
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 __init__(self): self.cm = common() self.history = CSearchHistoryHelper('fighttube') self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value # temporary data self.currList = [] self.currItem = {}
def __init__(self): CBaseHostClass.__init__(self, { 'history': 'HDKinoMir', 'cookie': 'HDKinoMir.cookie' }) self.catCache = {'movies': [], 'series': []} self.USER_AGENT = "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30" self.HEADER = {'User-Agent': self.USER_AGENT, 'Accept': 'text/html'} self.defaultParams = { 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE } self.sortCache = [] self.catCache = [] self.moonwalkParser = MoonwalkParser() self.ytParser = YouTubeParser()
def getLinksForVideo(self, cItem): printDBG("getLinksForVideo cItem[%s]" % cItem) search_list = YouTubeParser().getSearchResult(cItem.get('page', ''), "music", 1, '') if not search_list: return [] video_path = search_list[0]['url'] videoUrls = self._getLinksForVideo(video_path) return videoUrls
def __init__(self): CBaseHostClass.__init__(self, {'history':'HDKinoMir', 'cookie':'HDKinoMir.cookie'}) self.USER_AGENT = "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30" self.HEADER = {'User-Agent': self.USER_AGENT, 'Accept': 'text/html'} self.defaultParams = {'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE} self.sortCache = [] self.catCache = [] self.moonwalkParser = MoonwalkParser() self.ytParser = YouTubeParser() self.MAIN_URL = 'http://hdkinomir.com/' self.DEFAULT_ICON_URL = self.getFullIconUrl('/templates/prokino/images/logo.png') self.MAIN_CAT_TAB = [{'category':'categories', 'title': _('Movie categories'), 'url':self.getMainUrl() }, {'category':'search', 'title': _('Search'), 'search_item':True }, {'category':'search_history', 'title': _('Search history') } ] self.encoding = ''
def __init__(self): printDBG("Youtube.__init__") CBaseHostClass.__init__(self, { 'history': 'ytlist', 'cookie': 'youtube.cookie' }) self.UTLIST_FILE = 'ytlist.txt' self.DEFAULT_ICON_URL = 'https://lodz.adwent.pl/wp-content/uploads/YouTube-icon-full_color.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': _("On Time"), '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 __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 __init__(self): self.up = urlparser.urlparser() self.cm = pCommon.common() self.sessionEx = MainSessionWrapper() self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value # Temporary data self.currList = [] self.currItem = {} # Login data self.COOKIEFILE = GetCookieDir('Diff-anime.cookie') self.usePremiumAccount = config.plugins.iptvplayer.diffanime_premium.value self.username = config.plugins.iptvplayer.diffanime_login.value self.password = config.plugins.iptvplayer.diffanime_password.value
class Kabarety: MAINURL = 'http://www.kabarety.odpoczywam.net/' IMGURL = 'http://i.ytimg.com/vi/' NAJ_LINK = MAINURL + '/bestof/page:' NOW_LINK = MAINURL + '/index/page:' SERVICE_MENU_TABLE = { 1: "Najnowsze", 2: "Najlepsze", 3: "Kategorie", 4: "Wyszukaj", } def __init__(self): self.cm = pCommon.common() self.currList = [] self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value def _getFullUrl(self, url, baseUrl=None): if None == baseUrl: baseUrl = Kabarety.MAINURL if 0 < len(url) and not url.startswith('http'): url = baseUrl + url return url def getCurrList(self): return self.currList def setCurrList(self, list): self.currList = list return def setTable(self): return self.SERVICE_MENU_TABLE def listsMainMenu(self, table): printDBG("Kabarety.listsMainMenu") self.currList = [] for num, val in table.items(): item = {'type': 'dir', 'name': 'main-menu', 'category': val, 'title': val, 'icon': ''} self.currList.append(item) def getCategories(self, url): printDBG("Kabarety.getCategories") self.currList = [] query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: printDBG("Kabarety.getCategories exception") return match = re.compile('<b>Kategorie</a><br><br>(.+?)<br><br>', re.DOTALL).findall(data) if len(match) > 0: match2 = re.compile('href="(.+?)">(.+?)</a>').findall(match[0]) if len(match2) > 0: for i in range(len(match2)): title = self.cm.html_entity_decode(match2[i][1]) item = {'type': 'dir', 'name': 'category', 'title': title, 'category': match2[i][0], 'icon': ''} self.currList.append(item) def getFilmTab(self, url, page): printDBG("Kabarety.getFilmTab") self.currList = [] query_data = { 'url': self._getFullUrl(url)+page, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: printDBG("Kabarety.getFilmTab exception") return link = data.replace('\n', '') #MOD match = re.compile('<a class="video-mini" title="(.+?)" href=".+?">.+?<span class="duration".+?<img class="video-mini-img".+?src="http://i.ytimg.com/vi/(.+?)/0.jpg" />').findall(link) if len(match) > 0: for i in range(len(match)): title = self.cm.html_entity_decode(match[i][0]) img = self.IMGURL + match[i][1] + '/0.jpg' item = {'type': 'video', 'title': title, 'page': match[i][1], 'icon': img} self.currList.append(item) match = re.compile('<span><a href=".+?" class="next shadow-main">»</a></span>').findall(data) if len(match) > 0: newpage = str(int(page) + 1) item = {'type': 'dir', 'name': 'nextpage', 'title': 'Następna strona', 'category': url, 'page': newpage, 'icon': ''} self.currList.append(item) def getMovieUrls(self, vID): printDBG("Kabarety.getMovieUrls vID: " + vID) url = 'http://www.youtube.com/watch?v=' + vID tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({'name': item['format'] + '\t' + item['ext'] , 'url':item['url']}) return movieUrls def handleService(self, index, refresh = 0, searchPattern = ''): printDBG("Kabarety.handleService") if 0 == refresh: if len(self.currList) <= index: printDBG( "handleService wrong index: %s, len(self.currList): %d" % (index, len(self.currList)) ) return self.name = None self.title = '' self.category = '' self.page = '' self.icon = '' self.link = '' self.action = '' if -1 == index: printDBG( "Kinomaniak: handleService for first self.category" ) else: item = self.currList[index] if "name" in item: self.name = item['name'] if "title" in item: self.title = item['title'] if "category" in item: self.category = item['category'] if "page" in item: self.page = item['page'] if "icon" in item: self.icon = item['icon'] if "url" in item: self.link = item['url'] if "action" in item: self.action = item['action'] printDBG( "Kabarety: |||||||||||||||||||||||||||||||||||| %s " % item["name"] ) self.currList = [] name = self.name title = self.title category = self.category page = self.page icon = self.icon link = self.link action = self.action if str(page)=='None' or page=='': page = '1' #MAIN MENU if name == None: self.listsMainMenu(self.SERVICE_MENU_TABLE) #NAJNOWSZE elif category == self.setTable()[1]: self.getFilmTab(self.NOW_LINK, page) #NAJLEPSZE elif category == self.setTable()[2]: self.getFilmTab(self.NAJ_LINK, page) #KATEGORIE elif category == self.setTable()[3]: self.getCategories(self.MAINURL) #WYSZUKAJ elif category == self.setTable()[4]: self.getFilmTab(self.MAINURL + '/search/' + searchPattern + '/page:', page) #LISTA TYTULOW elif name == 'category' or name == 'nextpage': url = category + '/page:' self.getFilmTab(url, page)
def __init__(self): self.cm = pCommon.common() self.currList = [] self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value
class HDKinoMir(CBaseHostClass): def __init__(self): CBaseHostClass.__init__(self, { 'history': 'HDKinoMir', 'cookie': 'HDKinoMir.cookie' }) self.USER_AGENT = "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30" self.HEADER = {'User-Agent': self.USER_AGENT, 'Accept': 'text/html'} self.defaultParams = { 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE } self.sortCache = [] self.catCache = [] self.moonwalkParser = MoonwalkParser() self.ytParser = YouTubeParser() self.MAIN_URL = 'http://hdkinomir.com/' self.DEFAULT_ICON_URL = self.getFullIconUrl( '/templates/prokino/images/logo.png') self.MAIN_CAT_TAB = [{ 'category': 'categories', 'title': _('Movie categories'), 'url': self.getMainUrl() }, { 'category': 'search', 'title': _('Search'), 'search_item': True }, { 'category': 'search_history', 'title': _('Search history') }] self.encoding = '' def getPage(self, url, params={}, post_data=None): sts, data = self.cm.getPage(url, params, post_data) if sts and self.encoding == '': self.encoding = self.cm.ph.getSearchGroups(data, 'charset=([^"]+?)"')[0] return sts, data def getFullUrl(self, url): url = url.replace('&', '&') return CBaseHostClass.getFullUrl(self, url) def listMainMenu(self, cItem, category): printDBG("HDKinoMir.listCategories") sts, data = self.getPage(cItem['url']) if not sts: return if 0 == len(self.sortCache): sorData = self.cm.ph.getDataBeetwenMarkers( data, '<form name="news_set_sort"', '/> ', False)[1] sorData = re.compile( "dle_change_sort\('([^']+?)','([^']+?)'\)[^>]*?>([^<]+?)<" ).findall(sorData) for item in sorData: post_data = { 'dlenewssortby': item[0], 'dledirection': item[1], 'set_new_sort': 'dle_sort_cat', 'set_direction_sort': 'dle_direction_cat' } params = {'title': item[2], 'post_data': post_data} self.sortCache.append(params) if 0 == len(self.catCache): catData = self.cm.ph.getDataBeetwenMarkers( data, '<div class="films-category">', '</div> ', False)[1] catData = re.compile('href="([^"]+?)"[^>]*?>([^<]+?)<').findall( catData) for item in catData: params = dict(cItem) params.update({ 'category': category, 'title': item[1], 'url': self.getFullUrl(item[0]) }) self.catCache.append(params) mainMenuData = self.cm.ph.getDataBeetwenMarkers( data, '<div class="top-menu-block">', '</ul>', False)[1] mainMenuData = re.compile('href="([^"]+?)"[^>]*?>([^<]+?)<').findall( mainMenuData) for item in mainMenuData: if item[0] in ['/actors/', '/podborki-filmov.html']: continue params = dict(cItem) params.update({ 'category': category, 'title': item[1], 'url': self.getFullUrl(item[0]) }) self.addDir(params) self.listsTab(self.MAIN_CAT_TAB, {'name': 'category'}) def listContent(self, cItem, category): printDBG("HDKinoMir.listContent") sts, data = self.getPage(cItem['url']) if not sts: return desc = self.cm.ph.getDataBeetwenMarkers( data, '<div class="full-right-detailes">', '<div style="clear:both;">', False)[1] desc = self.cleanHtmlStr(desc) title = cItem['title'] seriesData = self.cm.ph.getAllItemsBeetwenMarkers( data, '<strong class="seria">', '</center>', False) if len(seriesData) > 1: for item in seriesData: url = self.cm.ph.getSearchGroups( item, '<iframe[^>]+?src="([^"]+?)"', 1, True)[0] if url.startswith('//'): url = 'http:' + url params = dict(cItem) params['desc'] = desc params['url'] = url hostName = self.up.getHostName(url) if 'youtube' in hostName and 'list=' in url: params.update({ 'host_name': 'youtube_tray', 'category': category, 'title': self.cleanHtmlStr(item), 'serie_title': title }) self.addDir(params) continue if 1 == self.up.checkHostSupport(url): params['title'] = '{0} - {1}'.format( title, self.cleanHtmlStr(item)) self.addVideo(params) return data = re.compile('<iframe[^>]+?src="([^"]+?)"', re.IGNORECASE).findall(data) for url in data: if url.startswith('//'): url = 'http:' + url params = dict(cItem) params['desc'] = desc params['url'] = url hostName = self.up.getHostName(url) if hostName in [ 'serpens.nl', '37.220.36.15', 'daaidaij.com', 'mastarti.com' ]: hostName = 'moonwalk.cc' if hostName == 'moonwalk.cc' and '/serial/' in url: params.update({'category': category, 'serie_title': title}) season = self.moonwalkParser.getSeasonsList(url) for item in season: param = dict(params) param.update({ 'host_name': 'moonwalk', 'title': item['title'], 'season_id': item['id'], 'url': item['url'] }) self.addDir(param) return if 1 == self.up.checkHostSupport(url): self.addVideo(params) def listEpisodes(self, cItem): printDBG("HDKinoMir.listEpisodes") hostName = cItem['host_name'] if hostName == 'moonwalk': title = cItem['serie_title'] id = cItem['season_id'] episodes = self.moonwalkParser.getEpiodesList(cItem['url'], id) for item in episodes: params = dict(cItem) params.update({ 'title': '{0} - s{1}e{2} {3}'.format(title, id, item['id'], item['title']), 'url': item['url'] }) self.addVideo(params) elif hostName == 'youtube_tray': try: list = self.ytParser.getVideosFromTraylist( cItem['url'], 'video', 1, cItem) except Exception: printExc() return for item in list: if item['category'] != 'video': continue self.addVideo(item) def listItems(self, cItem, category): printDBG("HDKinoMir.listItems") tmp = cItem['url'].split('?') url = tmp[0] if len(tmp) > 1: arg = tmp[1] else: arg = '' page = cItem.get('page', 1) if page > 1: url += 'page/%s/' % page if '' != arg: url += '?' + arg post_data = cItem.get('post_data', None) sts, data = self.getPage(url, {}, post_data) if not sts: return nextPage = False if ('/page/%s/' % (page + 1)) in data: nextPage = True m1 = '<div class="filmposters">' data = self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'filmposters'), ('<div', '>', 'center'), False)[1] data = data.split(m1) if len(data): data[-1] = data[-1].split('<div class="navigation">')[0] for item in data: url = self.cm.ph.getSearchGroups(item, 'href="([^"]+?)"')[0] title = self.cm.ph.getSearchGroups(item, 'alt="([^"]+?)"')[0] if title == '{title}': title = self.cm.ph.getDataBeetwenMarkers( item, '<span>', '</span>', False)[1] title = self.cleanHtmlStr(title) if title == '': continue icon = self.cm.ph.getSearchGroups(item, 'src="([^"]+?)"')[0] desc = self.cleanHtmlStr(item.split('<div class="ribbon">')[-1]) params = dict(cItem) params.update({ 'category': category, 'title': title, 'icon': self.getFullUrl(icon), 'desc': desc, 'url': self.getFullUrl(url) }) self.addDir(params) if nextPage: params = dict(cItem) params.update({ 'title': _('Next page'), 'page': cItem.get('page', 1) + 1 }) self.addDir(params) def listSearchResult(self, cItem, searchPattern, searchType): #searchPattern = 'ОРБИТА' if self.encoding == '': sts, data = self.getPage(self.getMainUrl()) if not sts: return try: searchPattern = searchPattern.decode('utf-8').encode( self.encoding, 'ignore') except Exception: searchPattern = '' post_data = { 'do': 'search', 'subaction': 'search', 'story': searchPattern, 'x': 0, 'y': 0 } sts, data = self.getPage(self.getMainUrl(), post_data=post_data) if not sts: return m1 = '<div class="filmposters">' data = self.cm.ph.getDataBeetwenMarkers(data, m1, '<div class="main">', False)[1] data = data.split(m1) for item in data: title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<h2', '</h2>')[1]) if title == '': title = self.cleanHtmlStr( self.cm.ph.getSearchGroups( item, '''alt=['"]([^'^"]+?)['"]''')[0]) icon = self.getFullIconUrl( self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0]) url = self.getFullUrl( self.cm.ph.getSearchGroups(item, '''href=['"]([^'^"]+?)['"]''')[0]) desc = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '</h2>', '</div>')[1]) if self.cm.isValidUrl(url): params = dict(cItem) params.update({ 'category': 'list_content', 'title': title, 'icon': icon, 'desc': desc, 'url': url }) self.addDir(params) def getLinksForVideo(self, cItem): printDBG("HDKinoMir.getLinksForVideo [%s]" % cItem) urlTab = [] urlTab.append({ 'name': 'Main url', 'url': cItem['url'], 'need_resolve': 1 }) return urlTab def getVideoLinks(self, videoUrl): printDBG("HDKinoMir.getVideoLinks [%s]" % videoUrl) urlTab = [] if 'HDKinoMir.com' in videoUrl: sts, data = self.getPage(videoUrl) if not sts: return [] data = self.cm.ph.getDataBeetwenMarkers( data, '<div class="wbox2 video dark">', '</iframe>', False)[1] videoUrl = self.cm.ph.getSearchGroups( data, '<iframe[^>]+?src="(http[^"]+?)"', 1, True)[0] if videoUrl.startswith('http'): urlTab = self.up.getVideoLinkExt(videoUrl) return urlTab def getFavouriteData(self, cItem): return cItem['url'] def getLinksForFavourite(self, fav_data): return self.getLinksForVideo({'url': fav_data}) def handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') printDBG( "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] " % (name, category)) self.currList = [] #MAIN MENU if name == None: self.listMainMenu( { 'name': 'category', 'icon': self.DEFAULT_ICON_URL, 'url': self.MAIN_URL }, 'show_sort') elif category == 'categories': self.listsTab(self.catCache, self.currItem) elif category == 'show_sort': cItem = dict(self.currItem) cItem['category'] = 'list_items' self.listsTab(self.sortCache, cItem) elif category == 'list_items': self.listItems(self.currItem, 'list_content') elif category == 'list_content': self.listContent(self.currItem, 'list_episodes') elif category == 'list_episodes': self.listEpisodes(self.currItem) #SEARCH elif category in ["search", "search_next_page"]: cItem = dict(self.currItem) cItem.update({'search_item': False, 'name': 'category'}) self.listSearchResult(cItem, searchPattern, searchType) #HISTORIA SEARCH elif category == "search_history": self.listsHistory({ 'name': 'history', 'category': 'search' }, 'desc', _("Type: ")) else: printExc() CBaseHostClass.endHandleService(self, index, refresh)
class AnyFilesVideoUrlExtractor: COOKIEFILE = GetCookieDir('anyfiles.cookie') MAINURL = 'http://video.anyfiles.pl' LOGIN_URL_2 = MAINURL + '/j_security_check' LOGIN_URL = MAINURL + '/Logo?op=l' def __init__(self): self.cm = common() self.ytp = YouTubeParser() self.ytformats = 'mp4' self.defaultParams = { 'header': { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0' }, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': AnyFilesVideoUrlExtractor.COOKIEFILE } self.logged = False def isLogged(self): return self.logged def tryTologin(self): login = config.plugins.iptvplayer.anyfilespl_login.value password = config.plugins.iptvplayer.anyfilespl_password.value printDBG("AnyFilesVideoUrlExtractor.tryTologin login[%s]" % login) if 0 < len(login) and 0 < len(password): #First we need get JSESSIONID params = dict(self.defaultParams) params['load_cookie'] = False sts, data = self.cm.getPage(self.LOGIN_URL, params) #Then we login and get new JSESSIONID params = dict(self.defaultParams) params['header']['Referer'] = self.LOGIN_URL post_data = {'j_username': login, 'j_password': password} sts, data = self.cm.getPage(self.LOGIN_URL_2, params, post_data) # prev sts will be probably False due to ERROR 302, so there # is there is no sens to check this status here sts, data = self.cm.getPage(self.MAINURL, self.defaultParams) if sts and 'href="/Logo?op=w"' in data: self.logged = True return True else: printDBG("AnyFilesVideoUrlExtractor.tryTologin wrong login data") self.logged = False return False def getYTVideoUrl(self, url): printDBG("getYTVideoUrl url[%s]" % url) tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({ 'name': 'YouTube: ' + item['format'] + '\t' + item['ext'], 'url': item['url'].encode('UTF-8') }) return movieUrls def getVideoUrl(self, url): #show adult content #self.cm.addCookieItem(COOKIEFILE, {'name': 'AnyF18', 'value': 'mam18', 'domain': 'video.anyfiles.pl'}, False) if not self.isLogged(): self.tryTologin() # GET VIDEO ID u = url.split('/') vidID = u[-1] match = re.search('([0-9]+?)\,', url) if match: vidID = match.group(1) # get COOKIE sts, data = self.cm.getPage(self.MAINURL + '/videos.jsp?id=' + vidID, self.defaultParams) if not sts: return [] fUrl = self.MAINURL + "/w.jsp?id=%s&width=620&height=349&pos=&skin=0" % vidID COOKIE_JSESSIONID = self.cm.getCookieItem(self.COOKIEFILE, 'JSESSIONID') HEADER = { 'Referer': url, 'Cookie': 'JSESSIONID=' + COOKIE_JSESSIONID, 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0' } request_param = {'header': HEADER} sts, data = self.cm.getPage(fUrl, request_param) if not sts: return [] #document.cookie = "__utdc_8a85608c7ff88b4de47cdc08107a8108=f68082abdaab664660b0c60289346552"+expires+"; path="; match = re.search('document.cookie = "([^"]+?)"', data) if match: printDBG( "========================================================================== B" ) #printDBG(data) printDBG( "========================================================================== C" ) HEADER['Cookie'] = HEADER['Cookie'] + '; ' + match.group(1) HEADER[ 'Referer'] = self.MAINURL + '/flowplaer/flowplayer.commercial-3.2.16.swf' config = CParsingHelper.getSearchGroups( data, 'var flashvars = {[^"]+?config: "([^"]+?)" }', 1)[0] if '' == config: printDBG( "========================================================================== D" ) config = CParsingHelper.getSearchGroups( data, 'src="/?(pcsevlet\?code=[^"]+?)"', 1)[0] if '' != config: printDBG( "========================================================================== E" ) sts, data = self.cm.getPage(self.MAINURL + '/' + config, {'header': HEADER}) if sts: url = CParsingHelper.getSearchGroups( data, "'url':'(http[^']+?mp4)'", 1)[0] if '' != url: return [{'name': 'AnyFiles', 'url': url}] url = CParsingHelper.getSearchGroups( data, "'url':'api:([^']+?)'", 1)[0] if '' != url: return self.getYTVideoUrl( 'http://www.youtube.com/watch?v=' + url) return []
class AnyFilesVideoUrlExtractor: COOKIEFILE = GetCookieDir('anyfiles.cookie') MAINURL = 'http://video.anyfiles.pl' LOGIN_URL_2 = MAINURL + '/j_security_check' LOGIN_URL = MAINURL + '/Logo?op=l' def __init__(self): self.cm = common() self.ytp = YouTubeParser() self.ytformats = 'mp4' self.defaultParams = {'header':{'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0'}, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': AnyFilesVideoUrlExtractor.COOKIEFILE} self.logged = False def isLogged(self): return self.logged def tryTologin(self): login = config.plugins.iptvplayer.anyfilespl_login.value password = config.plugins.iptvplayer.anyfilespl_password.value printDBG("AnyFilesVideoUrlExtractor.tryTologin login[%s]" % login) if 0 < len(login) and 0 < len(password): #First we need get JSESSIONID params = dict(self.defaultParams) params['load_cookie'] = False sts, data = self.cm.getPage(self.LOGIN_URL, params) #Then we login and get new JSESSIONID params = dict(self.defaultParams) params['header']['Referer'] = self.LOGIN_URL post_data = {'j_username':login, 'j_password':password} sts, data = self.cm.getPage(self.LOGIN_URL_2, params, post_data) # prev sts will be probably False due to ERROR 302, so there # is there is no sens to check this status here sts,data = self.cm.getPage(self.MAINURL, self.defaultParams) if sts and 'href="/Logo?op=w"' in data: self.logged = True return True else: printDBG("AnyFilesVideoUrlExtractor.tryTologin wrong login data") self.logged = False return False def getYTVideoUrl(self, url): printDBG("getYTVideoUrl url[%s]" % url) tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({ 'name': 'YouTube: ' + item['format'] + '\t' + item['ext'] , 'url':item['url'].encode('UTF-8') }) return movieUrls def getVideoUrl(self, url): #show adult content #self.cm.addCookieItem(COOKIEFILE, {'name': 'AnyF18', 'value': 'mam18', 'domain': 'video.anyfiles.pl'}, False) if not self.isLogged(): self.tryTologin() # GET VIDEO ID u = url.split('/') vidID = u[-1] match = re.search('([0-9]+?)\,', url ) if match: vidID = match.group(1) # get COOKIE sts, data = self.cm.getPage(self.MAINURL + '/videos.jsp?id=' + vidID, self.defaultParams) if not sts: return [] fUrl = self.MAINURL + "/w.jsp?id=%s&width=620&height=349&pos=&skin=0" % vidID COOKIE_JSESSIONID = self.cm.getCookieItem(self.COOKIEFILE,'JSESSIONID') HEADER = {'Referer' : url, 'Cookie' : 'JSESSIONID=' + COOKIE_JSESSIONID, 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0'} request_param = {'header':HEADER} sts, data = self.cm.getPage(fUrl, request_param) if not sts: return [] #document.cookie = "__utdc_8a85608c7ff88b4de47cdc08107a8108=f68082abdaab664660b0c60289346552"+expires+"; path="; match = re.search('document.cookie = "([^"]+?)"',data) if match: printDBG("========================================================================== B") #printDBG(data) printDBG("========================================================================== C") HEADER['Cookie'] = HEADER['Cookie'] + '; ' + match.group(1) HEADER['Referer'] = self.MAINURL + '/flowplaer/flowplayer.commercial-3.2.16.swf' config = CParsingHelper.getSearchGroups(data, 'var flashvars = {[^"]+?config: "([^"]+?)" }', 1)[0] if '' == config: printDBG("========================================================================== D") config = CParsingHelper.getSearchGroups(data, 'src="/?(pcsevlet\?code=[^"]+?)"', 1)[0] if '' != config: printDBG("========================================================================== E") sts,data = self.cm.getPage( self.MAINURL + '/' + config, {'header': HEADER}) if sts: url = CParsingHelper.getSearchGroups(data, "'url':'(http[^']+?mp4)'", 1)[0] if '' != url: return [{ 'name': 'AnyFiles', 'url': url}] url = CParsingHelper.getSearchGroups(data, "'url':'api:([^']+?)'", 1)[0] if '' != url: return self.getYTVideoUrl('http://www.youtube.com/watch?v='+url) return []
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()
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)
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()
class MusicBox(CBaseHostClass): SERVICE_MENU_TABLE = { 1: "Itunes - Top songs by country", 2: "Itunes - Top albums by country", # 3: "Dezzer - Top Tracks", 4: "Beatport - Top 100", # 5: "Official Charts UK", 6: "Bilboard - The Hot 100", 7: "Bilboard - 200", # 8: "Bilboard - Heatseekers Songs", 9: "Bilboard - Heatseekers Albums", 10: "Bilboard - Hot Pop Songs", 11: "Bilboard - Hot Country Songs", 12: "Bilboard - Hot Country Albums", 13: "Bilboard - Hot Rock Songs", 14: "Bilboard - Hot Rock Albums", 15: "Bilboard - Hot R&B/Hip-Hop Songs", 16: "Bilboard - Hot R&B/Hip-Hop Albums", 17: "Bilboard - Hot Dance/Electronic Songs", 18: "Bilboard - Hot Dance/Electronic Albums", 19: "Bilboard - Hot Latin Songs", 20: "Bilboard - Hot Latin Albums", 21: "Last.fm - Moja lista", } def __init__(self): CBaseHostClass.__init__(self) self.ytformats = config.plugins.iptvplayer.ytformat.value self.ytp = YouTubeParser() self.lastfm_username = config.plugins.iptvplayer.MusicBox_login.value self.usePremiumAccount = config.plugins.iptvplayer.MusicBox_premium.value def setTable(self): return self.SERVICE_MENU_TABLE def listsMainMenu(self, table): for num, val in table.items(): params = { 'name': 'main-menu', 'category': val, 'title': val, 'icon': '' } self.addDir(params) ############################################################################### # Itunes ############################################################################### def Itunes_countries_menu(self, url, mode): country_name = [ "Albania", "Algeria", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Botswana", "Brazil", "British Virgin Islands", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Cambodia", "Canada", "Cape Verde", "Cayman Islands", "Chad", "Chile", "China", "Colombia", "Congo, Republic of the", "Costa Rica", "Croatia", "Cyprus", "Czech Republic", "Denmark", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Estonia", "Fiji", "Finland", "France", "Gambia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea-Bissau", "Guyana", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Korea, Republic Of", "Kuwait", "Kyrgyzstan", "Lao, People's Democratic Republic", "Latvia", "Lebanon", "Liberia", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Mali", "Malta", "Mauritania", "Mauritius", "Mexico", "Micronesia, Federated States of", "Moldova", "Mongolia", "Montserrat", "Mozambique", "Namibia", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "South Africa", "Spain", "Sri Lanka", "St. Kitts and Nevis", "St. Lucia", "St. Vincent and The Grenadines", "Suriname", "Swaziland", "Sweden", "Switzerland", "São Tomé and Príncipe", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Venezuela", "Vietnam", "Yemen", "Zimbabwe" ] country_code = [ "al", "dz", "ao", "ai", "ag", "ar", "am", "au", "at", "az", "bs", "bh", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bw", "br", "vg", "bn", "bg", "bf", "kh", "ca", "cv", "ky", "td", "cl", "cn", "co", "cg", "cr", "hr", "cy", "cz", "dk", "dm", "do", "ec", "eg", "sv", "ee", "fj", "fi", "fr", "gm", "de", "gh", "gr", "gd", "gt", "gw", "gy", "hn", "hk", "hu", "is", "in", "id", "ie", "ir", "it", "jm", "jp", "jo", "kz", "ke", "kr", "kw", "kg", "la", "lv", "lb", "lr", "lt", "lu", "mo", "mk", "mg", "mw", "my", "ml", "mt", "mr", "mu", "mx", "fm", "md", "mn", "ms", "mz", "na", "np", "nl", "nz", "ni", "ne", "ng", "no", "om", "pk", "pw", "pa", "pg", "py", "pe", "ph", "pl", "pt", "qa", "ro", "ru", "sa", "sn", "sc", "sl", "sg", "sk", "si", "sb", "za", "es", "lk", "kn", "lc", "vc", "sr", "sz", "se", "ch", "st", "tw", "tj", "tz", "th", "tt", "tn", "tr", "tm", "tc", "ug", "ua", "ae", "gb", "us", "uy", "uz", "ve", "vn", "ye", "zw" ] for x in range(0, len(country_name)): if country_code[x] not in [ "al", "dz", "ao", "bj", "bt", "td", "cn", "cg", "gy", "is", "jm", "kr", "kw", "lr", "mk", "mg", "mw", "ml", "mr", "ms", "pk", "pw", "sn", "sc", "sl", "sb", "lc", "vc", "sr", "st", "tz", "tn", "tc", "uy", "ye" ]: #Countries without music store url = country_code[x] title = country_name[x] icon = 'http://www.geonames.org/flags/x/' + country_code[ x] + '.gif' desc = title if mode == 'song': params = { 'name': 'Itunes_track_charts', 'title': title, 'page': url, 'icon': icon, 'plot': desc } self.addDir(params) elif mode == 'album': params = { 'name': 'Itunes_album_charts', 'title': title, 'page': url, 'icon': icon, 'plot': desc } self.addDir(params) def Itunes_track_charts(self, url): country = url sts, data = self.cm.getPage( 'https://itunes.apple.com/%s/rss/topsongs/limit=100/explicit=true/json' % country, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['feed']['entry'] for x in range(len(data)): item = data[x] artist = item['im:artist']['label'] track_name = item['im:name']['label'] try: iconimage = item['im:image'][2]['label'] except Exception: iconimage = '' plot = '' search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = { 'title': str(x + 1) + '. ' + artist + '- ' + track_name, 'page': search_string, 'icon': iconimage, 'plot': plot } self.addVideo(params) except Exception: printExc() # wypisz co poszło nie tak def Itunes_album_charts(self, url): country = url sts, data = self.cm.getPage( 'https://itunes.apple.com/%s/rss/topalbums/limit=100/explicit=true/json' % country, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['feed']['entry'] for x in range(len(data)): item = data[x] artist = item['im:artist']['label'] album_name = item['im:name']['label'] idx = item['id']['attributes']['im:id'] try: iconimage = item['im:image'][2]['label'] except Exception: iconimage = '' plot = '' params = { 'name': 'Itunes_list_album_tracks', 'title': str(x + 1) + '. ' + artist + '- ' + album_name, 'page': idx, 'album': album_name, 'country': country, 'icon': iconimage, 'plot': plot } self.addDir(params) except Exception: printExc() # wypisz co poszło nie tak def Itunes_list_album_tracks(self, url, album, country): sts, data = self.cm.getPage( 'https://itunes.apple.com/lookup?id=' + url + '&country=' + country + '&entity=song&limit=200', {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['results'] for x in range(1, len(data)): item = data[x] artist = item['artistName'] track_name = item['trackName'] try: iconimage = item['artworkUrl100'] except Exception: iconimage = '' plot = '' search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = { 'title': artist + '- ' + track_name, 'page': search_string, 'icon': iconimage, 'plot': plot } self.addVideo(params) except Exception: printExc() ############################################################################### # Beatport ############################################################################### def Beatport_top100(self, url): sts, data = self.cm.getPage(url) if not sts: return match = re.findall( '<li class="bucket-item track">.*?<img.*?data-src="(.*?)".*?>.*?</a>.*?<div class="buk-track-num">(.+?)</div>.*?<p class="buk-track-title">.*?<a.*?>.*?<span class="buk-track-primary-title">(.*?)</span>.*?<span class="buk-track-remixed">(.*?)</span>.*?</a>.*?</p>.*?<p class="buk-track-artists">(.*?)</p>.*?<p class="buk-track-remixers">(.*?)</p>.*?</li>', data, re.DOTALL) if len(match) > 0: for i in range(len(match)): try: track_number = match[i][1] title_primary = (re.sub( '\s+', ' ', (re.sub('<[^>]*>', '', match[i][2])))).replace( "&", "&").replace("'", "'") remixed = '(' + (re.sub( '\s+', ' ', (re.sub('<[^>]*>', '', match[i][3])))).replace( "&", "&").replace("'", "'") + ')' track_name = title_primary + ' ' + remixed artist = re.sub('<[^>]*>', '', match[i][4]) artist = re.sub('\s+', ' ', artist.strip()) artist = artist.replace("&", "&").replace("'", "'") iconimage = match[i][0].replace('/95x95/', '/300x300/') search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = { 'title': track_number + '. ' + artist + '- ' + track_name, 'page': search_string, 'icon': iconimage, 'plot': '' } self.addVideo(params) except Exception: pass ############################################################################### # Bilboard ############################################################################### def Billboard_charts(self, url): sts, data = self.cm.getPage(url, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['query']['results']['item'] for x in range(0, len(data)): item = data[x] name = item['title'] artist = item['artist'] track_name = item['chart_item_title'] search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = { 'title': name + ' - ' + artist, 'page': search_string, 'icon': '', 'plot': '' } self.addVideo(params) except Exception: printExc() # wypisz co poszło nie tak def Billboard_chartsalbums(self, url): sts, data1 = self.cm.getPage(url, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data1))['query']['results']['item'] for x in range(0, len(data)): item = data[x] name = item['title'] artist = item['artist'] album_name = item['chart_item_title'] params = { 'name': 'List_album_tracks', 'title': name + ' - ' + artist, 'page': 0, 'artist': artist, 'album': album_name, 'icon': '', 'plot': '' } self.addDir(params) except Exception: printExc() # wypisz co poszło nie tak ############################################################################### # Szukanie tytułu z albumow ############################################################################### def List_album_tracks(self, url, artist, album): if url != 0: sts, data = self.cm.getPage( 'http://ws.audioscrobbler.com/2.0/?method=album.getInfo&mbid=' + url + '&api_key=' + audioscrobbler_api_key + '&format=json', {'header': HEADER}) if not sts: return else: sts, data = self.cm.getPage( 'http://ws.audioscrobbler.com/2.0/?method=album.getInfo&artist=' + urllib.quote(artist) + '&album=' + urllib.quote(album) + '&api_key=' + audioscrobbler_api_key + '&format=json', {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['album']['tracks']['track'] for x in range(0, len(data)): item = data[x] artist = item['artist']['name'] track_name = item['name'] try: iconimage = item['album']['image'][3]['#text'] except Exception: iconimage = '' search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = { 'title': track_name + ' - ' + artist, 'page': search_string, 'icon': iconimage, 'plot': '' } self.addVideo(params) except Exception: printExc() # wypisz co poszło nie tak ############################################################################### # Moja playlista z Last.fm ############################################################################### def Lastfmlist(self): if False == self.usePremiumAccount: self.sessionEx.waitForFinishOpen(MessageBox, 'Wpisz login do last.fm.', type=MessageBox.TYPE_INFO, timeout=10) else: url = 'http://ws.audioscrobbler.com/2.0/?method=user.getPlaylists&user='******'&api_key=' + audioscrobbler_api_key + '&format=json' sts, data = self.cm.getPage(url, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['playlists']['playlist'] for x in range(len(data)): item = data[x] playlist_name = item['title'] playlist_id = item['id'] params = { 'name': 'Lastfmlist_track', 'title': playlist_name, 'artist': playlist_id } self.addDir(params) except Exception: printExc() # wypisz co poszło nie tak def Lastfmlist_track(self, artist): playlist_id = "lastfm://playlist/" + artist url = 'http://ws.audioscrobbler.com/2.0/?method=playlist.fetch&playlistURL=' + playlist_id + '&api_key=' + audioscrobbler_api_key + '&format=json' print url sts, data = self.cm.getPage(url, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['playlist']['trackList']['track'] print data for x in range(len(data)): item = data[x] artist = item['creator'] track_name = item['title'] try: iconimage = item['image'] except Exception: iconimage = '' search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = { 'title': track_name + ' - ' + artist, 'page': search_string, 'icon': iconimage, 'plot': '' } self.addVideo(params) except Exception: printExc() # wypisz co poszło nie tak ############################################################################### # Szukanie linku do materiału na youtube ############################################################################### def Search_videoclip(self, url): sts, data = self.cm.getPage( "https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&q=" + url + "&type=Music&maxResults=1&key=" + youtube_api_key) if not sts: return [] match = re.compile('"videoId": "([^"]+?)"').findall(data) videoUrls = [] for item in match: video_path = "https://www.youtube.com/watch?v=" + item videoUrls = self.getLinksForVideo(video_path) return videoUrls def getLinksForVideo(self, url): printDBG("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): val = self.cm.ph.getSearchGroups('|%s|' % itemLink['format'], '[^0-9]([0-9]+?)[^0-9]')[0] if '' == val: return 0 return int(val) 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 handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') if 0 == refresh: if len(self.currList) <= index: printDBG( "handleService wrong index: %s, len(self.currList): %d" % (index, len(self.currList))) return if -1 == index: # use default value self.currItem = {"name": None} printDBG("handleService for first self.category") else: self.currItem = self.currList[index] name = self.currItem.get("name", '') title = self.currItem.get("title", '') category = self.currItem.get("category", '') page = self.currItem.get("page", '') icon = self.currItem.get("icon", '') album = self.currItem.get("album", '') country = self.currItem.get("country", '') artist = self.currItem.get("artist", '') printDBG("handleService: |||||||||||||||||||||||||||||||||||| [%s] " % name) self.currList = [] if str(page) == 'None' or page == '': page = '0' #MAIN MENU if name is None: self.listsMainMenu(self.SERVICE_MENU_TABLE) #LISTA # "Itunes - Top songs by country" elif category == self.setTable()[1]: self.Itunes_countries_menu('http://www.geonames.org/flags/x/', 'song') # "Itunes - Top albums by country" elif category == self.setTable()[2]: self.Itunes_countries_menu('http://www.geonames.org/flags/x/', 'album') # "Beatport - Top 100" elif category == self.setTable()[4]: self.Beatport_top100('https://pro.beatport.com/top-100') # "Bilboard - The Hot 100" elif category == self.setTable()[6]: item = 'hot-100' self.Billboard_charts( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - 200" elif category == self.setTable()[7]: item = 'billboard-200' self.Billboard_charts( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,200)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Heatseekers Albums" elif category == self.setTable()[9]: item = 'heatseekers-albums' self.Billboard_chartsalbums( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,200)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Pop Songs" elif category == self.setTable()[10]: item = 'pop-songs' self.Billboard_charts( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Country Songs" elif category == self.setTable()[11]: item = 'country-songs' self.Billboard_charts( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Country Albums" elif category == self.setTable()[12]: item = 'country-albums' self.Billboard_chartsalbums( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Rock Songs" elif category == self.setTable()[13]: item = 'rock-songs' self.Billboard_charts( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Rock Albums" elif category == self.setTable()[14]: item = 'rock-albums' self.Billboard_chartsalbums( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot R&B/Hip-Hop Songs" elif category == self.setTable()[15]: item = 'r-b-hip-hop-songs' self.Billboard_charts( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot R&B/Hip-Hop Albums" elif category == self.setTable()[16]: item = 'r-b-hip-hop-albums' self.Billboard_chartsalbums( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Dance/Electronic Songs" elif category == self.setTable()[17]: item = 'dance-electronic-songs' self.Billboard_charts( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Dance/Electronic Albums" elif category == self.setTable()[18]: item = 'dance-electronic-albums' self.Billboard_chartsalbums( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Latin Songs" elif category == self.setTable()[19]: item = 'latin-songs' self.Billboard_charts( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Latin Albums" elif category == self.setTable()[20]: item = 'latin-albums' self.Billboard_chartsalbums( 'http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') elif category == self.setTable()[21]: self.Lastfmlist() ########### elif name == 'Itunes_track_charts': self.Itunes_track_charts(page) elif name == 'Itunes_album_charts': self.Itunes_album_charts(page) elif name == 'Itunes_list_album_tracks': self.Itunes_list_album_tracks(page, album, country) elif name == 'List_album_tracks': self.List_album_tracks(page, artist, album) elif name == 'Lastfmlist_track': self.Lastfmlist_track(artist)
def __init__(self): CBaseHostClass.__init__(self) self.ytformats = config.plugins.iptvplayer.ytformat.value self.ytp = YouTubeParser() self.lastfm_username = config.plugins.iptvplayer.MusicBox_login.value self.usePremiumAccount = config.plugins.iptvplayer.MusicBox_premium.value
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)
class MaxtvGO(CBaseHostClass): def __init__(self): CBaseHostClass.__init__(self, {'history':'maxtvgo.com', 'cookie':'maxtvgo.com.cookie'}) self.DEFAULT_ICON_URL = 'https://maxtvgo.com/images/logo_37.png' self.USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0' self.MAIN_URL = 'https://maxtvgo.com/' self.HTTP_HEADER = {'User-Agent': self.USER_AGENT, 'DNT':'1', 'Accept': 'text/html', 'Accept-Encoding':'gzip, deflate', 'Referer':self.getMainUrl(), 'Origin':self.getMainUrl()} self.AJAX_HEADER = dict(self.HTTP_HEADER) self.AJAX_HEADER.update( {'X-Requested-With': 'XMLHttpRequest', 'Accept-Encoding':'gzip, deflate', 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8', 'Accept':'application/json, text/javascript, */*; q=0.01'} ) self.defaultParams = {'header':self.HTTP_HEADER, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE} self.MAIN_CAT_TAB = [{'category':'list_items', 'title': 'MaxTVGo', 'url':self.getFullUrl('/api/videos.php?action=find')}, {'category':'list_yt_channel', 'title': 'Max Kolonko - MaxTV', 'url':'https://www.youtube.com/user/Media2000Corp/videos' }, {'category':'list_yt_channel', 'title': 'MaxTVNews', 'url':'https://www.youtube.com/user/MaxTVTUBE/videos'}, {'category':'search', 'title': _('Search'), 'search_item':True, }, {'category':'search_history', 'title': _('Search history'), } ] self.ytp = YouTubeParser() self.loggedIn = None self.login = '' self.password = '' def getPage(self, baseUrl, addParams = {}, post_data = None): if addParams == {}: addParams = dict(self.defaultParams) origBaseUrl = baseUrl baseUrl = self.cm.iriToUri(baseUrl) def _getFullUrl(url): if self.cm.isValidUrl(url): return url else: return urlparse.urljoin(baseUrl, url) addParams['cloudflare_params'] = {'domain':self.up.getDomain(baseUrl), 'cookie_file':self.COOKIE_FILE, 'User-Agent':self.USER_AGENT, 'full_url_handle':_getFullUrl} return self.cm.getPageCFProtection(baseUrl, addParams, post_data) def listMainMenu(self, cItem, nextCategory): printDBG("MaxtvGO.listMainMenu") self.listsTab(self.MAIN_CAT_TAB, cItem) def getFullIconUrl(self, url): url = CBaseHostClass.getFullIconUrl(self, url.strip()) if url == '': return '' cookieHeader = self.cm.getCookieHeader(self.COOKIE_FILE) return strwithmeta(url, {'Cookie':cookieHeader, 'User-Agent':self.USER_AGENT, 'Referer':self.getMainUrl()}) def listItems(self, cItem, nextCategory): printDBG("MaxtvGO.listItems [%s]" % cItem) sts, data = self.getPage(cItem['url']) if not sts: return try: data = byteify(json.loads(data)) if data.get('error') != None: SetIPTVPlayerLastHostError(str(data['error']['message'])) for item in data['data']: sTitle = self.cleanHtmlStr(item['name']) subItems = [] for it in item['videos']: title = self.cleanHtmlStr(it['title']) #icon = self.getFullIconUrl(it['image']) icon = str(it.get('vimeoPosterId', '')) if icon != '': icon = 'http://i.vimeocdn.com/video/%s.jpg?mw=300' % icon url = self.getFullUrl('video.php?film=') + it['code'] params = dict(cItem) params.update({'type':'video', 'good_for_fav':True, 'title':title, 'url':url, 'icon':icon}) subItems.append(params) if len(subItems): params = dict(cItem) params.update({'category':nextCategory, 'good_for_fav':False, 'title':sTitle, 'sub_items':subItems}) self.addDir(params) except Exception: printExc() if self.loggedIn != True and 0 == len(self.currList): msg = _('The host %s requires registration. \nPlease fill your login and password in the host configuration. Available under blue button.' % self.getMainUrl()) GetIPTVNotify().push(msg, 'error', 10) def listYTChannel(self, cItem): printDBG('MaxtvGO.getVideos cItem[%s]' % (cItem)) category = cItem.get("category", '') url = cItem.get("url", '') page = cItem.get("page", '1') 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' params = dict(cItem) self.currList = self.ytp.getVideosFromChannelList(url, category, page, params) for idx in range(len(self.currList)): if self.currList[idx].get('type', '') == 'video': self.currList[idx]['good_for_fav'] = True def getLinksForVideo(self, cItem): printDBG("MaxtvGO.getLinksForVideo [%s]" % cItem) if 1 == self.up.checkHostSupport(cItem.get('url', '')): videoUrl = cItem['url'].replace('youtu.be/', 'youtube.com/watch?v=') return self.up.getVideoLinkExt(videoUrl) self.tryTologin() retTab = [] sts, data = self.getPage(cItem['url']) if not sts: return cookieHeader = self.cm.getCookieHeader(self.COOKIE_FILE) tmp = self.cm.ph.getDataBeetwenMarkers(data, '<video', '</video>')[1] tmp = self.cm.ph.getAllItemsBeetwenMarkers(tmp, '<source', '>') for item in tmp: url = self.getFullUrl(self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0]) if not self.cm.isValidUrl(url): continue type = self.getFullUrl(self.cm.ph.getSearchGroups(item, '''type=['"]([^'^"]+?)['"]''')[0]).lower() if 'mp4' in type: url = strwithmeta(self.getFullUrl(url), {'Cookie':cookieHeader, 'User-Agent':self.USER_AGENT, 'Referer':cItem['url']}) retTab.append({'name':'direct', 'url':url, 'need_resolve':0}) else: printDBG("Unknown source: [%s]" % item) data = self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'player'), ('</div', '>'), False)[1] videoUrl = self.getFullUrl(self.cm.ph.getSearchGroups(data, '''<iframe[^>]+?src=['"]([^"^']+?)['"]''', 1, True)[0], self.cm.meta['url']) if videoUrl != '': videoUrl = strwithmeta(videoUrl, {'User-Agent':self.USER_AGENT, 'Referer':self.cm.meta['url']}) retTab.extend(self.up.getVideoLinkExt(videoUrl)) return retTab def listSearchResult(self, cItem, searchPattern, searchType): printDBG("MaxtvGO.listSearchResult cItem[%s], searchPattern[%s] searchType[%s]" % (cItem, searchPattern, searchType)) self.tryTologin() cItem = dict(cItem) cItem['url'] = self.getFullUrl('/api/videos.php?action=find&fullText=') + urllib.quote_plus(searchPattern) self.listItems(cItem, 'sub_items') def tryTologin(self): printDBG('tryTologin start') if None == self.loggedIn or self.login != config.plugins.iptvplayer.maxtvgo_login.value or\ self.password != config.plugins.iptvplayer.maxtvgo_password.value: self.login = config.plugins.iptvplayer.maxtvgo_login.value self.password = config.plugins.iptvplayer.maxtvgo_password.value rm(self.COOKIE_FILE) self.loggedIn = False if '' == self.login.strip() or '' == self.password.strip(): return False sts, data = self.getPage(self.getFullUrl('/login.php')) if not sts: return False sts, data = self.cm.ph.getDataBeetwenNodes(data, ('<form', '>', 'login'), ('</form', '>')) if not sts: return False actionUrl = self.getFullUrl(self.cm.ph.getSearchGroups(data, '''action=['"]([^'^"]+?)['"]''')[0]) data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<input', '>') post_data = {} for item in data: name = self.cm.ph.getSearchGroups(item, '''name=['"]([^'^"]+?)['"]''')[0] value = self.cm.ph.getSearchGroups(item, '''value=['"]([^'^"]+?)['"]''')[0] post_data[name] = value post_data.update({'email':self.login, 'pass':self.password}) httpParams = dict(self.defaultParams) httpParams['header'] = dict(httpParams['header']) httpParams['header']['Referer'] = self.getFullUrl('/index.php') sts, data = self.cm.getPage(actionUrl, httpParams, post_data) if sts and 'logout.php' in data: printDBG('tryTologin OK') self.loggedIn = True else: self.sessionEx.open(MessageBox, _('Login failed.'), type = MessageBox.TYPE_ERROR, timeout = 10) printDBG('tryTologin failed') return self.loggedIn def getArticleContent(self, cItem, data=None): printDBG("MaxtvGO.getArticleContent [%s]" % cItem) self.tryTologin() if self.up.getDomain(cItem['url']) not in self.up.getDomain(self.getMainUrl()): return [] sts, data = self.getPage(cItem['url']) if not sts: return [] videoID = self.cm.ph.getSearchGroups(data, '''(<input[^>]+?videoID[^>]+?>)''', 1, True)[0] videoID = self.cm.ph.getSearchGroups(videoID, '''\svalue=['"]([^'^"]+?)['"]''', 1, True)[0] if videoID == '': return [] otherInfo = {} retTab = [] desc = [] desc = self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'chat_round'), ('<div', '>', 'CommentsSection'))[1] desc = [self.cleanHtmlStr(desc.replace('</p>', '[/br]')) + '[/br][/br]'] icon = self.cm.ph.getDataBeetwenNodes(data, ('<video', '>'), ('</video', '>'))[1] icon = self.getFullIconUrl(self.cm.ph.getSearchGroups(icon, '''poster=['"]([^'^"]+?)['"]''')[0]) #icon = '' title = self.cleanHtmlStr(self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'video-title'), ('</p', '>'), False)[1]) urlBase = self.getFullUrl('/api/comments.php?action=get&videoID=%s' % videoID) try: for page in range(4): url = urlBase if page > 0: url += '&page=%s' % page sts, data = self.getPage(url) if sts: data = byteify(json.loads(data)) for item in data['data']: author = self.cleanHtmlStr(item['nick']) date = self.cleanHtmlStr(item['date']) text = self.cleanHtmlStr(item['text']) desc.append('%s | %s[/br]%s[/br]' % (date, author, text)) printDBG("============================================================================") printDBG('%s\t%s\n%s\n' % (author, date, text)) except Exception: printExc() desc = '------------------------------------------------------------------------------[/br]'.join(desc) if title == '': title = cItem['title'] if desc == '': desc = cItem.get('desc', '') if icon == '': icon = cItem.get('icon', self.DEFAULT_ICON_URL) return [{'title':self.cleanHtmlStr( title ), 'text': self.cleanHtmlStr( desc ), 'images':[{'title':'', 'url':self.getFullIconUrl(icon)}], 'other_info':otherInfo}] def handleService(self, index, refresh = 0, searchPattern = '', searchType = ''): printDBG('handleService start') self.tryTologin() CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') mode = self.currItem.get("mode", '') printDBG( "handleService: || name[%s], category[%s] " % (name, category) ) self.currList = [] #MAIN MENU if name == None: self.listMainMenu({'name':'category'}, 'list_genres') elif category == 'list_filters': self.listFilters(self.currItem, 'list_items') elif category == 'list_items': self.listItems(self.currItem, 'sub_items') elif category == 'list_yt_channel': self.listYTChannel(self.currItem) elif category == 'sub_items': self.currList = self.currItem.get('sub_items', []) #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 diffanime: HOST = 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110621 Mandriva Linux/1.9.2.18-0.1mdv2010.2 (2010.2) Firefox/3.6.18' HEADER = {'User-Agent': HOST, 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'} MAINURL = 'http://diff-anime.pl' SERVICE_MENU_TABLE = { 1: "Lista anime (alfabetycznie)", # 2: "Lista anime (wg. gatunku)", 2: "Ranking", 3: "Ulubione", 4: "Aktualności" } def __init__(self): self.up = urlparser.urlparser() self.cm = pCommon.common() self.sessionEx = MainSessionWrapper() self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value # Temporary data self.currList = [] self.currItem = {} # Login data self.COOKIEFILE = GetCookieDir('Diff-anime.cookie') self.usePremiumAccount = config.plugins.iptvplayer.diffanime_premium.value self.username = config.plugins.iptvplayer.diffanime_login.value self.password = config.plugins.iptvplayer.diffanime_password.value def getCurrList(self): return self.currList def setCurrList(self, list): self.currList = list def getCurrItem(self): return self.currItem def setCurrItem(self, item): self.currItem = item # Login in to the site def requestLoginData(self): if False == self.usePremiumAccount: printDBG("diffanime niezalogowany") else: self.usePremiumAccount = False url = self.MAINURL query_data = {'url': url, 'header': self.HEADER, 'use_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIEFILE, 'return_data': True} postdata = {'user_name': self.username, 'user_pass': self.password, 'remember_me': 'y', "login": "******"} try: data = self.cm.getURLRequestData(query_data, postdata) except: printDBG("diffanime requestLoginData exception") return if 'Wyloguj' in data: printDBG("diffanime Notification(" + self.username + ", Zostales poprawnie zalogowany)") self.usePremiumAccount = True else: self.sessionEx.waitForFinishOpen(MessageBox, 'Błąd logowania. Sprawdź dane.\nlogin - ' + self.username + ' \nhasło - ' + self.password, type=MessageBox.TYPE_INFO, timeout=10) printDBG("diffanime Notification(Blad logowania)") # end login def addDir(self, params): params['type'] = 'category' self.currList.append(params) return def addVideo(self, params): params['type'] = 'video' self.currList.append(params) return def setTable(self): return self.SERVICE_MENU_TABLE # Get YT link def getYTVideoUrl(self, url): printDBG("getYTVideoUrl url[%s]" % url) tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({'name': item['format'] + '\t' + item['ext'], 'url': item['url']}) return movieUrls def getVideoUrlforYTube(self, url): printDBG("getVideoUrl url[%s]" % url) query_data = {'url': url, 'use_host': True, 'host': self.HOST, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: printDBG('getVideoUrl exception') return '' match = re.search('src="//www.youtube.com/(.+?)"', data) if match: printDBG('www.youtube.com/' + match.group(1)) return self.getYTVideoUrl('www.youtube.com/' + match.group(1)) else: printDBG('nie znaleziono YT link') return '' # end Get YT link # Get mp4 link def getVideoUrl(self, url): printDBG("getVideoUrl url[%s]" % url) query_data = {'url': url, 'use_host': True, 'host': self.HOST, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: printDBG('getVideoUrl exception') return '' match = re.search("'file': '(.+?)',", data) if match: return match.group(1) else: printDBG('nie znaleziono mp4 link') return '' # end Get mp4 link def listsMainMenu(self, table): query_data = {'url': self.MAINURL + '/newsy', 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: printDBG('listAbcItem exception') return match = re.compile("div class='sRight'><div class='panel news'>(.+?)<div class='left'><div>Czytań:", re.DOTALL).findall(data) if len(match) > 0: match2 = re.search(".png' alt=([^<]+?)class='news-category'", match[0]) if match2: plot = match2.group(1) else: plot = '' match3 = re.search("class='news-category' />([^<]+?)</div>", match[0]) if match3: plot2 = match3.group(1) else: plot2 = '' icon = re.compile("<div class='content'><img src='(.+?)' alt='").findall(match[0]) for num, val in table.items(): params = {'name': 'main-menu', 'category': val, 'title': val, 'icon': self.MAINURL + icon[0], 'plot': self.cm.html_entity_decode(plot + plot2)} self.addDir(params) def listsABCMenu(self, table): for i in range(len(table)): params = {'name': 'abc-menu', 'category': table[i], 'title': table[i], 'icon': ''} self.addDir(params) # "AKTUALNOŚCI" def getlistsNews(self, url): query_data = {'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: printDBG('listsGenre EXCEPTION') r2 = re.compile("<div class='head'><h2><a href='/news/(.+?)'>(.+?)</a>").findall(data) if len(r2) > 0: for i in range(len(r2)): value = r2[i] title = self.cm.html_entity_decode(value[1]) data = self.MAINURL + '/news/' + value[0] data2 = self.cm.getURLRequestData({'url': data, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True}) value = re.search("<div class='content'><img src='(.+?)' alt='(.+?)' class='news-category' />(.+?).<br />", data2) if value: icon = self.MAINURL + value.group(1) plot = self.cm.html_entity_decode(value.group(2) + value.group(3)) else: icon = '' plot = '' params = {'name': 'news', 'title': title, 'icon': icon, 'plot': plot, 'page': data} self.addVideo(params) # "ULUBIONE" def getlistsUlubione(self, url): query_data = {'url': url + '/odcinki', 'use_host': True, 'host': self.HOST, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: printDBG('listsGenre EXCEPTION') r = re.compile("<div id='pUAL' class='panel pDef'>(.+?)<div id='footer'>", re.DOTALL).findall(data) if len(r) > 0: x1 = re.compile("W trakcie<(.+?)>Ukończone<", re.DOTALL).findall(data) if len(x1) > 0: rx1 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall(x1[0]) if len(rx1) > 0: for i in range(len(rx1)): value = rx1[i] title = self.cm.html_entity_decode("W trakcie - " + value[1]) page = self.MAINURL + value[0] params = {'name': 'ulubione', 'title': title, 'page': page, 'icon': ''} self.addDir(params) x2 = re.compile("Ukończone<(.+?)>Wstrzymane<", re.DOTALL).findall(data) if len(x2) > 0: rx2 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall(x2[0]) if len(rx2) > 0: for i in range(len(rx2)): value = rx2[i] title = self.cm.html_entity_decode("Ukończone - " + value[1]) page = self.MAINURL + value[0] params = {'name': 'ulubione', 'title': title, 'page': page, 'icon': ''} self.addDir(params) x3 = re.compile("Wstrzymane<(.+?)>Porzucone<", re.DOTALL).findall(data) if len(x3) > 0: rx3 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall(x3[0]) if len(rx3) > 0: for i in range(len(rx3)): value = rx3[i] title = self.cm.html_entity_decode("Wstrzymane - " + value[1]) page = self.MAINURL + value[0] params = {'name': 'ulubione', 'title': title, 'page': page, 'icon': ''} self.addDir(params) x4 = re.compile("Porzucone<(.+?)>W planach<", re.DOTALL).findall(data) if len(x4) > 0: rx4 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall(x4[0]) if len(rx4) > 0: for i in range(len(rx4)): value = rx4[i] title = self.cm.html_entity_decode("Porzucone - " + value[1]) page = self.MAINURL + value[0] params = {'name': 'ulubione', 'title': title, 'page': page, 'icon': ''} self.addDir(params) x5 = re.compile("W planach<(.+?)='footer'>", re.DOTALL).findall(data) if len(x5) > 0: rx5 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall(x5[0]) if len(rx5) > 0: for i in range(len(rx5)): value = rx5[i] title = self.cm.html_entity_decode("W planach - " + value[1]) page = self.MAINURL + value[0] params = {'name': 'ulubione', 'title': title, 'page': page, 'icon': ''} self.addDir(params) # "RANKING" def getlistsRanks(self, url): query_data = {'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: printDBG('listsGenre EXCEPTION') r = re.compile("<h2>Ranking anime</h2>(.+?)</table>", re.DOTALL).findall(data) if len(r) > 0: r2 = re.compile("<td class='td2'><a href='/(.+?)'><img src='(.+?)' class='img' /></a><div class='con'><a href='(.+?)'>(.+?)</a><p>").findall(r[0]) if len(r2) > 0: for i in range(len(r2)): value = r2[i] title = self.cm.html_entity_decode(value[3]) page = self.MAINURL + value[2] icon = self.MAINURL + value[1] params = {'name': 'ranks', 'title': title, 'page': page, 'icon': icon} self.addDir(params) # "KATEGORIE" def getlistsGenre(self, url): query_data = {'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: printDBG('listsGenre EXCEPTION') r = re.compile("</div><div id='pSettings' class='panel'>(.+?)</div></div>", re.DOTALL).findall(data) if len(r) > 0: r2 = re.compile("<a href='(.+?)'>(.+?)</a>").findall(r[0]) if len(r2) > 0: for i in range(len(r2)): value = r2[i] title = self.cm.html_entity_decode(value[1]) page = value[0] + '&rowstart=00' params = {'name': 'genset', 'title': title, 'page': page, 'plot': title, 'icon': ''} self.addDir(params) # ANIME TITLES def getAnimeList(self, url): query_data = {'url': self.MAINURL + url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: printDBG('getAnimeList EXCEPTION') nextPage = False if -1 != data.find("div class='pagenav") and -1 != data.find("class='img"): nextPage = True else: nextPage = False r = re.compile("</div><div id='pSeries' class='panel'>(.+?)<div id='footer'>", re.DOTALL).findall(data) if len(r) > 0: r2 = re.compile("</a><div class='con'><a href='/(.+?)'>(.+?)</a><p>").findall(r[0]) if len(r2) > 0: for i in range(len(r2)): value = r2[i] title = self.cm.html_entity_decode(value[1]) page = value[0] data = self.MAINURL + "/" + value[0] data2 = self.cm.getURLRequestData({'url': data, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True}) #Cover grafika = re.search("</div><div class='content'><div class='con'><a href='(.+?)' class='fbox'>", data2) if grafika: icon = self.MAINURL + grafika.group(1) else: icon ='' #Description match = re.search("<h2>Opis anime</h2></div><div class='content'><div class='con'>(.+?)</div>", data2) if match: plot = match.group(1) else: match = re.search("<h2>Opis anime</h2></div><div class='content'><div class='con'>(.+?)<", data2) if match: plot = match.group(1) else: match = re.search("<h2>Opis anime</h2></div><.+?>(.+?)<", data2) if match: plot = match.group(1) else: plot = '' params = {'name': 'episodelist', 'title': title, 'page': page, 'icon': icon, 'plot': self.cm.html_entity_decode(plot)} self.addDir(params) if nextPage is True: nextpage = url[:-2] + str(int(url[-2:]) + 10) params = {'name': 'nextpage', 'title': 'Next page', 'page': nextpage} self.addDir(params) # EPISODES LIST def getEpisodeList(self, url): query_data = {'url': url + '/odcinki', 'use_host': True, 'host': self.HOST, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True} query_data1 = {'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) # episodes data data2 = self.cm.getURLRequestData(query_data1) # cover, desc. data except: printExc() # Description match = re.search("<h2>Opis anime</h2></div><div class='content'><div class='con'>(.+?)</div>", data2) if match: plot = match.group(1) else: match = re.search("<h2>Opis anime</h2></div><div class='content'><div class='con'>(.+?)<", data2) if match: plot = match.group(1) else: match = re.search("<h2>Opis anime</h2></div><.+?>(.+?)<", data2) if match: plot = match.group(1) else: plot = '' # Cover grafika = re.search("</div><div class='content'><div class='con'><a href='(.+?)' class='fbox'>", data2) if grafika: icon = self.MAINURL + grafika.group(1) else: icon ='' # Episodes match = re.compile("<span class='head2'>Statystyki:</span>(.+?)<div class='mainCon'>", re.DOTALL).findall(data) if len(match) > 0: match2 = re.compile("#(.+?)</div><div class=.+?</div><div class='con3'><a href='(.+?)' class='i'>").findall(match[0]) if len(match2) > 0: for i in range(len(match2)): value = match2[i] page = self.MAINURL + value[1] title = 'Odcinek ' + value[0] params = {'title': title, 'page': page, 'plot': self.cm.html_entity_decode(plot), 'icon': icon} self.addVideo(params) def handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') if 0 == refresh: if len(self.currList) <= index: printDBG("handleService wrong index: %s, len(self.currList): %d" % (index, len(self.currList))) return if -1 == index: # use default value self.currItem = {"name": None} printDBG("handleService for first self.category") else: self.currItem = self.currList[index] name = self.currItem.get("name", '') title = self.currItem.get("title", '') category = self.currItem.get("category", '') page = self.currItem.get("page", '') icon = self.currItem.get("icon", '') printDBG("handleService: |||||||||||||||||||||||||||||||| [%s] " % name) self.currList = [] if str(page) == 'None' or page == '': page = '0' # Fill the Menu #MAIN MENU if name is None: #logowanie if self.usePremiumAccount: self.requestLoginData() self.listsMainMenu(self.SERVICE_MENU_TABLE) #LISTA ANIME (Alfabetycznie) elif category == self.setTable()[1]: self.listsABCMenu(self.cm.makeABCList()) elif name == 'abc-menu': url = '/lista-anime?letter=' + category + '&rowstart=00' self.getAnimeList(url) elif name == 'nextpage': self.getAnimeList(page) #LISTA ANIME (wg. Gatunku) # elif category == self.setTable()[2]: # url = self.MAINURL + '/lista-anime' # self.getlistsGenre(url) # elif name == 'genset': # self.getAnimeList(page) #LISTA ANIME (wg. Rankingu) elif category == self.setTable()[2]: url = self.MAINURL + '/ranking-anime' self.getlistsRanks(url) elif name == 'ranks': self.getEpisodeList(page) #ULUBIONE elif category == self.setTable()[3]: url = self.MAINURL + '/moja-lista/' + self.username self.getlistsUlubione(url) elif name == 'ulubione': self.getEpisodeList(page) #AKTUALNOŚCI elif category == self.setTable()[4]: url = self.MAINURL + '/newsy' self.getlistsNews(url) elif name == 'news': self.getlistsNews(page) #Episodes will not display without this: #Episodes list elif name == 'episodelist': url = self.MAINURL + '/' + page self.getEpisodeList(url)
class MusicBox(CBaseHostClass): SERVICE_MENU_TABLE = { 1: "Itunes - Top songs by country", 2: "Itunes - Top albums by country", # 3: "Dezzer - Top Tracks", 4: "Beatport - Top 100", # 5: "Official Charts UK", 6: "Bilboard - The Hot 100", 7: "Bilboard - 200", # 8: "Bilboard - Heatseekers Songs", 9: "Bilboard - Heatseekers Albums", 10: "Bilboard - Hot Pop Songs", 11: "Bilboard - Hot Country Songs", 12: "Bilboard - Hot Country Albums", 13: "Bilboard - Hot Rock Songs", 14: "Bilboard - Hot Rock Albums", 15: "Bilboard - Hot R&B/Hip-Hop Songs", 16: "Bilboard - Hot R&B/Hip-Hop Albums", 17: "Bilboard - Hot Dance/Electronic Songs", 18: "Bilboard - Hot Dance/Electronic Albums", 19: "Bilboard - Hot Latin Songs", 20: "Bilboard - Hot Latin Albums", 21: "Last.fm - Moja lista", } def __init__(self): CBaseHostClass.__init__(self) self.ytformats = config.plugins.iptvplayer.ytformat.value self.ytp = YouTubeParser() self.lastfm_username = config.plugins.iptvplayer.MusicBox_login.value self.usePremiumAccount = config.plugins.iptvplayer.MusicBox_premium.value def setTable(self): return self.SERVICE_MENU_TABLE def listsMainMenu(self, table): for num, val in table.items(): params = {'name': 'main-menu', 'category': val, 'title': val, 'icon': ''} self.addDir(params) ############################################################################### # Itunes ############################################################################### def Itunes_countries_menu(self, url, mode): country_name = ["Albania", "Algeria", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Botswana", "Brazil", "British Virgin Islands", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Cambodia", "Canada", "Cape Verde", "Cayman Islands", "Chad", "Chile", "China", "Colombia", "Congo, Republic of the", "Costa Rica", "Croatia", "Cyprus", "Czech Republic", "Denmark", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Estonia", "Fiji", "Finland", "France", "Gambia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea-Bissau", "Guyana", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Korea, Republic Of", "Kuwait", "Kyrgyzstan", "Lao, People's Democratic Republic", "Latvia", "Lebanon", "Liberia", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Mali", "Malta", "Mauritania", "Mauritius", "Mexico", "Micronesia, Federated States of", "Moldova", "Mongolia", "Montserrat", "Mozambique", "Namibia", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "South Africa", "Spain", "Sri Lanka", "St. Kitts and Nevis", "St. Lucia", "St. Vincent and The Grenadines", "Suriname", "Swaziland", "Sweden", "Switzerland", "São Tomé and Príncipe", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Venezuela", "Vietnam", "Yemen", "Zimbabwe"] country_code = ["al", "dz", "ao", "ai", "ag", "ar", "am", "au", "at", "az", "bs", "bh", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bw", "br", "vg", "bn", "bg", "bf", "kh", "ca", "cv", "ky", "td", "cl", "cn", "co", "cg", "cr", "hr", "cy", "cz", "dk", "dm", "do", "ec", "eg", "sv", "ee", "fj", "fi", "fr", "gm", "de", "gh", "gr", "gd", "gt", "gw", "gy", "hn", "hk", "hu", "is", "in", "id", "ie", "ir", "it", "jm", "jp", "jo", "kz", "ke", "kr", "kw", "kg", "la", "lv", "lb", "lr", "lt", "lu", "mo", "mk", "mg", "mw", "my", "ml", "mt", "mr", "mu", "mx", "fm", "md", "mn", "ms", "mz", "na", "np", "nl", "nz", "ni", "ne", "ng", "no", "om", "pk", "pw", "pa", "pg", "py", "pe", "ph", "pl", "pt", "qa", "ro", "ru", "sa", "sn", "sc", "sl", "sg", "sk", "si", "sb", "za", "es", "lk", "kn", "lc", "vc", "sr", "sz", "se", "ch", "st", "tw", "tj", "tz", "th", "tt", "tn", "tr", "tm", "tc", "ug", "ua", "ae", "gb", "us", "uy", "uz", "ve", "vn", "ye", "zw"] for x in range(0, len(country_name)): if country_code[x] not in ["al", "dz", "ao", "bj", "bt", "td", "cn", "cg", "gy", "is", "jm", "kr", "kw", "lr", "mk", "mg", "mw", "ml", "mr", "ms", "pk", "pw", "sn", "sc", "sl", "sb", "lc", "vc", "sr", "st", "tz", "tn", "tc", "uy", "ye"]: #Countries without music store url = country_code[x] title = country_name[x] icon = 'http://www.geonames.org/flags/x/' + country_code[x] + '.gif' desc = title if mode == 'song': params = {'name': 'Itunes_track_charts', 'title': title, 'page': url, 'icon': icon, 'plot': desc} self.addDir(params) elif mode == 'album': params = {'name': 'Itunes_album_charts', 'title': title, 'page': url, 'icon': icon, 'plot': desc} self.addDir(params) def Itunes_track_charts(self, url): country = url sts, data = self.cm.getPage('https://itunes.apple.com/%s/rss/topsongs/limit=100/explicit=true/json' % country, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['feed']['entry'] for x in range(len(data)): item = data[x] artist = item['im:artist']['label'] track_name = item['im:name']['label'] try: iconimage = item['im:image'][2]['label'] except: iconimage = '' plot = '' search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = {'title': str(x + 1) + '. ' + artist + '- ' + track_name, 'page': search_string, 'icon': iconimage, 'plot': plot} self.addVideo(params) except: printExc() # wypisz co poszło nie tak def Itunes_album_charts(self, url): country = url sts, data = self.cm.getPage('https://itunes.apple.com/%s/rss/topalbums/limit=100/explicit=true/json' % country, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['feed']['entry'] for x in range(len(data)): item = data[x] artist = item['im:artist']['label'] album_name = item['im:name']['label'] idx = item['id']['attributes']['im:id'] try: iconimage = item['im:image'][2]['label'] except: iconimage = '' plot = '' params = {'name': 'Itunes_list_album_tracks','title': str(x + 1) + '. ' + artist + '- ' + album_name, 'page': idx, 'album': album_name, 'country': country, 'icon': iconimage, 'plot': plot} self.addDir(params) except: printExc() # wypisz co poszło nie tak def Itunes_list_album_tracks(self, url, album, country): sts, data = self.cm.getPage('https://itunes.apple.com/lookup?id='+url+'&country='+country+'&entity=song&limit=200', {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['results'] for x in range(1, len(data)): item = data[x] artist = item['artistName'] track_name = item['trackName'] try: iconimage = item['artworkUrl100'] except: iconimage = '' plot = '' search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = {'title': artist + '- ' + track_name, 'page': search_string, 'icon': iconimage, 'plot': plot} self.addVideo(params) except: printExc() ############################################################################### # Beatport ############################################################################### def Beatport_top100(self, url): sts, data = self.cm.getPage(url) if not sts: return match = re.findall('<li class="bucket-item track">.*?<img.*?data-src="(.*?)".*?>.*?</a>.*?<div class="buk-track-num">(.+?)</div>.*?<p class="buk-track-title">.*?<a.*?>.*?<span class="buk-track-primary-title">(.*?)</span>.*?<span class="buk-track-remixed">(.*?)</span>.*?</a>.*?</p>.*?<p class="buk-track-artists">(.*?)</p>.*?<p class="buk-track-remixers">(.*?)</p>.*?</li>', data, re.DOTALL) if len(match) > 0: for i in range(len(match)): try: track_number = match[i][1] title_primary = (re.sub('\s+', ' ', (re.sub('<[^>]*>', '', match[i][2])))).replace("&", "&").replace("'", "'") remixed = '(' + (re.sub('\s+', ' ', (re.sub('<[^>]*>', '', match[i][3])))).replace("&", "&").replace("'", "'") + ')' track_name = title_primary + ' ' + remixed artist = re.sub('<[^>]*>', '', match[i][4]) artist = re.sub('\s+', ' ', artist.strip()) artist = artist.replace("&", "&").replace("'", "'") iconimage = match[i][0].replace('/95x95/', '/300x300/') search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = {'title': track_number + '. ' + artist + '- ' + track_name, 'page': search_string, 'icon': iconimage, 'plot': ''} self.addVideo(params) except: pass ############################################################################### # Bilboard ############################################################################### def Billboard_charts(self, url): sts, data = self.cm.getPage(url, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['query']['results']['item'] for x in range(0, len(data)): item = data[x] name = item['title'] artist = item['artist'] track_name = item['chart_item_title'] search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = {'title': name + ' - ' + artist, 'page': search_string, 'icon': '', 'plot': ''} self.addVideo(params) except: printExc() # wypisz co poszło nie tak def Billboard_chartsalbums(self, url): sts, data1 = self.cm.getPage(url, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data1))['query']['results']['item'] for x in range(0, len(data)): item = data[x] name = item['title'] artist = item['artist'] album_name = item['chart_item_title'] params = {'name': 'List_album_tracks','title': name + ' - ' + artist, 'page': 0, 'artist': artist, 'album': album_name, 'icon': '', 'plot': ''} self.addDir(params) except: printExc() # wypisz co poszło nie tak ############################################################################### # Szukanie tytułu z albumow ############################################################################### def List_album_tracks(self, url, artist, album): if url != 0: sts, data = self.cm.getPage('http://ws.audioscrobbler.com/2.0/?method=album.getInfo&mbid='+url+'&api_key=' + audioscrobbler_api_key + '&format=json', {'header': HEADER}) if not sts: return else: sts, data = self.cm.getPage('http://ws.audioscrobbler.com/2.0/?method=album.getInfo&artist='+urllib.quote(artist)+'&album='+urllib.quote(album)+'&api_key=' + audioscrobbler_api_key + '&format=json', {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['album']['tracks']['track'] for x in range(0, len(data)): item = data[x] artist = item['artist']['name'] track_name = item['name'] try: iconimage = item['album']['image'][3]['#text'] except: iconimage = '' search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = {'title': track_name + ' - ' + artist, 'page': search_string, 'icon': iconimage, 'plot': ''} self.addVideo(params) except: printExc() # wypisz co poszło nie tak ############################################################################### # Moja playlista z Last.fm ############################################################################### def Lastfmlist(self): if False == self.usePremiumAccount: self.sessionEx.waitForFinishOpen(MessageBox, 'Wpisz login do last.fm.', type=MessageBox.TYPE_INFO, timeout=10) else: url = 'http://ws.audioscrobbler.com/2.0/?method=user.getPlaylists&user='******'&api_key=' + audioscrobbler_api_key + '&format=json' sts, data = self.cm.getPage(url, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['playlists']['playlist'] for x in range(len(data)): item = data[x] playlist_name = item['title'] playlist_id = item['id'] params = {'name': 'Lastfmlist_track', 'title': playlist_name, 'artist': playlist_id} self.addDir(params) except: printExc() # wypisz co poszło nie tak def Lastfmlist_track(self, artist): playlist_id = "lastfm://playlist/" + artist url = 'http://ws.audioscrobbler.com/2.0/?method=playlist.fetch&playlistURL=' + playlist_id + '&api_key=' + audioscrobbler_api_key + '&format=json' print url sts, data = self.cm.getPage(url, {'header': HEADER}) if not sts: return try: data = byteify(json.loads(data))['playlist']['trackList']['track'] print data for x in range(len(data)): item = data[x] artist = item['creator'] track_name = item['title'] try: iconimage = item['image'] except: iconimage = '' search_string = urllib.quote(artist + ' ' + track_name + ' music video') params = {'title': track_name + ' - ' + artist, 'page': search_string, 'icon': iconimage, 'plot': ''} self.addVideo(params) except: printExc() # wypisz co poszło nie tak ############################################################################### # Szukanie linku do materiału na youtube ############################################################################### def Search_videoclip(self, url): sts, data = self.cm.getPage("https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&q=" + url + "&type=Music&maxResults=1&key=" + youtube_api_key) if not sts: return [] match = re.compile('"videoId": "([^"]+?)"').findall(data) videoUrls = [] for item in match: video_path = "https://www.youtube.com/watch?v=" + item videoUrls = self.getLinksForVideo(video_path) return videoUrls def getLinksForVideo(self, url): printDBG("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 ): val = self.cm.ph.getSearchGroups('|%s|' %itemLink['format'], '[^0-9]([0-9]+?)[^0-9]')[0] if '' == val: return 0 return int(val) 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 handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') if 0 == refresh: if len(self.currList) <= index: printDBG("handleService wrong index: %s, len(self.currList): %d" % (index, len(self.currList))) return if -1 == index: # use default value self.currItem = {"name": None} printDBG("handleService for first self.category") else: self.currItem = self.currList[index] name = self.currItem.get("name", '') title = self.currItem.get("title", '') category = self.currItem.get("category", '') page = self.currItem.get("page", '') icon = self.currItem.get("icon", '') album = self.currItem.get("album", '') country = self.currItem.get("country", '') artist = self.currItem.get("artist", '') printDBG( "handleService: |||||||||||||||||||||||||||||||||||| [%s] " % name ) self.currList = [] if str(page)=='None' or page=='': page = '0' #MAIN MENU if name is None: self.listsMainMenu(self.SERVICE_MENU_TABLE) #LISTA # "Itunes - Top songs by country" elif category == self.setTable()[1]: self.Itunes_countries_menu('http://www.geonames.org/flags/x/', 'song') # "Itunes - Top albums by country" elif category == self.setTable()[2]: self.Itunes_countries_menu('http://www.geonames.org/flags/x/', 'album') # "Beatport - Top 100" elif category == self.setTable()[4]: self.Beatport_top100('https://pro.beatport.com/top-100') # "Bilboard - The Hot 100" elif category == self.setTable()[6]: item = 'hot-100' self.Billboard_charts('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item +'%22&format=json&diagnostics=true&callback=') # "Bilboard - 200" elif category == self.setTable()[7]: item = 'billboard-200' self.Billboard_charts('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,200)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item +'%22&format=json&diagnostics=true&callback=') # "Bilboard - Heatseekers Albums" elif category == self.setTable()[9]: item = 'heatseekers-albums' self.Billboard_chartsalbums('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,200)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item +'%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Pop Songs" elif category == self.setTable()[10]: item = 'pop-songs' self.Billboard_charts('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Country Songs" elif category == self.setTable()[11]: item = 'country-songs' self.Billboard_charts('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Country Albums" elif category == self.setTable()[12]: item = 'country-albums' self.Billboard_chartsalbums('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Rock Songs" elif category == self.setTable()[13]: item = 'rock-songs' self.Billboard_charts('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Rock Albums" elif category == self.setTable()[14]: item = 'rock-albums' self.Billboard_chartsalbums('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot R&B/Hip-Hop Songs" elif category == self.setTable()[15]: item = 'r-b-hip-hop-songs' self.Billboard_charts('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot R&B/Hip-Hop Albums" elif category == self.setTable()[16]: item = 'r-b-hip-hop-albums' self.Billboard_chartsalbums('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Dance/Electronic Songs" elif category == self.setTable()[17]: item = 'dance-electronic-songs' self.Billboard_charts('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Dance/Electronic Albums" elif category == self.setTable()[18]: item = 'dance-electronic-albums' self.Billboard_chartsalbums('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Latin Songs" elif category == self.setTable()[19]: item = 'latin-songs' self.Billboard_charts('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') # "Bilboard - Hot Latin Albums" elif category == self.setTable()[20]: item = 'latin-albums' self.Billboard_chartsalbums('http://query.yahooapis.com/v1/public/yql?q=SELECT+*+FROM+feed(1,100)+WHERE+url=%22http://www.billboard.com/rss/charts/' + item + '%22&format=json&diagnostics=true&callback=') elif category == self.setTable()[21]: self.Lastfmlist() ########### elif name == 'Itunes_track_charts': self.Itunes_track_charts(page) elif name == 'Itunes_album_charts': self.Itunes_album_charts(page) elif name == 'Itunes_list_album_tracks': self.Itunes_list_album_tracks(page, album, country) elif name == 'List_album_tracks': self.List_album_tracks(page, artist, album) elif name == 'Lastfmlist_track': self.Lastfmlist_track(artist)
def __init__(self): self.cm = pCommon.common() self.currList = [] self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value
def __init__(self): CBaseHostClass.__init__(self) self.ytformats = config.plugins.iptvplayer.ytformat.value self.ytp = YouTubeParser() self.lastfm_username = config.plugins.iptvplayer.MusicBox_login.value self.usePremiumAccount = config.plugins.iptvplayer.MusicBox_premium.value
class AnyFilesVideoUrlExtractor: COOKIEFILE = GetCookieDir('anyfiles.cookie') MAINURL = 'http://video.anyfiles.pl' LOGIN_URL_2 = MAINURL + '/j_security_check' LOGIN_URL = MAINURL + '/Logo?op=l' def __init__(self): self.cm = common() self.ytp = YouTubeParser() self.ytformats = 'mp4' self.defaultParams = {'header':{'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0'}, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': AnyFilesVideoUrlExtractor.COOKIEFILE} self.logged = False def isLogged(self): return self.logged def tryTologin(self): login = config.plugins.iptvplayer.anyfilespl_login.value password = config.plugins.iptvplayer.anyfilespl_password.value printDBG("AnyFilesVideoUrlExtractor.tryTologin login[%s]" % login) if 0 < len(login) and 0 < len(password): #First we need get JSESSIONID params = dict(self.defaultParams) params['load_cookie'] = False sts, data = self.cm.getPage(self.LOGIN_URL, params) #Then we login and get new JSESSIONID params = dict(self.defaultParams) params['header']['Referer'] = self.LOGIN_URL post_data = {'j_username':login, 'j_password':password} sts, data = self.cm.getPage(self.LOGIN_URL_2, params, post_data) # prev sts will be probably False due to ERROR 302, so there # is there is no sens to check this status here sts,data = self.cm.getPage(self.MAINURL, self.defaultParams) if sts and 'href="/Logo?op=w"' in data: self.logged = True return True else: printDBG("AnyFilesVideoUrlExtractor.tryTologin wrong login data") self.logged = False return False def getYTVideoUrl(self, url): printDBG("getYTVideoUrl url[%s]" % url) tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({ 'name': 'YouTube: ' + item['format'] + '\t' + item['ext'] , 'url':item['url'].encode('UTF-8') }) return movieUrls def getVideoUrl(self, url): #show adult content #self.cm.addCookieItem(COOKIEFILE, {'name': 'AnyF18', 'value': 'mam18', 'domain': 'video.anyfiles.pl'}, False) if not self.isLogged(): self.tryTologin() # GET VIDEO ID u = url.split('/') vidID = u[-1] match = re.search('([0-9]+?)\,', url ) if match: vidID = match.group(1) # get COOKIE url = self.MAINURL + '/videos.jsp?id=' + vidID sts, data = self.cm.getPage(url, self.defaultParams) if not sts: return [] fUrl = self.MAINURL + "/w.jsp?id=%s&width=620&height=349&pos=0&skin=0" % vidID COOKIE_JSESSIONID = self.cm.getCookieItem(self.COOKIEFILE,'JSESSIONID') HEADER = {'Referer' : url, 'Cookie' : 'JSESSIONID=' + COOKIE_JSESSIONID + ';', 'User-Agent': "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"} request_param = {'header':HEADER} sts, data = self.cm.getPage(fUrl, request_param) if not sts: return [] HEADER['Referer'] = fUrl config = CParsingHelper.getSearchGroups(data, 'src="/?(pcs\?code=[^"]+?)"', 1)[0] if '' != config: sts,data = self.cm.getPage( self.MAINURL + '/' + config, {'header': HEADER}) if sts: #var source = "<source src=\"http://50.7.220.66/video/60ExQvchsi4PbqMLr--I7A/1433518629/5e638de7a15c7a8dc7c979044cd2a953_147325.mp4\" type=\"video/mp4\" />"; #var track = "<track label=\"izombie.112...\" srclang=\"pl\" kind=\"captions\" src=\"http://video.anyfiles.pl/subtit/1433508336949.srt\"></track>\n"; data = data.replace('\\"', '"') #printDBG(data) difSourcesSrc = CParsingHelper.getSearchGroups(data, '''difSourcesSrc[^=]*?=[^"']*?["'](http[^'^"]+?)['"]''', 1)[0] url = CParsingHelper.getSearchGroups(data, '''<source[^>]+?src=["'](http[^'^"]+?)['"]''', 1)[0] subUrl = CParsingHelper.getSearchGroups(data, '''<track[^>]+?src=["'](http[^'^"]+?)['"]''', 1)[0] if 'youtube' in difSourcesSrc: return self.getYTVideoUrl(difSourcesSrc) else: return [{'name':'AnyFiles.pl', 'url':url}] return []
def __init__(self): printDBG("Youtube.__init__") CBaseHostClass.__init__(self, {'history':'ytlist', 'cookie':'youtube.cookie'}) self.ytp = YouTubeParser() self.currFileHost = None
class FightTube: MAINURL = 'http://www.fighttube.pl/' SEARCHURL = MAINURL + 'search/?keywords=' def __init__(self): self.cm = common() self.history = CSearchHistoryHelper('fighttube') self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value # temporary data self.currList = [] self.currItem = {} def getCurrList(self): return self.currList def setCurrList(self, list): self.currList = list def getCurrItem(self): return self.currItem def setCurrItem(self, item): self.currItem = item @staticmethod def printDBG(strDBG): printDBG('[IPTV FightTube] ' + strDBG) def getVideoUrl(self, url): FightTube.printDBG("getVideoUrl url[%s]" % url) query_data = {'url': url, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: FightTube.printDBG('getVideoUrl exception') return [] match = re.search( '<embed src="([^"]+?)" type="application/x-shockwave-flash"', data) if match: return self.getYTVideoUrl(match.group(1)) else: FightTube.printDBG('getVideoUrl YT embed not found!') return [] def getYTVideoUrl(self, url): FightTube.printDBG("getYTVideoUrl url[%s]" % url) tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({ 'name': item['format'] + '\t' + item['ext'], 'url': item['url'] }) return movieUrls def listsMainMenu(self): FightTube.printDBG('listsMainMenu start') query_data = {'url': self.MAINURL, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: FightTube.printDBG('listsMainMenu exception') return sts, data = CParsingHelper.getDataBeetwenMarkers( data, 'Kategorie video', '</ul>', False) if not sts: printDBG('listsMainMenu: menu marker cannot be found!') return match = re.compile( "<a href='([^']+?)' class='level0'[^>]+?>([^<]+?)</a>").findall( data) if len(match) > 0: for i in range(len(match)): params = { 'type': 'category', 'title': match[i][1], 'page': match[i][0], 'icon': '' } self.currList.append(params) params = { 'type': 'category', 'title': 'Wyszukaj', 'page': self.SEARCHURL, 'icon': '' } self.currList.append(params) return def getMovieTab(self, url): FightTube.printDBG('getMovieTab start') query_data = {'url': url, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: FightTube.printDBG('getMovieTab exception') return # get next page url nexPageUrl = '' sts, tmp = CParsingHelper.getDataBeetwenMarkers( data, "<nav class='pagination'>", "</nav>", False) if sts: match = re.search("<li><a href='([^']+?)'>></a></li>", tmp) if match: nexPageUrl = match.group(1) # separete vidTab sts, data = CParsingHelper.getDataBeetwenMarkers( data, "<ul class='videos-listing'>", "</ul>", False) if not sts: printDBG('getMovieTab: main markers cannot be found!') return # separate videos data data = data.split('</li>') for vidItem in data: url = '' title = '' icon = '' ocena = '' wyswietlen = '' match = re.search("<a href='([^']+?)'", vidItem) if match: url = match.group(1) match = re.search("<img src='([^']+?)' alt='([^']+?)'", vidItem) if match: icon = match.group(1) title = match.group(2) if '' != url and '' != title: params = { 'type': 'video', 'title': title, 'page': url, 'icon': icon } self.currList.append(params) if nexPageUrl.startswith("http://"): params = { 'type': 'category', 'name': 'nextpage', 'title': 'Następna strona', 'page': nexPageUrl, 'icon': '' } self.currList.append(params) return def searchTab(self, text): FightTube.printDBG('searchTab start') self.getMovieTab(self.SEARCHURL + text) def handleService(self, index, refresh=0, searchPattern=''): FightTube.printDBG('handleService start') if 0 == refresh: if len(self.currList) <= index: FightTube.printDBG( "handleService wrong index: %s, len(self.currList): %d" % (index, len(self.currList))) return if -1 == index: # use default value self.currItem = {"name": None} FightTube.printDBG("handleService for first self.category") else: self.currItem = self.currList[index] name = self.currItem.get("name", '') title = self.currItem.get("title", '') category = self.currItem.get("category", '') page = self.currItem.get("page", '') icon = self.currItem.get("icon", '') type = self.currItem.get("type", '') FightTube.printDBG( "handleService: |||||||||||||||||||||||||||||||||||| [%s] " % name) self.currList = [] #MAIN MENU == KATEGORIE if name == None: self.listsMainMenu() elif type != 'category': return #WYSZUKAJ elif title == 'Wyszukaj': if searchPattern != None: self.searchTab(searchPattern) else: self.getMovieTab(page)
def __init__(self): self.cm = common() self.ytp = YouTubeParser() self.ytformats = 'mp4' self.defaultParams = {'header':{'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0'}, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': AnyFilesVideoUrlExtractor.COOKIEFILE} self.logged = False
class AnyFilesVideoUrlExtractor: COOKIEFILE = GetCookieDir('anyfiles.cookie') MAINURL = 'http://video.anyfiles.pl' LOGIN_URL_2 = MAINURL + '/j_security_check' LOGIN_URL = MAINURL + '/Logo?op=l' def __init__(self): self.cm = common() self.ytp = YouTubeParser() self.ytformats = 'mp4' self.defaultParams = { 'header': { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0' }, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': AnyFilesVideoUrlExtractor.COOKIEFILE } self.logged = False def isLogged(self): return self.logged def tryTologin(self): login = config.plugins.iptvplayer.anyfilespl_login.value password = config.plugins.iptvplayer.anyfilespl_password.value printDBG("AnyFilesVideoUrlExtractor.tryTologin login[%s]" % login) if 0 < len(login) and 0 < len(password): #First we need get JSESSIONID params = dict(self.defaultParams) params['load_cookie'] = False sts, data = self.cm.getPage(self.LOGIN_URL, params) #Then we login and get new JSESSIONID params = dict(self.defaultParams) params['header']['Referer'] = self.LOGIN_URL post_data = {'j_username': login, 'j_password': password} sts, data = self.cm.getPage(self.LOGIN_URL_2, params, post_data) # prev sts will be probably False due to ERROR 302, so there # is there is no sens to check this status here sts, data = self.cm.getPage(self.MAINURL, self.defaultParams) if sts and 'href="/Logo?op=w"' in data: self.logged = True return True else: printDBG("AnyFilesVideoUrlExtractor.tryTologin wrong login data") self.logged = False return False def getYTVideoUrl(self, url): printDBG("getYTVideoUrl url[%s]" % url) tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({ 'name': 'YouTube: ' + item['format'] + '\t' + item['ext'], 'url': item['url'].encode('UTF-8') }) return movieUrls def getVideoUrl(self, url): #show adult content #self.cm.addCookieItem(COOKIEFILE, {'name': 'AnyF18', 'value': 'mam18', 'domain': 'video.anyfiles.pl'}, False) if not self.isLogged(): self.tryTologin() # GET VIDEO ID u = url.split('/') vidID = u[-1] match = re.search('([0-9]+?)\,', url) if match: vidID = match.group(1) # get COOKIE url = self.MAINURL + '/videos.jsp?id=' + vidID sts, data = self.cm.getPage(url, self.defaultParams) if not sts: return [] fUrl = self.MAINURL + "/w.jsp?id=%s&width=620&height=349&pos=0&skin=0" % vidID COOKIE_JSESSIONID = self.cm.getCookieItem(self.COOKIEFILE, 'JSESSIONID') HEADER = { 'Referer': url, 'Cookie': 'JSESSIONID=' + COOKIE_JSESSIONID + ';', 'User-Agent': "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30" } request_param = {'header': HEADER} sts, data = self.cm.getPage(fUrl, request_param) if not sts: return [] HEADER['Referer'] = fUrl config = CParsingHelper.getSearchGroups(data, 'src="/?(pcs\?code=[^"]+?)"', 1)[0] if '' != config: sts, data = self.cm.getPage(self.MAINURL + '/' + config, {'header': HEADER}) if sts: #var source = "<source src=\"http://50.7.220.66/video/60ExQvchsi4PbqMLr--I7A/1433518629/5e638de7a15c7a8dc7c979044cd2a953_147325.mp4\" type=\"video/mp4\" />"; #var track = "<track label=\"izombie.112...\" srclang=\"pl\" kind=\"captions\" src=\"http://video.anyfiles.pl/subtit/1433508336949.srt\"></track>\n"; data = data.replace('\\"', '"') #printDBG(data) difSourcesSrc = CParsingHelper.getSearchGroups( data, '''difSourcesSrc[^=]*?=[^"']*?["'](http[^'^"]+?)['"]''', 1)[0] url = CParsingHelper.getSearchGroups( data, '''<source[^>]+?src=["'](http[^'^"]+?)['"]''', 1)[0] subUrl = CParsingHelper.getSearchGroups( data, '''<track[^>]+?src=["'](http[^'^"]+?)['"]''', 1)[0] if 'youtube' in difSourcesSrc: return self.getYTVideoUrl(difSourcesSrc) else: return [{'name': 'AnyFiles.pl', 'url': url}] return []
class Kabarety: MAINURL = 'http://www.kabarety.odpoczywam.net/' IMGURL = 'http://i.ytimg.com/vi/' NAJ_LINK = MAINURL + '/bestof/page:' NOW_LINK = MAINURL + '/index/page:' SERVICE_MENU_TABLE = { 1: "Najnowsze", 2: "Najlepsze", 3: "Kategorie", 4: "Wyszukaj", } def __init__(self): self.cm = pCommon.common() self.currList = [] self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value def _getFullUrl(self, url, baseUrl=None): if None == baseUrl: baseUrl = Kabarety.MAINURL if 0 < len(url) and not url.startswith('http'): url = baseUrl + url return url def getCurrList(self): return self.currList def setCurrList(self, list): self.currList = list return def setTable(self): return self.SERVICE_MENU_TABLE def listsMainMenu(self, table): printDBG("Kabarety.listsMainMenu") self.currList = [] for num, val in table.items(): item = {'type': 'dir', 'name': 'main-menu', 'category': val, 'title': val, 'icon': ''} self.currList.append(item) def getCategories(self, url): printDBG("Kabarety.getCategories") self.currList = [] query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except Exception: printDBG("Kabarety.getCategories exception") return match = re.compile('<b>Kategorie</a><br><br>(.+?)<br><br>', re.DOTALL).findall(data) if len(match) > 0: match2 = re.compile('href="(.+?)">(.+?)</a>').findall(match[0]) if len(match2) > 0: for i in range(len(match2)): title = self.cm.html_entity_decode(match2[i][1]) item = {'type': 'dir', 'name': 'category', 'title': title, 'category': match2[i][0], 'icon': ''} self.currList.append(item) def getFilmTab(self, url, page): printDBG("Kabarety.getFilmTab") self.currList = [] query_data = { 'url': self._getFullUrl(url)+page, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except Exception: printDBG("Kabarety.getFilmTab exception") return link = data.replace('\n', '') #MOD match = re.compile('<a class="video-mini" title="(.+?)" href=".+?">.+?<span class="duration".+?<img class="video-mini-img".+?src="http://i.ytimg.com/vi/(.+?)/0.jpg" />').findall(link) if len(match) > 0: for i in range(len(match)): title = self.cm.html_entity_decode(match[i][0]) img = self.IMGURL + match[i][1] + '/0.jpg' item = {'type': 'video', 'title': title, 'page': match[i][1], 'icon': img} self.currList.append(item) match = re.compile('<span><a href=".+?" class="next shadow-main">»</a></span>').findall(data) if len(match) > 0: newpage = str(int(page) + 1) item = {'type': 'dir', 'name': 'nextpage', 'title': 'Następna strona', 'category': url, 'page': newpage, 'icon': ''} self.currList.append(item) def getMovieUrls(self, vID): printDBG("Kabarety.getMovieUrls vID: " + vID) url = 'http://www.youtube.com/watch?v=' + vID tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({'name': item['format'] + '\t' + item['ext'] , 'url':item['url']}) return movieUrls def handleService(self, index, refresh = 0, searchPattern = ''): printDBG("Kabarety.handleService") if 0 == refresh: if len(self.currList) <= index: printDBG( "handleService wrong index: %s, len(self.currList): %d" % (index, len(self.currList)) ) return self.name = None self.title = '' self.category = '' self.page = '' self.icon = '' self.link = '' self.action = '' if -1 == index: printDBG( "Kinomaniak: handleService for first self.category" ) else: item = self.currList[index] if "name" in item: self.name = item['name'] if "title" in item: self.title = item['title'] if "category" in item: self.category = item['category'] if "page" in item: self.page = item['page'] if "icon" in item: self.icon = item['icon'] if "url" in item: self.link = item['url'] if "action" in item: self.action = item['action'] printDBG( "Kabarety: |||||||||||||||||||||||||||||||||||| %s " % item["name"] ) self.currList = [] name = self.name title = self.title category = self.category page = self.page icon = self.icon link = self.link action = self.action if str(page)=='None' or page=='': page = '1' #MAIN MENU if name == None: self.listsMainMenu(self.SERVICE_MENU_TABLE) #NAJNOWSZE elif category == self.setTable()[1]: self.getFilmTab(self.NOW_LINK, page) #NAJLEPSZE elif category == self.setTable()[2]: self.getFilmTab(self.NAJ_LINK, page) #KATEGORIE elif category == self.setTable()[3]: self.getCategories(self.MAINURL) #WYSZUKAJ elif category == self.setTable()[4]: self.getFilmTab(self.MAINURL + '/search/' + searchPattern + '/page:', page) #LISTA TYTULOW elif name == 'category' or name == 'nextpage': url = category + '/page:' self.getFilmTab(url, page)
class FightTube: MAINURL = 'http://www.fighttube.pl/' SEARCHURL = MAINURL + 'search/?keywords=' def __init__(self): self.cm = common() self.up = urlparser() self.history = CSearchHistoryHelper('fighttube') self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value # temporary data self.currList = [] self.currItem = {} def getCurrList(self): return self.currList def setCurrList(self, list): self.currList = list def getCurrItem(self): return self.currItem def setCurrItem(self, item): self.currItem = item @staticmethod def printDBG( strDBG ): printDBG('[IPTV FightTube] ' + strDBG) def getVideoUrl(self, url): FightTube.printDBG("getVideoUrl url[%s]" % url) sts, data = self.cm.getPage(url) if not sts: return [] #data = self.cm.ph.getDataBeetwenMarkers(data, '<div class="content">', "<ul")[1] vidUrl = self.cm.ph.getSearchGroups(data, '<embed src="([^"]+?)" type="application/x-shockwave-flash"')[0] if '' == vidUrl: vidUrl = self.cm.ph.getSearchGroups(data, 'src="([^"]+?/video/embed[^"]+?)"')[0] return self.up.getVideoLinkExt(vidUrl) def getYTVideoUrl(self, url): FightTube.printDBG("getYTVideoUrl url[%s]" % url) tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({'name': item['format'] + '\t' + item['ext'] , 'url':item['url']}) return movieUrls def listsMainMenu(self): FightTube.printDBG('listsMainMenu start') query_data = {'url': self.MAINURL, 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: FightTube.printDBG('listsMainMenu exception') return sts, data = CParsingHelper.getDataBeetwenMarkers(data, 'Kategorie video', '</ul>', False) if not sts: printDBG('listsMainMenu: menu marker cannot be found!') return match = re.compile("<a href='([^']+?)' class='level0'[^>]+?>([^<]+?)</a>").findall(data) if len(match) > 0: for i in range(len(match)): params = {'type': 'category', 'title': match[i][1], 'page': match[i][0], 'icon': ''} self.currList.append(params) params = {'type': 'category', 'title': 'Wyszukaj', 'page': self.SEARCHURL, 'icon': ''} self.currList.append(params) return def getMovieTab(self, url): FightTube.printDBG('getMovieTab start') query_data = { 'url': url, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: FightTube.printDBG('getMovieTab exception') return # get next page url nexPageUrl = '' sts, tmp = CParsingHelper.getDataBeetwenMarkers(data, "<nav class='pagination'>", "</nav>", False) if sts: match = re.search("<li><a href='([^']+?)'>></a></li>", tmp) if match: nexPageUrl = match.group(1) # separete vidTab sts, data = CParsingHelper.getDataBeetwenMarkers(data, "<ul class='videos-listing'>", "</ul>", False) if not sts: printDBG('getMovieTab: main markers cannot be found!') return # separate videos data data = data.split('</li>') for vidItem in data: url = '' title = '' icon = '' ocena = '' wyswietlen = '' match = re.search("<a href='([^']+?)'", vidItem) if match: url = match.group(1) match = re.search("<img src='([^']+?)' alt='([^']+?)'", vidItem) if match: icon = match.group(1) title = match.group(2) if '' != url and '' != title: params = {'type': 'video', 'title': title, 'page': url, 'icon': icon} self.currList.append(params) if nexPageUrl.startswith("http://"): params = {'type': 'category', 'name': 'nextpage', 'title': 'Następna strona', 'page': nexPageUrl, 'icon': ''} self.currList.append(params) return def searchTab(self, text): FightTube.printDBG('searchTab start') self.getMovieTab(self.SEARCHURL + text) def handleService(self, index, refresh = 0, searchPattern = ''): FightTube.printDBG('handleService start') if 0 == refresh: if len(self.currList) <= index: FightTube.printDBG( "handleService wrong index: %s, len(self.currList): %d" % (index, len(self.currList)) ) return if -1 == index: # use default value self.currItem = { "name": None } FightTube.printDBG( "handleService for first self.category" ) else: self.currItem = self.currList[index] name = self.currItem.get("name", '') title = self.currItem.get("title", '') category = self.currItem.get("category", '') page = self.currItem.get("page", '') icon = self.currItem.get("icon", '') type = self.currItem.get("type", '') FightTube.printDBG( "handleService: |||||||||||||||||||||||||||||||||||| [%s] " % name ) self.currList = [] #MAIN MENU == KATEGORIE if name == None: self.listsMainMenu() elif type != 'category': return #WYSZUKAJ elif title == 'Wyszukaj': if searchPattern != None: self.searchTab(searchPattern) else: self.getMovieTab(page)
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 diffanime: HOST = 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110621 Mandriva Linux/1.9.2.18-0.1mdv2010.2 (2010.2) Firefox/3.6.18' HEADER = { 'User-Agent': HOST, 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' } MAINURL = 'http://diff-anime.pl' SERVICE_MENU_TABLE = { 1: "Lista anime (alfabetycznie)", # 2: "Lista anime (wg. gatunku)", 2: "Ranking", 3: "Ulubione", 4: "Aktualności" } def __init__(self): self.up = urlparser.urlparser() self.cm = pCommon.common() self.sessionEx = MainSessionWrapper() self.ytp = YouTubeParser() self.ytformats = config.plugins.iptvplayer.ytformat.value # Temporary data self.currList = [] self.currItem = {} # Login data self.COOKIEFILE = GetCookieDir('Diff-anime.cookie') self.usePremiumAccount = config.plugins.iptvplayer.diffanime_premium.value self.username = config.plugins.iptvplayer.diffanime_login.value self.password = config.plugins.iptvplayer.diffanime_password.value def getCurrList(self): return self.currList def setCurrList(self, list): self.currList = list def getCurrItem(self): return self.currItem def setCurrItem(self, item): self.currItem = item # Login in to the site def requestLoginData(self): if False == self.usePremiumAccount: printDBG("diffanime niezalogowany") else: self.usePremiumAccount = False url = self.MAINURL query_data = { 'url': url, 'header': self.HEADER, 'use_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIEFILE, 'return_data': True } postdata = { 'user_name': self.username, 'user_pass': self.password, 'remember_me': 'y', "login": "******" } try: data = self.cm.getURLRequestData(query_data, postdata) except: printDBG("diffanime requestLoginData exception") return if 'Wyloguj' in data: printDBG("diffanime Notification(" + self.username + ", Zostales poprawnie zalogowany)") self.usePremiumAccount = True else: self.sessionEx.waitForFinishOpen( MessageBox, 'Błąd logowania. Sprawdź dane.\nlogin - ' + self.username + ' \nhasło - ' + self.password, type=MessageBox.TYPE_INFO, timeout=10) printDBG("diffanime Notification(Blad logowania)") # end login def addDir(self, params): params['type'] = 'category' self.currList.append(params) return def addVideo(self, params): params['type'] = 'video' self.currList.append(params) return def setTable(self): return self.SERVICE_MENU_TABLE # Get YT link def getYTVideoUrl(self, url): printDBG("getYTVideoUrl url[%s]" % url) tmpTab = self.ytp.getDirectLinks(url, self.ytformats) movieUrls = [] for item in tmpTab: movieUrls.append({ 'name': item['format'] + '\t' + item['ext'], 'url': item['url'] }) return movieUrls def getVideoUrlforYTube(self, url): printDBG("getVideoUrl url[%s]" % url) query_data = { 'url': url, 'use_host': True, 'host': self.HOST, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: printDBG('getVideoUrl exception') return '' match = re.search('src="//www.youtube.com/(.+?)"', data) if match: printDBG('www.youtube.com/' + match.group(1)) return self.getYTVideoUrl('www.youtube.com/' + match.group(1)) else: printDBG('nie znaleziono YT link') return '' # end Get YT link # Get mp4 link def getVideoUrl(self, url): printDBG("getVideoUrl url[%s]" % url) query_data = { 'url': url, 'use_host': True, 'host': self.HOST, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: printDBG('getVideoUrl exception') return '' match = re.search("'file': '(.+?)',", data) if match: return match.group(1) else: printDBG('nie znaleziono mp4 link') return '' # end Get mp4 link def listsMainMenu(self, table): query_data = {'url': self.MAINURL + '/newsy', 'return_data': True} try: data = self.cm.getURLRequestData(query_data) except: printDBG('listAbcItem exception') return match = re.compile( "div class='sRight'><div class='panel news'>(.+?)<div class='left'><div>Czytań:", re.DOTALL).findall(data) if len(match) > 0: match2 = re.search(".png' alt=([^<]+?)class='news-category'", match[0]) if match2: plot = match2.group(1) else: plot = '' match3 = re.search("class='news-category' />([^<]+?)</div>", match[0]) if match3: plot2 = match3.group(1) else: plot2 = '' icon = re.compile( "<div class='content'><img src='(.+?)' alt='").findall( match[0]) for num, val in table.items(): params = { 'name': 'main-menu', 'category': val, 'title': val, 'icon': self.MAINURL + icon[0], 'plot': self.cm.html_entity_decode(plot + plot2) } self.addDir(params) def listsABCMenu(self, table): for i in range(len(table)): params = { 'name': 'abc-menu', 'category': table[i], 'title': table[i], 'icon': '' } self.addDir(params) # "AKTUALNOŚCI" def getlistsNews(self, url): query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: printDBG('listsGenre EXCEPTION') r2 = re.compile("<div class='head'><h2><a href='/news/(.+?)'>(.+?)</a>" ).findall(data) if len(r2) > 0: for i in range(len(r2)): value = r2[i] title = self.cm.html_entity_decode(value[1]) data = self.MAINURL + '/news/' + value[0] data2 = self.cm.getURLRequestData({ 'url': data, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }) value = re.search( "<div class='content'><img src='(.+?)' alt='(.+?)' class='news-category' />(.+?).<br />", data2) if value: icon = self.MAINURL + value.group(1) plot = self.cm.html_entity_decode( value.group(2) + value.group(3)) else: icon = '' plot = '' params = { 'name': 'news', 'title': title, 'icon': icon, 'plot': plot, 'page': data } self.addVideo(params) # "ULUBIONE" def getlistsUlubione(self, url): query_data = { 'url': url + '/odcinki', 'use_host': True, 'host': self.HOST, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: printDBG('listsGenre EXCEPTION') r = re.compile( "<div id='pUAL' class='panel pDef'>(.+?)<div id='footer'>", re.DOTALL).findall(data) if len(r) > 0: x1 = re.compile("W trakcie<(.+?)>Ukończone<", re.DOTALL).findall(data) if len(x1) > 0: rx1 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall( x1[0]) if len(rx1) > 0: for i in range(len(rx1)): value = rx1[i] title = self.cm.html_entity_decode("W trakcie - " + value[1]) page = self.MAINURL + value[0] params = { 'name': 'ulubione', 'title': title, 'page': page, 'icon': '' } self.addDir(params) x2 = re.compile("Ukończone<(.+?)>Wstrzymane<", re.DOTALL).findall(data) if len(x2) > 0: rx2 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall( x2[0]) if len(rx2) > 0: for i in range(len(rx2)): value = rx2[i] title = self.cm.html_entity_decode("Ukończone - " + value[1]) page = self.MAINURL + value[0] params = { 'name': 'ulubione', 'title': title, 'page': page, 'icon': '' } self.addDir(params) x3 = re.compile("Wstrzymane<(.+?)>Porzucone<", re.DOTALL).findall(data) if len(x3) > 0: rx3 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall( x3[0]) if len(rx3) > 0: for i in range(len(rx3)): value = rx3[i] title = self.cm.html_entity_decode("Wstrzymane - " + value[1]) page = self.MAINURL + value[0] params = { 'name': 'ulubione', 'title': title, 'page': page, 'icon': '' } self.addDir(params) x4 = re.compile("Porzucone<(.+?)>W planach<", re.DOTALL).findall(data) if len(x4) > 0: rx4 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall( x4[0]) if len(rx4) > 0: for i in range(len(rx4)): value = rx4[i] title = self.cm.html_entity_decode("Porzucone - " + value[1]) page = self.MAINURL + value[0] params = { 'name': 'ulubione', 'title': title, 'page': page, 'icon': '' } self.addDir(params) x5 = re.compile("W planach<(.+?)='footer'>", re.DOTALL).findall(data) if len(x5) > 0: rx5 = re.compile("'sTitle'><a href='(.+?)'>(.+?)</a>").findall( x5[0]) if len(rx5) > 0: for i in range(len(rx5)): value = rx5[i] title = self.cm.html_entity_decode("W planach - " + value[1]) page = self.MAINURL + value[0] params = { 'name': 'ulubione', 'title': title, 'page': page, 'icon': '' } self.addDir(params) # "RANKING" def getlistsRanks(self, url): query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: printDBG('listsGenre EXCEPTION') r = re.compile("<h2>Ranking anime</h2>(.+?)</table>", re.DOTALL).findall(data) if len(r) > 0: r2 = re.compile( "<td class='td2'><a href='/(.+?)'><img src='(.+?)' class='img' /></a><div class='con'><a href='(.+?)'>(.+?)</a><p>" ).findall(r[0]) if len(r2) > 0: for i in range(len(r2)): value = r2[i] title = self.cm.html_entity_decode(value[3]) page = self.MAINURL + value[2] icon = self.MAINURL + value[1] params = { 'name': 'ranks', 'title': title, 'page': page, 'icon': icon } self.addDir(params) # "KATEGORIE" def getlistsGenre(self, url): query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: printDBG('listsGenre EXCEPTION') r = re.compile( "</div><div id='pSettings' class='panel'>(.+?)</div></div>", re.DOTALL).findall(data) if len(r) > 0: r2 = re.compile("<a href='(.+?)'>(.+?)</a>").findall(r[0]) if len(r2) > 0: for i in range(len(r2)): value = r2[i] title = self.cm.html_entity_decode(value[1]) page = value[0] + '&rowstart=00' params = { 'name': 'genset', 'title': title, 'page': page, 'plot': title, 'icon': '' } self.addDir(params) # ANIME TITLES def getAnimeList(self, url): query_data = { 'url': self.MAINURL + url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) except: printDBG('getAnimeList EXCEPTION') nextPage = False if -1 != data.find("div class='pagenav") and -1 != data.find( "class='img"): nextPage = True else: nextPage = False r = re.compile( "</div><div id='pSeries' class='panel'>(.+?)<div id='footer'>", re.DOTALL).findall(data) if len(r) > 0: r2 = re.compile( "</a><div class='con'><a href='/(.+?)'>(.+?)</a><p>").findall( r[0]) if len(r2) > 0: for i in range(len(r2)): value = r2[i] title = self.cm.html_entity_decode(value[1]) page = value[0] data = self.MAINURL + "/" + value[0] data2 = self.cm.getURLRequestData({ 'url': data, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }) #Cover grafika = re.search( "</div><div class='content'><div class='con'><a href='(.+?)' class='fbox'>", data2) if grafika: icon = self.MAINURL + grafika.group(1) else: icon = '' #Description match = re.search( "<h2>Opis anime</h2></div><div class='content'><div class='con'>(.+?)</div>", data2) if match: plot = match.group(1) else: match = re.search( "<h2>Opis anime</h2></div><div class='content'><div class='con'>(.+?)<", data2) if match: plot = match.group(1) else: match = re.search( "<h2>Opis anime</h2></div><.+?>(.+?)<", data2) if match: plot = match.group(1) else: plot = '' params = { 'name': 'episodelist', 'title': title, 'page': page, 'icon': icon, 'plot': self.cm.html_entity_decode(plot) } self.addDir(params) if nextPage is True: nextpage = url[:-2] + str(int(url[-2:]) + 10) params = { 'name': 'nextpage', 'title': 'Next page', 'page': nextpage } self.addDir(params) # EPISODES LIST def getEpisodeList(self, url): query_data = { 'url': url + '/odcinki', 'use_host': True, 'host': self.HOST, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True } query_data1 = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True } try: data = self.cm.getURLRequestData(query_data) # episodes data data2 = self.cm.getURLRequestData(query_data1) # cover, desc. data except: printExc() # Description match = re.search( "<h2>Opis anime</h2></div><div class='content'><div class='con'>(.+?)</div>", data2) if match: plot = match.group(1) else: match = re.search( "<h2>Opis anime</h2></div><div class='content'><div class='con'>(.+?)<", data2) if match: plot = match.group(1) else: match = re.search("<h2>Opis anime</h2></div><.+?>(.+?)<", data2) if match: plot = match.group(1) else: plot = '' # Cover grafika = re.search( "</div><div class='content'><div class='con'><a href='(.+?)' class='fbox'>", data2) if grafika: icon = self.MAINURL + grafika.group(1) else: icon = '' # Episodes match = re.compile( "<span class='head2'>Statystyki:</span>(.+?)<div class='mainCon'>", re.DOTALL).findall(data) if len(match) > 0: match2 = re.compile( "#(.+?)</div><div class=.+?</div><div class='con3'><a href='(.+?)' class='i'>" ).findall(match[0]) if len(match2) > 0: for i in range(len(match2)): value = match2[i] page = self.MAINURL + value[1] title = 'Odcinek ' + value[0] params = { 'title': title, 'page': page, 'plot': self.cm.html_entity_decode(plot), 'icon': icon } self.addVideo(params) def handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') if 0 == refresh: if len(self.currList) <= index: printDBG( "handleService wrong index: %s, len(self.currList): %d" % (index, len(self.currList))) return if -1 == index: # use default value self.currItem = {"name": None} printDBG("handleService for first self.category") else: self.currItem = self.currList[index] name = self.currItem.get("name", '') title = self.currItem.get("title", '') category = self.currItem.get("category", '') page = self.currItem.get("page", '') icon = self.currItem.get("icon", '') printDBG("handleService: |||||||||||||||||||||||||||||||| [%s] " % name) self.currList = [] if str(page) == 'None' or page == '': page = '0' # Fill the Menu #MAIN MENU if name is None: #logowanie if self.usePremiumAccount: self.requestLoginData() self.listsMainMenu(self.SERVICE_MENU_TABLE) #LISTA ANIME (Alfabetycznie) elif category == self.setTable()[1]: self.listsABCMenu(self.cm.makeABCList()) elif name == 'abc-menu': url = '/lista-anime?letter=' + category + '&rowstart=00' self.getAnimeList(url) elif name == 'nextpage': self.getAnimeList(page) #LISTA ANIME (wg. Gatunku) # elif category == self.setTable()[2]: # url = self.MAINURL + '/lista-anime' # self.getlistsGenre(url) # elif name == 'genset': # self.getAnimeList(page) #LISTA ANIME (wg. Rankingu) elif category == self.setTable()[2]: url = self.MAINURL + '/ranking-anime' self.getlistsRanks(url) elif name == 'ranks': self.getEpisodeList(page) #ULUBIONE elif category == self.setTable()[3]: url = self.MAINURL + '/moja-lista/' + self.username self.getlistsUlubione(url) elif name == 'ulubione': self.getEpisodeList(page) #AKTUALNOŚCI elif category == self.setTable()[4]: url = self.MAINURL + '/newsy' self.getlistsNews(url) elif name == 'news': self.getlistsNews(page) #Episodes will not display without this: #Episodes list elif name == 'episodelist': url = self.MAINURL + '/' + page self.getEpisodeList(url)