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): 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 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 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)
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)
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 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)
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 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)
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 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 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 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 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)