def download_img(self, img_url, filename): # if at start there was NOT enough space on disk # new icon will not be downloaded if False == self.downloadNew: return False if len(self.currDownloadDir) < 4: printDBG('IconMenager.download_img: wrong path for IPTVCache') return False path = self.currDownloadDir + '/' # if at start there was enough space on disk # we will check if we still have free space if 0 >= self.checkSpace: printDBG('IconMenager.download_img: checking space on device') if not iptvtools_FreeSpace(path, 10): printDBG('IconMenager.download_img: not enough space for new icons, new icons will not be downloaded any more') self.downloadNew = False return False else: # for another 50 check again self.checkSpace = 50 else: self.checkSpace -= 1 file_path = "%s%s" % (path, filename) params = {'maintype': 'image'} if config.plugins.iptvplayer.allowedcoverformats.value != 'all': params['subtypes'] = config.plugins.iptvplayer.allowedcoverformats.value.split(',') return self.cm.saveWebFile(file_path, img_url, params)['sts']
def download_img(self, img_url, filename): # if at start there was NOT enough space on disk # new icon will not be downloaded if False == self.downloadNew: return False if len(self.currDownloadDir) < 4: printDBG('IconMenager.download_img: wrong path for IPTVCache') return False path = self.currDownloadDir + '/' # if at start there was enough space on disk # we will check if we still have free space if 0 >= self.checkSpace: printDBG('IconMenager.download_img: checking space on device') if not iptvtools_FreeSpace(path, 10): printDBG( 'IconMenager.download_img: not enough space for new icons, new icons will not be downloaded any more' ) self.downloadNew = False return False else: # for another 50 check again self.checkSpace = 50 else: self.checkSpace -= 1 file_path = "%s%s" % (path, filename) params = {} #{'maintype': 'image'} if config.plugins.iptvplayer.allowedcoverformats.value != 'all': subtypes = config.plugins.iptvplayer.allowedcoverformats.value.split( ',') #params['subtypes'] = subtypes params['check_first_bytes'] = [] if 'jpeg' in subtypes: params['check_first_bytes'].extend(['\xFF\xD8', '\xFF\xD9']) if 'png' in subtypes: params['check_first_bytes'].append('\x89\x50\x4E\x47') if 'gif' in subtypes: params['check_first_bytes'].extend(['GIF87a', 'GIF89a']) else: params['check_first_bytes'] = [ '\xFF\xD8', '\xFF\xD9', '\x89\x50\x4E\x47', 'GIF87a', 'GIF89a' ] if img_url.endswith('need_resolve.jpeg'): domain = urlparser.getDomain(img_url) if domain.startswith('www.'): domain = domain[4:] # link need resolve, at now we will have only one img resolver, # we should consider add img resolver to urlparser if more will be needed sts, data = self.cm.getPage(img_url) if not sts: return False if 'imdb.com' in domain: img_url = self.cm.ph.getDataBeetwenMarkers( data, 'class="poster"', '</div>')[1] img_url = self.cm.ph.getSearchGroups(img_url, 'src="([^"]+?)"')[0] if not self.cm.isValidUrl(img_url): img_url = self.cm.ph.getDataBeetwenMarkers( data, 'class="slate"', '</div>')[1] img_url = self.cm.ph.getSearchGroups( img_url, 'src="([^"]+?)"')[0] elif 'bs.to' in domain: baseUrl = img_url img_url = self.cm.ph.getSearchGroups( data, '(<img[^>]+?alt="Cover"[^>]+?>)')[0] img_url = self.cm.ph.getSearchGroups(img_url, 'src="([^"]+?)"')[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'watchseriesmovie.' in domain or 'gowatchseries' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<div', '>', 'picture'), ('</div', '>'), False)[1] img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?)"')[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'classiccinemaonline.com' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<center>', '</center>', '<img'), ('<', '>'))[1] img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(:?\?[^"]+?)?)"')[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'nasze-kino.tv' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<div', '>', 'single-poster'), ('<img', '>'))[1] img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(:?\?[^"]+?)?)"')[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'allbox.' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<img', '>', '"image"'), ('<', '>'))[1] if img_url != '': img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(:?\?[^"]+?)?)"' )[0] else: img_url = self.cm.ph.getSearchGroups( data, 'url\(([^"^\)]+?\.(:?jpe?g|png)(:?\?[^"^\)]+?)?)\);' )[0].strip() if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'efilmy.' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<img', '>', 'align="left"'), ('<', '>'))[1] img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(:?\?[^"]+?)?)"')[0] img_url = self.cm.getFullUrl(img_url, baseUrl) elif 'bajeczki.org' == domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<img', '>', 'wp-post-image'), ('<', '>'))[1] if img_url != '': img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(?:\?[^"]+?)?)"' )[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif '7tv.de' == domain: data = ph.find(data, ('<meta', '>', 'thumbnail_image_url'))[1] img_url = ph.getattr(data, 'content') if not self.cm.isValidUrl(img_url): return False else: img_url = strwithmeta(img_url) if img_url.meta.get('icon_resolver', None) is not None: try: img_url = img_url.meta['icon_resolver'](self.cm, img_url) except Exception: printExc() return False if not self.cm.isValidUrl(img_url): return False return self.cm.saveWebFile(file_path, img_url, params)['sts']
def listCategory(self, cItem, searchMode=False): printDBG("Urllist.listCategory cItem[%s]" % cItem) sortList = config.plugins.iptvplayer.sortuj.value filespath = config.plugins.iptvplayer.Sciezkaurllist.value groupList = config.plugins.iptvplayer.grupujurllist.value if cItem['category'] in ['all', Urllist.URLLIST_FILE, Urllist.URRLIST_STREAMS, Urllist.URRLIST_USER, Urllist.RAFALCOOL1_FILE]: self.currFileHost = IPTVFileHost() if cItem['category'] in ['all', Urllist.RAFALCOOL1_FILE] and config.plugins.iptvplayer.urllist_showrafalcool1.value: self.updateRafalcoolFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8') self.currFileHost.addFile(filespath + Urllist.RAFALCOOL1_FILE, encoding='utf-8') if cItem['category'] in ['all', Urllist.URLLIST_FILE]: self.currFileHost.addFile(filespath + Urllist.URLLIST_FILE, encoding='utf-8') if cItem['category'] in ['all', Urllist.URRLIST_STREAMS]: self.currFileHost.addFile(filespath + Urllist.URRLIST_STREAMS, encoding='utf-8') if cItem['category'] in ['all', Urllist.URRLIST_USER]: self.currFileHost.addFile(filespath + Urllist.URRLIST_USER, encoding='utf-8') if 'all' != cItem['category'] and groupList: tmpList = self.currFileHost.getGroups(sortList) for item in tmpList: if '' == item: title = (_("Other")) else: title = item params = {'name': 'category', 'category':'group', 'title':title, 'group':item} self.addDir(params) else: tmpList = self.currFileHost.getAllItems(sortList) for item in tmpList: desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url']) if item['desc'] != '': desc = item['desc'] params = {'title':item['full_title'], 'url':item['url'], 'desc':desc, 'icon':item['icon']} self.addVideo(params) elif 'group' in cItem: tmpList = self.currFileHost.getItemsInGroup(cItem['group'], sortList) if 'j00zekFork' in globals(): if iptvtools_FreeSpace(config.plugins.iptvplayer.SciezkaCache.value, 10): downloadPath = config.plugins.iptvplayer.SciezkaCache.value cacheTMDB = True else: downloadPath = config.plugins.iptvplayer.NaszaTMP.value cacheTMDB = False for item in tmpList: if '' == item['title_in_group']: title = item['full_title'] else: title = item['title_in_group'] if 'j00zekFork' in globals(): if item.get('desc', '') == '' and item.get('icon', '') == '' and config.plugins.iptvplayer.useTMDB.value == True: desc, cover = downloadData(item['url'], title, config.plugins.iptvplayer.wgetpath.value, downloadPath, cacheTMDB ) else: desc = item.get('desc', '') cover = item.get('icon', '') params = {'title':title, 'url':item['url'], 'desc': desc, 'icon':cover} else: desc = (_("Hosting: %s, %s")) % (self._getHostingName(item['url']), item['url']) if item.get('desc', '') != '': desc = item['desc'] params = {'title':title, 'url':item['url'], 'desc': desc, 'icon':item.get('icon', '')} self.addVideo(params)
def download_img(self, img_url, filename): # if at start there was NOT enough space on disk # new icon will not be downloaded if False == self.downloadNew: return False if len(self.currDownloadDir) < 4: printDBG('IconMenager.download_img: wrong path for IPTVCache') return False path = self.currDownloadDir + '/' # if at start there was enough space on disk # we will check if we still have free space if 0 >= self.checkSpace: printDBG('IconMenager.download_img: checking space on device') if not iptvtools_FreeSpace(path, 10): printDBG( 'IconMenager.download_img: not enough space for new icons, new icons will not be downloaded any more' ) self.downloadNew = False return False else: # for another 50 check again self.checkSpace = 50 else: self.checkSpace -= 1 file_path = "%s%s" % (path, filename) params = {'maintype': 'image'} if config.plugins.iptvplayer.allowedcoverformats.value != 'all': params[ 'subtypes'] = config.plugins.iptvplayer.allowedcoverformats.value.split( ',') params['check_first_bytes'] = [] if 'jpeg' in params['subtypes']: params['check_first_bytes'].extend(['\xFF\xD8', '\xFF\xD9']) if 'png' in params['subtypes']: params['check_first_bytes'].append('\x89\x50\x4E\x47') if 'gif' in params['subtypes']: params['check_first_bytes'].extend(['GIF87a', 'GIF89a']) else: params['check_first_bytes'] = [ '\xFF\xD8', '\xFF\xD9', '\x89\x50\x4E\x47', 'GIF87a', 'GIF89a' ] if img_url.endswith('need_resolve.jpeg' ) and 'imdb.com' in urlparser.getDomain(img_url): # link need resolve, at now we will have only one img resolver, # we should consider add img resolver to urlparser if more will be needed sts, data = self.cm.getPage(img_url) if not sts: return False img_url = self.cm.ph.getDataBeetwenMarkers(data, 'class="poster"', '</div>')[1] img_url = self.cm.ph.getSearchGroups(img_url, 'src="([^"]+?)"')[0] if not self.cm.isValidUrl(img_url): img_url = self.cm.ph.getDataBeetwenMarkers( data, 'class="slate"', '</div>')[1] img_url = self.cm.ph.getSearchGroups(img_url, 'src="([^"]+?)"')[0] if not self.cm.isValidUrl(img_url): return False else: img_url = strwithmeta(img_url) if img_url.meta.get('icon_resolver', None) is not None: try: img_url = img_url.meta['icon_resolver'](self.cm, img_url) except Exception: printExc() return False if not self.cm.isValidUrl(img_url): return False return self.cm.saveWebFile(file_path, img_url, params)['sts']