class Kinotan(CBaseHostClass): def __init__(self): CBaseHostClass.__init__(self, { 'history': 'Kinotan', 'cookie': 'Kinotan.cookie' }) self.moonwalkParser = MoonwalkParser() self.hdgocc = HdgoccParser() self.HEADER = {'User-Agent': 'Mozilla/5.0', 'Accept': 'text/html'} self.AJAX_HEADER = dict(self.HEADER) self.AJAX_HEADER.update({'X-Requested-With': 'XMLHttpRequest'}) self.MAIN_URL = 'http://kinotan.ru/' self.DEFAULT_ICON_URL = 'http://ipic.su/img/img7/fs/logo2.1460442551.png' self.MAIN_CAT_TAB = [{ 'category': 'cat_serials', 'title': _('Serials'), 'url': self.getFullUrl('/serial/') }, { 'category': 'cat_tv_shows', 'title': _('TV shows'), 'url': self.getFullUrl('/tv-shou/') }, { 'category': 'cat_mult', 'title': _('Cartoons'), 'url': self.getFullUrl('/multserial/') }, { 'category': 'search', 'title': _('Search'), 'search_item': True }, { 'category': 'search_history', 'title': _('Search history') }] self.SERIALS_CAT_TAB = [{ 'category': 'genre', 'title': _('Genre selection'), 'url': self.getFullUrl('/serial/') }, { 'category': 'country', 'title': _('By country'), 'url': self.getFullUrl('/serial/') }, { 'category': 'trans', 'title': _('Translations'), 'url': self.getFullUrl('/serial/') }, { 'category': 'sel', 'title': _('Collections'), 'url': self.getFullUrl('/serial/') }, { 'category': 'years', 'title': _('By Year'), 'url': self.getFullUrl('/serial/') }] self.cacheContentTab = {} def getPage(self, url, params={}, post_data=None): sts, data = self.cm.getPage(url, params, post_data) return sts, data def listMainMenu(self, cItem, category): printDBG("Kinotan.listCategories") sts, data = self.getPage(cItem['url']) if not sts: return datac = self.cm.ph.getDataBeetwenMarkers(data, '<ul class="head-menu">', '</ul>', False)[1] datac = re.compile( '<a[^"]+?href="([^"]*?)"[^>]*?>(.*?)</a></li>').findall(datac) for item in datac: if item[0] in [ '/novosti/', 'http://kinotan.ru/skoro/', 'http://kinotan.ru/index.php?do=orderdesc' ]: continue params = dict(cItem) params.update({ 'category': category, 'title': item[1], 'url': self.getFullUrl(item[0]) }) self.addDir(params) self.listsTab(self.MAIN_CAT_TAB, {'name': 'category'}) def listGenre(self, cItem, category): printDBG("Kinotan.listGenre") sts, data = self.getPage(cItem['url']) if not sts: return datag = self.cm.ph.getDataBeetwenMarkers( data, '<ul class="main-menu clearfix">', '</ul>', False)[1] datag = re.compile('<a[^"]+?href="([^"]*?)">(.*?)</a></li>').findall( datag) for item in datag: params = dict(cItem) params.update({ 'category': category, 'title': item[1], 'url': self.getFullUrl(item[0]) }) self.addDir(params) def listCountry(self, cItem, category): printDBG("Kinotan.listCountry") sts, data = self.getPage(cItem['url']) if not sts: return datacn = self.cm.ph.getDataBeetwenMarkers(data, '<div class="navigright2">', '</div>', False)[1] datacn = re.compile('href="(/xf[^"]*?)"[^>]+?>(.*?)</a><br>').findall( datacn) for item in datacn: params = dict(cItem) params.update({ 'category': category, 'title': item[1], 'url': self.getFullUrl(item[0][1:]) }) self.addDir(params) def listTrans(self, cItem, category): printDBG("Kinotan.listTrans") sts, data = self.getPage(cItem['url']) if not sts: return datatr = self.cm.ph.getDataBeetwenMarkers(data, '<div class="navigright3">', '</div>', False)[1] datatr = re.compile('href="(/xf[^"]*?)"[^>]+?>(.*?)</a><br>').findall( datatr) for item in datatr: params = dict(cItem) params.update({ 'category': category, 'title': item[1], 'url': self.getFullUrl(item[0][1:]) }) self.addDir(params) def listSel(self, cItem, category): printDBG("Kinotan.listSel") sts, data = self.getPage(cItem['url']) if not sts: return data1 = self.cm.ph.getDataBeetwenMarkers(data, '<div class="navigright">', '</div>', False)[1] datasl = re.compile('href="(/xf[^"]*?)"[^>]+?>(.*?)</a><br>').findall( data1) for item in datasl: params = dict(cItem) params.update({ 'category': category, 'title': item[1], 'url': self.getFullUrl(item[0][1:]) }) self.addDir(params) def listYears(self, cItem, category): printDBG("Kinotan.listYears") sts, data = self.getPage(cItem['url']) if not sts: return data1 = self.cm.ph.getDataBeetwenMarkers(data, '<div class="navigright">', '</div>', False)[1] datay = re.compile('href="(/t[^"]*?)"[^>]+?>(.*?)</a><br>').findall( data1) for item in datay: params = dict(cItem) params.update({ 'category': category, 'title': item[1][:-2], 'url': self.getFullUrl(item[0][1:]) }) self.addDir(params) def listItems(self, cItem, category): printDBG("Kinotan.listItems") tmp = cItem['url'].split('?') url = tmp[0] if len(tmp) > 1: args = cItem.get('title', None) url = self.SRCH_URL + args page = cItem.get('page', 1) if page > 1: url += 'page/%s/' % page post_data = cItem.get('post_data', None) sts, data = self.getPage(url, {}, post_data) if not sts: return nextPage = False if ('/page/%s/' % (page + 1)) in data: nextPage = True data = self.cm.ph.getDataBeetwenMarkers(data, '<div class="short-item">', '</div></div>', False)[1] data = data.split('<div class="short-item">') for item in data: url = self.cm.ph.getSearchGroups(item, '<h3>.*"(.*?)">.*</a>')[0] icon = self.cm.ph.getSearchGroups(item, 'src="(.*?)"')[0][1:] icon = self.getFullUrl(icon) title = self.cm.ph.getSearchGroups(item, '<h3>.*".*">(.*?)</a>')[0] desc1 = self.cm.ph.getSearchGroups(item, 'label">(.*?)</div>')[0] desc2 = self.cm.ph.getSearchGroups(item, 'update3">(.*?)</div>')[0] desc = desc1 + ': ' + desc2 params = dict(cItem) params.update({ 'category': category, 'title': title, 'icon': self.getFullUrl(icon), 'desc': desc, 'url': self.getFullUrl(url) }) self.addDir(params) if nextPage: params = dict(cItem) params.update({ 'title': _('Next page'), 'page': cItem.get('page', 1) + 1 }) self.addDir(params) def listIndexes(self, cItem, nextCategory, nextCategory2): printDBG("Kinotan.listIndexes") sts, data = self.getPage(cItem['url']) if not sts: return idx = 0 tmp = self.cm.ph.getAllItemsBeetwenNodes(data, ('<div', '>', 'news-item'), ('</div', '>')) for item in tmp: url = self.getFullUrl( self.cm.ph.getSearchGroups(item, '''\shref=['"]([^'^"]+?)['"]''', 1, True)[0]) if url == '' and idx == 0: url = cItem['url'] title = self.cleanHtmlStr(item) if url == '': continue params = dict(cItem) params.update({ 'good_for_fav': False, 'category': nextCategory, 'title': title, 'url': url }) self.addDir(params) if len(self.currList) < 2: self.currList = [] cItem = dict(cItem) self.listContent(cItem, nextCategory2, data) def listContent(self, cItem, category, data=None): printDBG("Kinotan.listContent") self.cacheContentTab = {} if data == None: sts, data = self.getPage(cItem['url']) if not sts: return tabs = [] tmp = self.cm.ph.getAllItemsBeetwenMarkers(data, '<div id="videotabs_', '</div>') printDBG(tmp) for item in tmp: title = self.cleanHtmlStr(item) tab_block = self.cm.ph.getSearchGroups(item, '''re_xfn="([^"]+?)"''')[0] tab_id = self.cm.ph.getSearchGroups(item, '''re_idnews="([0-9]+?)"''')[0] tab_page = self.cm.ph.getSearchGroups(item, '''re_page="([0-9]+?)"''')[0] printDBG('>>>>>>>>> tab_block[%s] tab_id[%s] tab_page[%s]' % (tab_block, tab_id, tab_page)) if '' != tab_block and '' != tab_id and '' != tab_page: post_data = { 'block': tab_block, 'id': tab_id, 'page': tab_page } tabs.append({ 'title': title, 'url': self.getFullUrl('/engine/ajax/re_video_part.php'), 'post_data': post_data }) if len(tabs): params = dict(cItem) params['category'] = 'list_tab_content' self.listsTab(tabs, params) return tmp = self.cm.ph.getDataBeetwenMarkers(data, 'RalodePlayer.init(', '"});', False)[1] if tmp != '': try: tmp = byteify(json.loads('[' + tmp + '"}]'))[0] for sKey in tmp: tabs = [] sTitle = self.cleanHtmlStr(tmp[sKey]['name']) sId = self.cleanHtmlStr(tmp[sKey]['id']) for eKey in tmp[sKey]['items']: title = self.cleanHtmlStr( tmp[sKey]['items'][eKey]['sname']) url = self.cm.ph.getSearchGroups( tmp[sKey]['items'][eKey]['scode'], 'src="([^"]*?)"')[0] if url.startswith('//'): url = 'http:' + url try: sortVal = int( self.cm.ph.getSearchGroups( ' %s ' % title, '''[^0-9]([0-9]+?)[^0-9]''')[0]) except Exception: sortVal = 0 tabs.append({ 'title': title, 'sort_value': sortVal, 'url': url }) if len(tabs): tabs.sort(key=lambda item: item['sort_value']) params = dict(cItem) params.update({ 'category': 'list_tab_content', 'title': sTitle, 'tab_id': sId }) self.addDir(params) self.cacheContentTab[sId] = tabs except Exception: printExc() d_url = self.cm.ph.getDataBeetwenMarkers(data, '<div class="full-text">', '</iframe>', False)[1] url = self.cm.ph.getSearchGroups(d_url, 'src="([^"]*?)"')[0] if url.startswith('//'): url = 'http:' + url desc = self.cm.ph.getDataBeetwenMarkers(data, '<h2 class="opisnie">', '</div>', True)[1] desc = self.cm.ph.getSearchGroups(desc, '>(.*?)</div>')[0] desc = self.cleanHtmlStr(desc) self.exploreLink(cItem, category, url, desc) def exploreLink(self, cItem, category, url, desc=''): title = cItem['title'] params = dict(cItem) params['desc'] = desc params['url'] = url hostName = self.up.getHostName(url) if hostName in ['serpens.nl', 'daaidaij.com', '37.220.36.15']: hostName = 'moonwalk.cc' params.update({'category': category, 'serie_title': title}) if hostName == 'moonwalk.cc' and '/serial/' in url: seasons = self.moonwalkParser.getSeasonsList(url) for item in seasons: param = dict(params) param.update({ 'host_name': 'moonwalk', 'title': item['title'], 'season_id': item['id'], 'url': item['url'] }) self.addDir(param) return elif hostName == 'hdgo.cc': url = strwithmeta(url, {'Referer': cItem['url']}) seasons = self.hdgocc.getSeasonsList(url) for item in seasons: param = dict(params) param.update({ 'host_name': 'hdgo.cc', 'title': item['title'], 'season_id': item['id'], 'url': item['url'] }) self.addDir(param) if 0 != len(seasons): return seasonUrl = url episodes = self.hdgocc.getEpiodesList(seasonUrl, -1) for item in episodes: param = dict(params) param.update({ 'title': '{0} - {1} - s01e{2} '.format(title, item['title'], item['id']), 'url': item['url'] }) self.addVideo(param) if 0 != len(episodes): return if 1 == self.up.checkHostSupport(url): self.addVideo(params) def listTabContent(self, cItem, category): printDBG("Kinotan.listTabContent") tabId = cItem.get('tab_id', '') if tabId != '': tabs = self.cacheContentTab[tabId] for item in tabs: params = dict(cItem) params['title'] = item['title'] self.exploreLink(params, category, item['url']) else: post_data = cItem.get('post_data') sts, data = self.getPage(cItem['url'], {}, post_data) if not sts: return printDBG("==========================================") printDBG(data) printDBG("==========================================") url = data.strip() if url.startswith('http://') or url.startswith('https://'): self.exploreLink(cItem, category, url) def listEpisodes(self, cItem): printDBG("Kinotan.listEpisodes") title = cItem['serie_title'] id = cItem['season_id'] hostName = cItem['host_name'] episodes = [] if hostName == 'moonwalk': episodes = self.moonwalkParser.getEpiodesList(cItem['url'], id) elif hostName == 'hdgo.cc': episodes = self.hdgocc.getEpiodesList(cItem['url'], id) for item in episodes: params = dict(cItem) params.update({ 'title': '{0} - s{1}e{2} {3}'.format(title, id, item['id'], item['title']), 'url': item['url'] }) self.addVideo(params) def listSearchResult(self, cItem, searchPattern, searchType): #searchPattern = 'сезон' post_data = { 'do': 'search', 'titleonly': 3, 'subaction': 'search', 'story': searchPattern } sts, data = self.getPage(self.getMainUrl(), post_data=post_data) if not sts: return m1 = '<div class="short-item">' data = self.cm.ph.getDataBeetwenMarkers(data, m1, '<div class="navigright">', False)[1] data = data.split(m1) for item in data: title = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<h3', '</h3>')[1]) if title == '': title = self.cleanHtmlStr( self.cm.ph.getSearchGroups( item, '''alt=['"]([^'^"]+?)['"]''')[0]) icon = self.getFullIconUrl( self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0]) url = self.getFullUrl( self.cm.ph.getSearchGroups(item, '''href=['"]([^'^"]+?)['"]''')[0]) desc = self.cleanHtmlStr( self.cm.ph.getDataBeetwenMarkers(item, '<a', '</a>')[1]) if self.cm.isValidUrl(url): params = dict(cItem) params.update({ 'category': 'list_content', 'title': title, 'icon': icon, 'desc': desc, 'url': url }) self.addDir(params) def getLinksForVideo(self, cItem): printDBG("Kinotan.getLinksForVideo [%s]" % cItem) urlTab = [] urlTab.append({ 'name': 'Main url', 'url': cItem['url'], 'need_resolve': 1 }) return urlTab def getVideoLinks(self, videoUrl): printDBG("Kinotan.getVideoLinks [%s]" % videoUrl) urlTab = [] if videoUrl.startswith('http'): urlTab = self.up.getVideoLinkExt(videoUrl) return urlTab def getFavouriteData(self, cItem): return cItem['url'] def getLinksForFavourite(self, fav_data): return self.getLinksForVideo({'url': fav_data}) def handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') printDBG( "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] " % (name, category)) self.currList = [] # MAIN MENU if name == None: self.listsTab(self.MAIN_CAT_TAB, {'name': 'category'}) elif category == 'cat_tv_shows': self.listItems(self.currItem, 'list_indexes') elif category == 'cat_mult': self.listItems(self.currItem, 'list_indexes') # SERIALES elif category == 'cat_serials': self.listsTab(self.SERIALS_CAT_TAB, {'name': 'category'}) elif category == 'genre': self.listGenre(self.currItem, 'list_items') elif category == 'country': self.listCountry(self.currItem, 'list_items') elif category == 'trans': self.listTrans(self.currItem, 'list_items') elif category == 'sel': self.listSel(self.currItem, 'list_items') elif category == 'years': self.listYears(self.currItem, 'list_items') elif category == 'list_items': self.listItems(self.currItem, 'list_indexes') elif category == 'list_indexes': self.listIndexes(self.currItem, 'list_content', 'list_episodes') elif category == 'list_content': self.listContent(self.currItem, 'list_episodes') elif category == 'list_tab_content': self.listTabContent(self.currItem, 'list_episodes') elif category == 'list_episodes': self.listEpisodes(self.currItem) # SEARCH elif category in ["search", "search_next_page"]: cItem = dict(self.currItem) cItem.update({'search_item': False, 'name': 'category'}) self.listSearchResult(cItem, searchPattern, searchType) # HISTORIA SEARCH elif category == "search_history": self.listsHistory({ 'name': 'history', 'category': 'search' }, 'desc', _("Type: ")) else: printExc() CBaseHostClass.endHandleService(self, index, refresh)
class HD1080Online(CBaseHostClass): def __init__(self): CBaseHostClass.__init__(self, { 'history': 'hd1080.online', 'cookie': 'hd1080.online.cookie' }) self.HTTP_HEADER = self.cm.getDefaultHeader(browser='chrome') self.defaultParams = { 'header': self.HTTP_HEADER, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE } self.MAIN_URL = 'https://hd1080.online/' self.DEFAULT_ICON_URL = 'https://spliffmobile.com/1080-x-1920-wallpapers/hd/images/big-next-0001-focus.png' self.cacheLinks = {} self.hdgocc = HdgoccParser() def getPage(self, baseUrl, addParams={}, post_data=None): if addParams == {}: addParams = dict(self.defaultParams) return self.cm.getPage(baseUrl, addParams, post_data) def listMain(self, cItem, nextCategory): printDBG("HD1080Online.listMain") sts, data = self.getPage(self.getMainUrl()) if not sts: return self.setMainUrl(self.cm.meta['url']) tmp = ph.find(data, ('<ul', '>', 'first-menu'), '</ul>', flags=0)[1] tmp = ph.findall(tmp, ('<li', '>'), '</li>', flags=0) for item in tmp: url = self.getFullUrl(ph.search(item, ph.A)[1]) title = ph.clean_html(item) self.addDir( MergeDicts(cItem, { 'category': nextCategory, 'url': url, 'title': title })) data = ph.find(data, ('<aside', '>'), '</aside>')[1] tmp = ph.rfindall(data, '</ul>', ('<div', '>'), flags=0) for section in tmp: section = section.split('</div>', 1) sTitle = ph.clean_html(section[0]) section = ph.findall(section[-1], ('<li', '>'), '</li>', flags=0) subItems = [] for item in section: url = self.getFullUrl(ph.search(item, ph.A)[1]) title = ph.clean_html(item) subItems.append( MergeDicts( cItem, { 'good_for_fav': True, 'category': nextCategory, 'title': title, 'url': url })) if len(subItems): self.addDir( MergeDicts( cItem, { 'category': 'sub_items', 'sub_items': subItems, 'title': sTitle })) MAIN_CAT_TAB = [{ 'category': 'search', 'title': _('Search'), 'search_item': True }, { 'category': 'search_history', 'title': _('Search history'), }] self.listsTab(MAIN_CAT_TAB, cItem) def listSubItems(self, cItem): printDBG("HD1080Online.listSubItems") self.currList = cItem['sub_items'] def listItems(self, cItem, nextCategory): printDBG("HD1080Online.listItems") page = cItem.get('page', 1) sts, data = self.getPage(cItem['url']) if not sts: return self.setMainUrl(self.cm.meta['url']) nextPage = ph.find(data, ('<span', '>', 'pnext'), '</span>', flags=0)[1] nextPage = self.getFullUrl(ph.search(nextPage, ph.A)[1]) data = ph.find(data, ('<div', '>', 'dle-content'), ('<aside', '>'))[1] data = ph.rfindall(data, '</div>', ('<div', '>', 'kino-item')) if data and nextPage: data[-1] = ph.find(data[-1], '<div', ('<div', '>', 'pagi-nav'))[1] for item in data: url = self.getFullUrl(ph.search(item, ph.A)[1]) icon = self.getFullIconUrl(ph.search(item, ph.IMG)[1]) title = self.cleanHtmlStr( ph.find(item, ('<div', '>', 'title'), '</div>', flags=0)[1]) desc = [] tmp = ph.find(item, ('<ul', '>', 'lines'), '<ul', flags=0)[1] tmp = ph.findall(tmp, ('<li', '>'), '</li>', flags=0) for t in tmp: t = ph.clean_html(t) if t: desc.append(t) # rating desc.append( ph.clean_html( ph.rfind(item, ('<div', '>', 'ratig-layer'), ('<b', '>'), flags=0)[1])) t = ph.clean_html( ph.find(item, ('<li', '>', 'current-rating'), '</li>', flags=0)[1]) if t.isdigit(): desc[-1] += ' %s/10' % str(int(t) / 10.0) desc.append( ph.clean_html( ph.find(item, ('<div', '>', 'desc'), '</div>', flags=0)[1])) self.addDir( MergeDicts( cItem, { 'good_for_fav': True, 'category': nextCategory, 'title': title, 'url': url, 'icon': icon, 'desc': '[/br]'.join(desc) })) if nextPage: self.addDir( MergeDicts( cItem, { 'good_for_fav': False, 'title': _('Next page'), 'url': nextPage, 'page': page + 1 })) def exploreItem(self, cItem, nextCategory): printDBG("HD1080Online.exploreItem") self.cacheLinks = {} sts, data = self.getPage(cItem['url']) if not sts: return cUrl = self.cm.meta['url'] self.setMainUrl(cUrl) desc = [] descObj = self.getArticleContent(cItem, data)[0] icon = descObj['images'][0]['url'] baseTitle = descObj['title'] for item in descObj['other_info']['custom_items_list']: desc.append(item[1]) desc = ' | '.join(desc) + '[/br]' + descObj['text'] data = ph.find(data, ('<div', '>', 'player-section'), ('<div', '>', 'ratig'), flags=0)[1] printDBG(data) titles = [] tmp = ph.findall(data, ('<li', '>'), '</li>', flags=0) for t in tmp: titles.append(ph.clean_html(t)) data = ph.findall(data, ('<div', '>', 'player-box'), '</div>', flags=0) for idx, item in enumerate(data): url = self.getFullUrl(ph.search(item, ph.IFRAME)[1]) if not url: continue title = baseTitle if idx < len(titles): title += ' - ' + titles[idx] if ('/video/' in url and '/serials/' in url) or 'playlist' in url: url = strwithmeta(url, {'Referer': cUrl}) seasons = self.hdgocc.getSeasonsList(url) for item in seasons: self.addDir( MergeDicts( cItem, { 'good_for_fav': False, 'prev_url': cUrl, 'category': nextCategory, 'serie_title': baseTitle, 'title': _('Season %s') % item['title'], 'season_id': item['id'], 'url': item['url'], 'icon': icon, 'desc': desc })) if 0 == len(seasons): seasonUrl = url episodes = self.hdgocc.getEpiodesList(seasonUrl, -1) for item in episodes: title = '{0} - {1} - s01e{2} '.format( baseTitle, item['title'], str(item['id']).zfill(2)) self.addVideo({ 'good_for_fav': False, 'type': 'video', 'prev_url': cUrl, 'title': title, 'url': item['url'], 'icon': icon, 'desc': desc }) elif '/video/' in url: self.addVideo({ 'good_for_fav': False, 'prev_url': cUrl, 'title': title, 'url': url, 'icon': icon, 'desc': desc }) else: # trailes ?? self.addVideo({ 'good_for_fav': False, 'prev_url': cUrl, 'title': title, 'url': url, 'icon': icon, 'desc': desc }) def listEpisodes(self, cItem): printDBG("HD1080Online.listEpisodes") title = cItem['serie_title'] id = cItem['season_id'] episodes = self.hdgocc.getEpiodesList(cItem['url'], id) for item in episodes: self.addVideo( MergeDicts( cItem, { 'title': '{0} - s{1}e{2} {3}'.format(title, str(id).zfill(2), str(item['id']).zfill(2), item['title']), 'url': item['url'] })) def listSearchItems(self, cItem, nextCategory): printDBG("HD1080Online.listSearchItems") cItem = dict(cItem) page = cItem.get('page', 1) post_data = cItem['post_data'] if page > 1: post_data.update({ 'search_start': page, 'full_search': 0, 'result_from': (page - 1) * 10 + 1 }) sts, data = self.getPage(cItem['url'], post_data=post_data) if not sts: return self.setMainUrl(self.cm.meta['url']) nextPage = ph.find(data, ('<div', '>', 'pagi-nav'), '</div>', flags=0)[1] nextPage = (ph.search(nextPage, '<a[^>]+?>(\s*%d\s*)<' % (page + 1))[0]) data = ph.findall(data, ('<a', '>', 'sres-wrap'), '</a>') for item in data: url = self.getFullUrl(ph.search(item, ph.A)[1]) icon = self.getFullIconUrl(ph.search(item, ph.IMG)[1]) title = self.cleanHtmlStr( ph.find(item, ('<h', '>'), '</h', flags=0)[1]) desc = [] desc.append( ph.clean_html( ph.find(item, ('<div', '>', 'date'), '</div>', flags=0)[1])) desc.append( ph.clean_html( ph.find(item, ('<div', '>', 'desc'), '</div>', flags=0)[1])) self.addDir( MergeDicts( cItem, { 'good_for_fav': True, 'category': nextCategory, 'title': title, 'url': url, 'icon': icon, 'desc': '[/br]'.join(desc) })) if nextPage: self.addDir( MergeDicts( cItem, { 'good_for_fav': False, 'title': _('Next page'), 'page': page + 1 })) def listSearchResult(self, cItem, searchPattern, searchType): #searchPattern = 'Человек' sts, data = self.getPage(self.getMainUrl()) if not sts: return self.setMainUrl(self.cm.meta['url']) value = ph.search( data, '''var\s*?dle_login_hash\s*?=\s*?['"]([^'^"]+?)['"]''')[0] post_data = { 'query': searchPattern, 'user_hash': value, 'do': 'search', 'subaction': 'search', 'story': searchPattern } self.listSearchItems( MergeDicts( cItem, { 'category': 'list_search_items', 'url': self.getFullUrl('/index.php?do=search'), 'post_data': post_data }), 'explore_item') def getLinksForVideo(self, cItem): linksTab = self.cacheLinks.get(cItem['url'], []) if linksTab: return linksTab linksTab = self.up.getVideoLinkExt(cItem['url']) for item in linksTab: item['need_resolve'] = 1 if len(linksTab): self.cacheLinks[cItem['url']] = linksTab return linksTab def getVideoLinks(self, videoUrl): printDBG("HD1080Online.getVideoLinks [%s]" % videoUrl) # mark requested link as used one if len(self.cacheLinks.keys()): for key in self.cacheLinks: for idx in range(len(self.cacheLinks[key])): if videoUrl in self.cacheLinks[key][idx]['url']: if not self.cacheLinks[key][idx]['name'].startswith( '*'): self.cacheLinks[key][idx][ 'name'] = '*' + self.cacheLinks[key][idx][ 'name'] return [{'name': 'direct', 'url': videoUrl}] def getArticleContent(self, cItem, data=None): printDBG("HD1080Online.getArticleContent [%s]" % cItem) retTab = [] itemsList = [] if not data: url = cItem.get('prev_url', cItem['url']) sts, data = self.getPage(url) if not sts: return [] self.setMainUrl(self.cm.meta['url']) rating = ph.clean_html( ph.find(data, ('<div', '>', 'aggregateRating'), '</div>', flags=0)[1]) data = ph.find(data, ('<div', '>', 'dle-content'), ('<', '>', 'kino-online'), flags=0)[1] title = self.cleanHtmlStr( ph.find(data, ('<h1', '>'), '</h1>', flags=0)[1]) icon = self.getFullIconUrl(ph.search(data, ph.IMG)[1]) desc = self.cleanHtmlStr( ph.find(data, ('<div', '>', 'description'), '</div>', flags=0)[1]) data = ph.find(data, ('<ul', '>', 'opisanie'), '</ul>', flags=0)[1] data = ph.findall(data, ('<b', '</b>'), '</li>', flags=ph.START_S) for idx in range(1, len(data), 2): label = ph.clean_html(data[idx - 1]) value = ph.clean_html(data[idx]) if label and value: itemsList.append((label, value)) itemsList.append((_('Rating'), rating)) if title == '': title = cItem['title'] if icon == '': icon = cItem.get('icon', self.DEFAULT_ICON_URL) if desc == '': desc = cItem.get('desc', '') return [{ 'title': self.cleanHtmlStr(title), 'text': self.cleanHtmlStr(desc), 'images': [{ 'title': '', 'url': self.getFullUrl(icon) }], 'other_info': { 'custom_items_list': itemsList } }] def handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') printDBG("handleService: ||| name[%s], category[%s] " % (name, category)) self.currList = [] #MAIN MENU if name == None: self.listMain({ 'name': 'category', 'type': 'category' }, 'list_items') elif category == 'sub_items': self.listSubItems(self.currItem) elif category == 'list_items': self.listItems(self.currItem, 'explore_item') elif category == 'list_search_items': self.listSearchItems(self.currItem, 'explore_item') elif category == 'explore_item': self.exploreItem(self.currItem, 'list_episodes') elif category == 'list_episodes': self.listEpisodes(self.currItem) #SEARCH elif category == 'search': self.listSearchResult( MergeDicts(self.currItem, { 'search_item': False, 'name': 'category' }), searchPattern, searchType) #HISTORIA SEARCH elif category == "search_history": self.listsHistory({ 'name': 'history', 'category': 'search' }, 'desc', _("Type: ")) else: printExc() CBaseHostClass.endHandleService(self, index, refresh)
class Cinemaxx(CBaseHostClass): def __init__(self): CBaseHostClass.__init__(self, { 'history': 'cinemaxx.cc', 'cookie': 'cinemaxx.cc.cookie' }) self.HTTP_HEADER = self.cm.getDefaultHeader(browser='chrome') self.defaultParams = { 'header': self.HTTP_HEADER, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': self.COOKIE_FILE } self.MAIN_URL = 'http://cinemaxx.cc/' self.DEFAULT_ICON_URL = 'https://fdtech.pl/wp-content/uploads/2017/01/kinowy-40-100k-765x509.jpg' #self.getFullIconUrl('/templates/flat-cinema/images/logo.png') self.cacheLinks = {} self.hdgocc = HdgoccParser() def getPage(self, baseUrl, addParams={}, post_data=None): tries = 0 cUrl = '' while tries < 4: tries += 1 if addParams == {}: addParams = dict(self.defaultParams) sts, data = self.cm.getPage(baseUrl, addParams, post_data) if not sts: return sts, data cUrl = self.cm.meta['url'] if 'DDoS' in data: if tries == 1: rm(self.COOKIE_FILE) continue timestamp = time.time() * 1000 jscode = '' tmp = ph.findall(data, ('<script', '>'), '</script>', flags=0) for item in tmp: if 'xhr.open' in item: jscode = item break js_params = [{'path': GetJSScriptFile('cinemaxx1.byte')}] js_params.append({'code': jscode}) ret = js_execute_ext(js_params) if ret['sts'] and 0 == ret['code']: try: tmp = ret['data'].split('\n', 1) sleep_time = int(float(tmp[1])) tmp = json_loads(tmp[0]) url = self.getFullUrl(tmp['1'], cUrl) params = dict(addParams) params['header'] = MergeDicts(self.HTTP_HEADER, {'Referer': cUrl}) sts2, data2 = self.cm.getPage(url, params) if not sts2: break js_params = [{ 'path': GetJSScriptFile('cinemaxx2.byte') }] js_params.append( {'code': data2 + 'print(JSON.stringify(e2iobj));'}) ret = js_execute_ext(js_params) if ret['sts'] and 0 == ret['code']: cj = self.cm.getCookie(self.COOKIE_FILE) for item in json_loads(ret['data'])['cookies']: for cookieKey, cookieValue in item.iteritems(): cookieItem = cookielib.Cookie( version=0, name=cookieKey, value=cookieValue, port=None, port_specified=False, domain='.' + self.cm.getBaseUrl(cUrl, True), domain_specified=True, domain_initial_dot=True, path='/', path_specified=True, secure=False, expires=time.time() + 3600 * 48, discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False) cj.set_cookie(cookieItem) cj.save(self.COOKIE_FILE, ignore_discard=True) sleep_time -= time.time() * 1000 - timestamp if sleep_time > 0: GetIPTVSleep().Sleep( int(math.ceil(sleep_time / 1000.0))) continue else: break except Exception: printExc() else: break if sts and cUrl: self.cm.meta['url'] = cUrl return sts, data def listMain(self, cItem, nextCategory): printDBG("Cinemaxx.listMain") sts, data = self.getPage(self.getMainUrl()) if not sts: return self.setMainUrl(self.cm.meta['url']) subItems = [] tmp = ph.findall(data, ('<div', '>', 'owl-cat'), '</div>') for item in tmp: icon = self.getFullIconUrl(ph.search(item, ph.IMAGE_SRC_URI_RE)[1]) item = ph.find(item, ('<h2', '>'), '</h2>', flags=0)[1] url = self.getFullUrl(ph.search(item, ph.A_HREF_URI_RE)[1]) title = self.cleanHtmlStr(item) subItems.append( MergeDicts( cItem, { 'good_for_fav': True, 'category': nextCategory, 'title': title, 'url': url })) printDBG(subItems) sections = ph.find(data, ('<div', '>', 'navbar-collapse'), '</div>')[1] sections = ph.rfindall(sections, '</li>', ('<li', '>', 'nav'), flags=0) for section in sections: tmp = ph.findall(section, ('<a', '>'), '</a>', flags=ph.START_S, limits=1) if not tmp: continue sTitle = ph.clean_html(tmp[1]) sUrl = ph.getattr(tmp[0], 'href') if sUrl == '/': self.addDir( MergeDicts( cItem, { 'category': 'sub_items', 'sub_items': subItems, 'title': sTitle })) elif '<ul' in section: subItems = [] section = ph.findall(section, ('<li', '>'), '</li>', flags=0) for item in section: title = ph.clean_html(item) url = self.getFullUrl(ph.search(item, ph.A_HREF_URI_RE)[1]) subItems.append( MergeDicts( cItem, { 'good_for_fav': True, 'category': nextCategory, 'title': title, 'url': url })) if len(subItems): self.addDir( MergeDicts( cItem, { 'category': 'sub_items', 'sub_items': subItems, 'title': sTitle })) else: self.addDir( MergeDicts( cItem, { 'category': nextCategory, 'url': self.getFullUrl(sUrl), 'title': sTitle })) MAIN_CAT_TAB = [{ 'category': 'search', 'title': _('Search'), 'search_item': True }, { 'category': 'search_history', 'title': _('Search history'), }] self.listsTab(MAIN_CAT_TAB, cItem) def listSubItems(self, cItem): printDBG("Cinemaxx.listSubItems") self.currList = cItem['sub_items'] def listItems(self, cItem, nextCategory): printDBG("Cinemaxx.listItems") cItem = dict(cItem) page = cItem.get('page', 1) post_data = cItem.pop('post_data', None) sts, data = self.getPage(cItem['url'], post_data=post_data) if not sts: return self.setMainUrl(self.cm.meta['url']) printDBG(data) tmp = ph.find(data, ('<div', '>', 'pages-numbers'), '</div>')[1] tmp = ph.search(tmp, '''<a([^>]+?)>%s<''' % (page + 1))[0] nextPage = self.getFullUrl(ph.getattr(tmp, 'href')) data = ph.find(data, ('<div', '>', 'shortstory'), ('<div', '>', 'clearfix'))[1] data = ph.rfindall(data, '</div>', ('<div', '>', 'shortstory')) for item in data: url = self.getFullUrl(ph.search(item, ph.A_HREF_URI_RE)[1]) icon = self.getFullIconUrl(ph.search(item, ph.IMAGE_SRC_URI_RE)[1]) title = self.cleanHtmlStr( ph.find(item, ('<h', '>'), '</h', flags=0)[1]) desc = [] tmp = [ ph.find(item, ('<', '>', 'current-rating'), ('</', '>'), flags=0)[1] + '/100' ] tmp.extend(ph.findall(item, ('<span', '>'), '</span>', flags=0)) for t in tmp: t = self.cleanHtmlStr(t) if t: desc.append(t) self.addDir( MergeDicts( cItem, { 'good_for_fav': True, 'category': nextCategory, 'title': title, 'url': url, 'icon': icon, 'desc': ' | '.join(desc) })) if nextPage: self.addDir( MergeDicts( cItem, { 'good_for_fav': False, 'title': _('Next page'), 'url': nextPage, 'page': page + 1 })) def exploreItem(self, cItem, nextCategory): printDBG("Cinemaxx.exploreItem") self.cacheLinks = {} sts, data = self.getPage(cItem['url']) if not sts: return cUrl = self.cm.meta['url'] self.setMainUrl(cUrl) desc = [] descObj = self.getArticleContent(cItem, data)[0] icon = descObj['images'][0]['url'] baseTitle = descObj['title'] for item in descObj['other_info']['custom_items_list']: desc.append(item[1]) desc = ' | '.join(desc) + '[/br]' + descObj['text'] data = ph.find(data, ('<div', '>', 'dle-content'), ('<div', '>', 'fstory-info'), flags=0)[1] trailer = ph.find(data, ('<', '>', '#trailer'), '</div>', flags=0)[1] title = self.cleanHtmlStr(trailer) trailer = self.getFullUrl(ph.search(trailer, ph.IFRAME_SRC_URI_RE)[1]) if trailer: self.addVideo({ 'good_for_fav': True, 'prev_url': cUrl, 'title': '%s %s' % (title, baseTitle), 'url': trailer, 'icon': icon, 'desc': desc }) data = ph.find(data, ('<div', '>', 'full-video'), '</div>', flags=0)[1] url = self.getFullUrl(ph.search(data, ph.IFRAME_SRC_URI_RE)[1]) if url: if ('/video/' in url and '/serials/' in url) or 'playlist' in url: url = strwithmeta(url, {'Referer': cUrl}) seasons = self.hdgocc.getSeasonsList(url) for item in seasons: self.addDir( MergeDicts( cItem, { 'good_for_fav': False, 'prev_url': cUrl, 'category': nextCategory, 'serie_title': baseTitle, 'title': 'Staffel %s' % item['title'], 'season_id': item['id'], 'url': item['url'], 'icon': icon, 'desc': desc })) if 0 != len(seasons): return seasonUrl = url episodes = self.hdgocc.getEpiodesList(seasonUrl, -1) for item in episodes: title = '{0} - {1} - s01e{2} '.format( baseTitle, item['title'], str(item['id']).zfill(2)) self.addVideo({ 'good_for_fav': False, 'type': 'video', 'prev_url': cUrl, 'title': title, 'url': item['url'], 'icon': icon, 'desc': desc }) if 0 != len(episodes): return self.addVideo({ 'good_for_fav': False, 'prev_url': cUrl, 'title': baseTitle, 'url': url, 'icon': icon, 'desc': desc }) else: data = ph.find(data, 'vk.show(', ');', flags=0)[1].split(',', 1)[-1] ret = js_execute('print(JSON.stringify(%s));' % data) if ret['sts'] and 0 == ret['code']: try: data = json_loads(ret['data']) for sNum, season in enumerate(data, 1): subItems = [] for eNum, episode in enumerate(season, 1): title = baseTitle + ' s%se%s' % ( str(sNum).zfill(2), str(eNum).zfill(2)) subItems.append({ 'good_for_fav': False, 'type': 'video', 'prev_url': cUrl, 'title': title, 'url': episode, 'icon': icon, 'desc': desc }) if subItems: self.addDir( MergeDicts( cItem, { 'good_for_fav': False, 'prev_url': cUrl, 'title': 'Staffel %s' % (str(sNum).zfill(2)), 'category': 'sub_items', 'sub_items': subItems })) except Exception: printExc() def listEpisodes(self, cItem): printDBG("Cinemaxx.listEpisodes") title = cItem['serie_title'] id = cItem['season_id'] episodes = self.hdgocc.getEpiodesList(cItem['url'], id) for item in episodes: self.addVideo( MergeDicts( cItem, { 'title': '{0} - s{1}e{2} {3}'.format(title, str(id).zfill(2), str(item['id']).zfill(2), item['title']), 'url': item['url'] })) def listSearchResult(self, cItem, searchPattern, searchType): url = self.getFullUrl( '/api/private/get/search?query=%s&limit=100&f=1' % urllib.quote(searchPattern)) sts, data = self.getPage(self.getMainUrl()) if not sts: return self.setMainUrl(self.cm.meta['url']) value = ph.search( data, '''var\s*?dle_login_hash\s*?=\s*?['"]([^'^"]+?)['"]''')[0] post_data = { 'query': searchPattern, 'user_hash': value, 'do': 'search', 'subaction': 'search', 'story': searchPattern } self.listItems( MergeDicts( cItem, { 'url': self.getFullUrl('/index.php?do=search'), 'post_data': post_data }), 'explore_item') def getLinksForVideo(self, cItem): linksTab = self.cacheLinks.get(cItem['url'], []) if linksTab: return linksTab linksTab = self.up.getVideoLinkExt(cItem['url']) for item in linksTab: item['need_resolve'] = 1 if len(linksTab): self.cacheLinks[cItem['url']] = linksTab return linksTab def getVideoLinks(self, videoUrl): printDBG("Cinemaxx.getVideoLinks [%s]" % videoUrl) # mark requested link as used one if len(self.cacheLinks.keys()): for key in self.cacheLinks: for idx in range(len(self.cacheLinks[key])): if videoUrl in self.cacheLinks[key][idx]['url']: if not self.cacheLinks[key][idx]['name'].startswith( '*'): self.cacheLinks[key][idx][ 'name'] = '*' + self.cacheLinks[key][idx][ 'name'] return [{'name': 'direct', 'url': videoUrl}] def getArticleContent(self, cItem, data=None): printDBG("Cinemaxx.getArticleContent [%s]" % cItem) retTab = [] itemsList = [] if not data: url = cItem.get('prev_url', cItem['url']) sts, data = self.getPage(url) if not sts: return [] self.setMainUrl(self.cm.meta['url']) tmp = ph.find(data, ('<div', '>', 'dle-content'), ('<div', '>', 'fstory-info'), flags=0)[1] title = self.cleanHtmlStr( ph.find(tmp, ('<h1', '>'), '</h1>', flags=0)[1]) icon = self.getFullIconUrl(ph.search(tmp, ph.IMAGE_SRC_URI_RE)[1]) desc = self.cleanHtmlStr( ph.find(data, ('<div', '>', 'fstory-content'), '</div>', flags=0)[1]) data = ph.find(data, ('<div', '>', 'finfo'), ('<div', '>', 'fstory-content'), flags=0)[1] data = ph.rfindall(data, '</div>', ('<div', '>', 'finfo-block'), flags=0) for item in data: key = self.cleanHtmlStr( ph.find(item, ('<div', '>', 'title'), '</div>', flags=0)[1]) if 'current-rating' in item: value = self.cleanHtmlStr( ph.find(item, ('<', '>', 'current-rating'), ('</', '>'), flags=0)[1] + '/100') else: value = self.cleanHtmlStr( ph.find(item, ('<div', '>', 'text'), '</div>', flags=0)[1].rsplit('</ul>', 1)[-1]) itemsList.append((key, value)) if title == '': title = cItem['title'] if icon == '': icon = cItem.get('icon', self.DEFAULT_ICON_URL) if desc == '': desc = cItem.get('desc', '') return [{ 'title': self.cleanHtmlStr(title), 'text': self.cleanHtmlStr(desc), 'images': [{ 'title': '', 'url': self.getFullUrl(icon) }], 'other_info': { 'custom_items_list': itemsList } }] def handleService(self, index, refresh=0, searchPattern='', searchType=''): printDBG('handleService start') CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') printDBG("handleService: ||| name[%s], category[%s] " % (name, category)) self.currList = [] #MAIN MENU if name == None: self.listMain({ 'name': 'category', 'type': 'category' }, 'list_items') elif category == 'sub_items': self.listSubItems(self.currItem) elif category == 'list_items': self.listItems(self.currItem, 'explore_item') elif category == 'explore_item': self.exploreItem(self.currItem, 'list_episodes') elif category == 'list_episodes': self.listEpisodes(self.currItem) #SEARCH elif category in ["search", "search_next_page"]: cItem = dict(self.currItem) cItem.update({'search_item': False, 'name': 'category'}) self.listSearchResult(cItem, searchPattern, searchType) #HISTORIA SEARCH elif category == "search_history": self.listsHistory({ 'name': 'history', 'category': 'search' }, 'desc', _("Type: ")) else: printExc() CBaseHostClass.endHandleService(self, index, refresh)
class Kinopokaz(CBaseHostClass): def __init__(self): CBaseHostClass.__init__(self, {'history':'Kinopokaz', 'cookie':'Kinopokaz.cookie'}) self.catCache = [] self.moonwalkParser = MoonwalkParser() self.hdgocc = HdgoccParser() self.HEADER = {'User-Agent': 'Mozilla/5.0', 'Accept': 'text/html'} self.AJAX_HEADER = dict(self.HEADER) self.AJAX_HEADER.update( {'X-Requested-With': 'XMLHttpRequest'} ) self.MAIN_URL = 'http://online-kinopokaz.ru/' self.DEFAULT_ICON_URL = "http://ipic.su/img/img7/fs/logi.1456142273.png" self.MAIN_CAT_TAB = [{'category':'categories', 'title':_('Movie categories'), 'url':self.getMainUrl()}, {'category':'search', 'title':_('Search'), 'search_item':True }, {'category':'search_history', 'title':_('Search history'), } ] def getPage(self, url, params={}, post_data=None): sts,data = self.cm.getPage(url, params, post_data) return sts,data def getFullUrl(self, url): url = url.replace('&', '&') return CBaseHostClass.getFullUrl(self, url) def listMainMenu(self, cItem, category): printDBG("Kinopokaz.listCategories") sts, data = self.getPage(cItem['url']) if not sts: return if 0 == len(self.catCache): catData = self.cm.ph.getDataBeetwenMarkers(data, 'class="catsTable">', '</table>', False)[1] catData = re.compile('href="(/[^"]+?)"[^>]*?>([^<]+?)<').findall(catData) for item in catData: if item[0] in ['/load/serialy/12','/load/multiplikacionnye/13','/load/anime/24','/load/tv_onlajn/23','/load/trillery/10']: continue params = dict(cItem) params.update({'category':category, 'title':item[1], 'url':self.getFullUrl(item[0])}) self.catCache.append(params) mainMenuData = self.cm.ph.getDataBeetwenMarkers(data, '<ul class="uMenuRoot">', '</ul>', False)[1] mainMenuData = re.compile('href="/([^"]+?)"><span>([^<]+?)</span>').findall(mainMenuData) for item in mainMenuData: if item[0] in ['/load/tv_onlajn/tv_onlajn_prjamoj_ehfir/23-1-0-4951','index/pomoshh/0-2', 'index/stol_zakazov/0-5','index/ne_rabotaet_film/0-6']: continue params = dict(cItem) params.update({'category':category, 'title':item[1], 'url':self.getFullUrl(item[0])}) self.addDir(params) self.listsTab(self.MAIN_CAT_TAB, {'name':'category'}) def listContent(self, cItem, category): printDBG("Kinopokaz.listContent") sts, data = self.getPage(cItem['url']) if not sts: return desc = '' title = cItem['title'] url = cItem['url'] seriesData = self.cm.ph.getDataBeetwenMarkers(data, '<h2 style=', '<div id=', False)[1]# if len(seriesData): desc = self.cm.ph.getDataBeetwenMarkers(data, 'colspan="2">', '<h2 style="text-align:', False)[1] desc = self.cleanHtmlStr(desc) tranData = re.compile('<div align="center">(.*)</div>\n.*\s.+?src="(http:[^"]+?)"').findall(seriesData) if tranData !=[]: params = dict(cItem) params['desc'] = desc for item in tranData: param = dict(params) param.update({'category':'tran', 'title':item[0], 'url':item[1]}) self.addDir(param) return if self.up.getDomain(url) in self.getMainUrl(): tmp = self.cm.ph.getAllItemsBeetwenMarkers(data, '<iframe', '>') for item in tmp: url = self.cm.ph.getSearchGroups(item, '''src=['"]([^"^']+?)['"]''', 1, True)[0] if 1 == self.up.checkHostSupport(url): break params = dict(cItem) params['desc'] = desc params['url'] = strwithmeta(url, {'Referer':cItem['url']}) hostName = self.up.getHostName(url) if hostName in ['serpens.nl', '37.220.36.15']: hostName = 'moonwalk.cc' params.update({'category':category, 'serie_title':title}) if hostName == 'moonwalk.cc' and '/serial/' in url: params.update({'category':category, 'serie_title':title}) season = self.moonwalkParser.getSeasonsList(url) for item in season: param = dict(params) param.update({'host_name':'moonwalk', 'title':item['title'], 'season_id':item['id'], 'url':item['url']}) self.addDir(param) return elif hostName == 'hdgo.cc': url = strwithmeta(url, {'Referer':cItem['url']}) seasons = self.hdgocc.getSeasonsList(url) for item in seasons: param = dict(params) param.update( {'host_name': 'hdgo.cc', 'title': item['title'], 'season_id': item['id'], 'url': item['url']}) self.addDir(param) if 0 != len(seasons): return seasonUrl = url episodes = self.hdgocc.getEpiodesList(seasonUrl, -1) for item in episodes: param = dict(params) param.update( {'title': '{0} - {1} - s01e{2} '.format(title, item['title'], item['id']), 'url': item['url']}) self.addVideo(param) if 0 != len(episodes): return if self.up.checkHostSupport(url) == 1: self.addVideo(params) def listEpisodes(self, cItem): printDBG("Kinopokaz.listEpisodes") title = cItem['serie_title'] id = cItem['season_id'] hostName = cItem['host_name'] episodes = [] if hostName == 'moonwalk': episodes = self.moonwalkParser.getEpiodesList(cItem['url'], id) elif hostName == 'hdgo.cc': episodes = self.hdgocc.getEpiodesList(cItem['url'], id) for item in episodes: params = dict(cItem) params.update( {'title': '{0} - s{1}e{2} {3}'.format(title, id, item['id'], item['title']), 'url': item['url']}) self.addVideo(params) def listItems(self, cItem, category): printDBG("Kinopokaz.listItems") url = cItem['url'] page = cItem.get('page', 1) if page > 1: url += '-' + str(page) post_data = cItem.get('post_data', None) sts, data = self.getPage(url, {}, post_data) if not sts: return nextPage = False if '' != self.cm.ph.getSearchGroups(data, '''spages\(\s*['"](%s)['"]''' % (page+1))[0]: nextPage = True data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<div class="eTitle"', '</table>') for item in data: url = self.cm.ph.getSearchGroups(item, 'href="([^"]+?)"')[0] title = self.cm.ph.getSearchGroups(item, 'alt="([^"]+?)"')[0] if title == '': title = self.cm.ph.getSearchGroups(item, 'href="[^"]+?">(.*?)</a>')[0] title = self.cleanHtmlStr(title) if title == '': continue icon = self.cm.ph.getSearchGroups(item, 'src="([^"]+?)"')[0] data = self.cm.ph.getDataBeetwenMarkers(item, '<div class="eMessage" style=','</p><br>', True)[1] if data == '': data = self.cm.ph.getDataBeetwenMarkers(item, '<div class="eMessage" style=','<br />', True)[1] desc = data.replace(' ', '') desc = self.cleanHtmlStr(desc) params = dict(cItem) params.update({'category':category, 'title':title, 'icon':self.getFullUrl(icon), 'desc':desc, 'url':self.getFullUrl(url)}) self.addDir(params) if nextPage: params = dict(cItem) params.update({'title':_('Next page'), 'page':page+1}) self.addDir(params) def listSearchResult(self, cItem, searchPattern, searchType): #searchPattern = 'Колонна' cItem = dict(cItem) cItem['url'] = self.getFullUrl('search/?q=%s&m=site&m=load&t=0' % urllib.quote_plus(searchPattern)) self.listItems(cItem, 'list_content') def getLinksForVideo(self, cItem): printDBG("Kinopokaz.getLinksForVideo [%s]" % cItem) urlTab = [] urlTab.append({'name':'Main url', 'url':cItem['url'], 'need_resolve':1}) return urlTab def getVideoLinks(self, videoUrl): printDBG("Kinopokaz.getVideoLinks [%s]" % videoUrl) urlTab = [] if videoUrl.startswith('http'): urlTab = self.up.getVideoLinkExt(videoUrl) return urlTab def getFavouriteData(self, cItem): return cItem['url'] def getLinksForFavourite(self, fav_data): return self.getLinksForVideo({'url':fav_data}) def handleService(self, index, refresh = 0, searchPattern = '', searchType = ''): printDBG('handleService start') CBaseHostClass.handleService(self, index, refresh, searchPattern, searchType) name = self.currItem.get("name", '') category = self.currItem.get("category", '') printDBG( "handleService: |||||||||||||||||||||||||||||||||||| name[%s], category[%s] " % (name, category) ) self.currList = [] #MAIN MENU if name == None: self.listMainMenu({'name':'category', 'icon':self.DEFAULT_ICON_URL, 'url':self.MAIN_URL},'list_items') elif category == 'categories': self.listsTab(self.catCache, self.currItem) elif category == 'list_items': self.listItems(self.currItem, 'list_content') elif category == 'list_content': self.listContent(self.currItem, 'tran') elif category == 'tran': self.listContent(self.currItem, 'list_episodes') elif category == 'list_episodes': self.listEpisodes(self.currItem) #SEARCH elif category in ["search", "search_next_page"]: cItem = dict(self.currItem) cItem.update({'search_item':False, 'name':'category'}) self.listSearchResult(cItem, searchPattern, searchType) #HISTORIA SEARCH elif category == "search_history": self.listsHistory({'name':'history', 'category': 'search'}, 'desc', _("Type: ")) else: printExc() CBaseHostClass.endHandleService(self, index, refresh)