def add_trakt_subscription_listitem(self, db_type, ids, count, total, path, dialog): try: get_ids = get_trakt_movie_id if db_type in ( 'movie', 'movies') else get_trakt_tvshow_id meta_action = tikimeta.movie_meta if db_type in ( 'movie', 'movies') else tikimeta.tvshow_meta tmdb_id = get_ids(ids) address_insert = 'movie' if db_type in ('movie', 'movies') else 'tv' meta = meta_action('tmdb_id', tmdb_id, self.meta_user_info) title = clean_file_name(meta['title']) year = meta['year'] if 'year' in meta else '0' rootname = '{0} ({1})'.format(title, year) if year != '0' else title folder = os.path.join(path, rootname + '/') nfo_filename = rootname + '.nfo' if db_type in ( 'movie', 'movies') else 'tvshow.nfo' nfo_filepath = os.path.join(folder, nfo_filename) nfo_content = "https://www.themoviedb.org/%s/%s-%s" % ( address_insert, str(meta['tmdb_id']), title.lower().replace( ' ', '-')) self.make_folder(folder) self.make_nfo(nfo_filepath, nfo_content) if db_type in ('movie', 'movies'): in_library = get_library_video( 'movie', title, year) if settings.skip_duplicates() else False if in_library: return stream_file = self.create_movie_strm_files(folder, rootname) params = to_utf8({ 'mode': 'play_media', 'library': 'True', 'query': rootname, 'poster': meta['poster'], 'year': year, 'plot': meta['plot'], 'title': title, 'tmdb_id': meta['tmdb_id'], 'vid_type': 'movie' }) self.make_stream(stream_file, params) else: self.create_tvshow_strm_files(meta, folder, tmdb_id, title, year) dialog.update(int(float(count) / float(total) * 100), '', 'Adding: [B]%s[/B]' % rootname) except Exception as e: logger('add_trakt_subscription_listitem Exception', e) pass
def make_stream(self, stream_file, params): if not xbmcvfs.exists(stream_file): from modules.nav_utils import build_url file = xbmcvfs.File(stream_file, 'w') content = build_url(params) file.write(str(content)) file.close() if self.add_release_date: try: premiered = params['premiered'] adjusted_time = settings.date_to_timestamp(premiered) os.utime(stream_file, (adjusted_time, adjusted_time)) except Exception as e: logger('make_stream Exception', e) pass
def results(self, info): try: self.info = info self.db_type = self.info.get("db_type") self.title = self.info.get("title") self.year = self.info.get("year") if self.year: self.rootname = '%s (%s)' % (self.title, self.year) else: self.rootname = self.title self.season = self.info.get("season", None) self.episode = self.info.get("episode", None) self.extensions = supported_video_extensions() self.folder_query = clean_title(normalize(self.title)) self.query_list = self._year_query_list() if self.db_type == 'movie' else self._episode_query_list() self._scrape_cloud() self._scrape_history() if not self.scrape_results: return self.sources self.label_settings = label_settings(self.info['scraper_settings'], self.scrape_provider) for item in self.scrape_results: try: direct_debrid_link = item.get('direct_debrid_link', False) folder_name = normalize(item['folder_name']) file_name = self._get_filename(item['path']) file_dl = item['url_link'] size = float(item['bytes'])/1073741824 video_quality = get_release_quality(file_name, folder_name) details = get_file_info(file_name) if not details: details = get_file_info(folder_name) label, multiline_label = build_internal_scrapers_label(self.label_settings, file_name, details, size, video_quality) self.sources.append({'name': file_name, 'label': label, 'multiline_label': multiline_label, 'title': file_name, 'quality': video_quality, 'size': size, 'url_dl': file_dl, 'id': file_dl, 'downloads': False, 'direct': True, 'source': self.scrape_provider, 'scrape_provider': self.scrape_provider, 'direct_debrid_link': direct_debrid_link}) except: pass window.setProperty('rd-cloud_source_results', json.dumps(self.sources)) except Exception as e: from modules.utils import logger logger('FEN real-debrid scraper Exception', e) return self.sources
def results(self, info): try: self.info = info search_name = self._search_name() files = EasyNews.search(search_name) files = files[0:self.max_results] self.label_settings = label_settings(self.info['scraper_settings'], self.scrape_provider) for item in files: try: if self.max_bytes: match = re.search('([\d.]+)\s+(.*)', item['size']) if match: size_bytes = self.to_bytes(*match.groups()) if size_bytes > self.max_bytes: continue file_name = normalize(item['name']) file_dl = item['url_dl'] size = float(int(item['rawSize'])) / 1073741824 details = get_file_info(file_name) video_quality = get_release_quality(file_name, file_dl) label, multiline_label = build_internal_scrapers_label( self.label_settings, file_name, details, size, video_quality) self.sources.append({ 'name': file_name, 'label': label, 'multiline_label': multiline_label, 'quality': video_quality, 'size': size, 'url_dl': file_dl, 'id': file_dl, 'local': False, 'direct': True, 'source': self.scrape_provider, 'scrape_provider': self.scrape_provider }) except: pass window.setProperty('easynews_source_results', json.dumps(self.sources)) except Exception as e: from modules.utils import logger logger('FEN easynews scraper Exception', e) return self.sources
def account(self): try: from bs4 import BeautifulSoup account_html = self._get(self.account_link) if account_html == None or account_html == '': raise Exception() account_html = BeautifulSoup(account_html, "html.parser") account_html = account_html.find_all('form', id='accountForm')[0] account_html = account_html.find_all('table', recursive=False)[0] account_html = account_html.find_all('tr', recursive=False) usage_html = self._get(self.usage_link) if usage_html == None or usage_html == '': raise Exception() usage_html = BeautifulSoup(usage_html, "html.parser") usage_html = usage_html.find_all('div', class_='table-responsive')[0] usage_html = usage_html.find_all('table', recursive=False)[0] usage_html = usage_html.find_all('tr', recursive=False) return account_html, usage_html except Exception as e: from modules.utils import logger logger('easynews API account error', e)
def results(self, info): try: self.info = info self.db_type = self.info.get("db_type") self.title = self.info.get("title") self.year = self.info.get("year") self.season = self.info.get("season") self.episode = self.info.get("episode") self.db_info = self._get_library_video(self.db_type, self.title, self.year, self.season, self.episode) if not self.db_info: return self.sources self.label_settings = label_settings(self.info['scraper_settings'], self.scrape_provider) file_name = self.db_info.get("name") file_id = self.db_info.get("file_id") file_dl = self.db_info.get("file_id") size = self._get_size(file_dl) details = get_file_info(file_name) video_quality = get_release_quality(file_name, file_dl) label, multiline_label = build_internal_scrapers_label( self.label_settings, file_name, details, size, video_quality) self.sources.append({ 'name': file_name, 'label': label, 'multiline_label': multiline_label, 'quality': video_quality, 'size': size, 'url_dl': file_dl, 'url': file_dl, 'id': file_id, 'local': True, 'direct': True, 'source': self.scrape_provider, 'scrape_provider': self.scrape_provider }) window.setProperty('local_source_results', json.dumps(self.sources)) except Exception as e: from modules.utils import logger logger('FEN local scraper Exception', e) return self.sources
def results(self, info): try: self.info = info search_name = self._search_name() files = Furk.search(search_name) if not files: return self.sources active_downloads = self.get_active_downloads() cached_files = [ i for i in files if i.get('type') not in ('default', 'audio', '') and i.get('is_ready') == '1' ][0:self.furk_limit] uncached_files = [ i for i in files if i.get('type') not in ('default', 'audio', '') and i not in cached_files ] self.label_settings = label_settings(self.info['scraper_settings'], self.scrape_provider) for i in cached_files: try: file_name = normalize(i['name']) file_id = i['id'] files_num_video = i['files_num_video'] size = float(int(i['size'])) / 1073741824 if not int(files_num_video) > 3: if size > self.max_gb: continue file_dl = i['url_dl'] details = get_file_info(file_name) video_quality = get_release_quality(file_name, file_dl) furk_settings = { 'files_num_video': files_num_video, 'uncached': False, 'active_download': False } label, multiline_label = build_internal_scrapers_label( self.label_settings, file_name, details, size, video_quality, **furk_settings) self.sources.append({ 'name': file_name, 'label': label, 'multiline_label': multiline_label, 'title': file_name, 'quality': video_quality, 'size': size, 'url_dl': file_dl, 'id': file_id, 'local': False, 'direct': True, 'source': self.scrape_provider, 'scrape_provider': self.scrape_provider }) except Exception as e: from modules.utils import logger logger('FURK ERROR - 65', e) pass for i in uncached_files: try: file_name = i['name'] info_hash = i['info_hash'] try: files_num_video = i['files_num_video'] except: files_num_video = 1 try: size = float(int(i['size'])) / 1073741824 except: size = 0 active_download = True if info_hash in active_downloads else False details = get_file_info(file_name) video_quality = get_release_quality(file_name) furk_settings = { 'files_num_video': files_num_video, 'uncached': True, 'active_download': active_download } label, multiline_label = build_internal_scrapers_label( self.label_settings, file_name, details, size, video_quality, **furk_settings) self.sources.append({ 'name': file_name, 'label': label, 'multiline_label': multiline_label, 'title': file_name, 'quality': video_quality, 'size': size, 'url_dl': info_hash, 'id': info_hash, 'local': False, 'direct': True, 'uncached': True, 'source': self.scrape_provider, 'scrape_provider': self.scrape_provider }) except Exception as e: from modules.utils import logger logger('FURK ERROR - 96', e) pass window.setProperty( 'furk_source_results', json.dumps([i for i in self.sources if not 'uncached' in i])) except Exception as e: from modules.utils import logger logger('FEN furk scraper Exception', e) pass return self.sources
def results(self, info): try: self.info = info self.db_type = self.info.get("db_type") self.folder_path = settings.source_folders_directory( self.db_type, self.scrape_provider) if not self.folder_path: return self.sources self.title = self.info.get("title") self.year = self.info.get("year") self.season = self.info.get("season") self.episode = self.info.get("episode") self.title_query = clean_title(self.title) self.folder_query = self._season_query_list( ) if self.db_type == 'episode' else self._year_query_list() self.file_query = self._episode_query_list( ) if self.db_type == 'episode' else self._year_query_list() cache_name = 'fen_%s_SCRAPER_%s_%s_%s_%s' % ( self.scrape_provider, self.title, self.year, self.season, self.episode) cache = _cache.get(cache_name) if cache: self.scrape_results = cache else: self._scrape_directory(self.folder_path) _cache.set(cache_name, self.scrape_results, expiration=datetime.timedelta(hours=2)) if not self.scrape_results: return self.sources self.label_settings = label_settings(self.info['scraper_settings'], 'folders', self.scraper_name) for item in self.scrape_results: try: file_name = item[0] file_dl = item[1] size = self._get_size( file_dl) if not file_dl.endswith('.strm') else 'strm' details = get_file_info(file_name) video_quality = get_release_quality(file_name, file_dl) label, multiline_label = build_internal_scrapers_label( self.label_settings, file_name, details, size, video_quality) self.sources.append({ 'name': file_name, 'label': label, 'multiline_label': multiline_label, 'title': file_name, 'quality': video_quality, 'size': size, 'url_dl': file_dl, 'id': file_dl, self.scrape_provider: True, 'direct': True, 'source': self.scrape_provider, 'scrape_provider': self.scrape_provider }) except: pass window.setProperty('%s_source_results' % self.scrape_provider, json.dumps(self.sources)) except Exception as e: from modules.utils import logger logger('FEN folders scraper Exception', e) return self.sources
def create_tvshow_strm_files(self, meta=None, folder=None, tmdb_id=None, title=None, year=None): from datetime import date from modules.utils import to_utf8 from modules.kodi_library import get_library_video if not meta: meta = self.meta if not folder: folder = self.folder if not tmdb_id: tmdb_id = self.tmdb_id if not title: title = self.title if not year: year = self.year try: skip_duplicates = settings.skip_duplicates() season_data = tikimeta.all_episodes_meta( meta['tmdb_id'], meta['tvdb_id'], meta['tvdb_summary']['airedSeasons'], meta['season_data'], self.meta_user_info) season_data = [ i for i in season_data if not i['season_number'] == 0 ] for i in season_data: try: season_path = os.path.join( folder, 'Season ' + str(i['season_number'])) self.make_folder(season_path) ep_data = i['episodes_data'] for item in ep_data: try: in_library = get_library_video( 'episode', title, year, item['airedSeason'], item['airedEpisodeNumber'] ) if skip_duplicates else None if not in_library: first_aired = item[ 'firstAired'] if 'firstAired' in item else None try: d = first_aired.split('-') episode_date = date( int(d[0]), int(d[1]), int(d[2])) except: episode_date = date(2100, 10, 24) if date.today() > episode_date: display = "%s S%.2dE%.2d" % ( title, int(item['airedSeason']), int(item['airedEpisodeNumber'])) stream_file = os.path.join( season_path, str(display) + '.strm') params = to_utf8({ 'mode': 'play_media', 'library': 'True', 'query': title, 'year': year, 'plot': item['overview'], 'poster': meta['poster'], 'season': item['airedSeason'], 'episode': item['airedEpisodeNumber'], 'ep_name': item['episodeName'], 'premiered': item['firstAired'], 'tmdb_id': tmdb_id, 'vid_type': 'episode' }) self.make_stream(stream_file, params) except: pass except: pass except: logger('meta', meta['search_title']) pass
def run(self, url=None): params = dict(parse_qsl(sys.argv[2].replace('?', ''))) rootname = params.get('rootname', '') url = url if url else params.get("url") if 'url' in params else None url = unquote(url) if not url: return try: if rootname in ('video', 'music'): p_list = xbmc.PLAYLIST_VIDEO if rootname == 'video' else xbmc.PLAYLIST_MUSIC playlist = xbmc.PlayList(p_list) playlist.clear() listitem = xbmcgui.ListItem() listitem.setInfo(type=rootname, infoLabels={}) playlist.add(url, listitem) return self.play(playlist) self.meta = json.loads(window.getProperty('fen_media_meta')) rootname = self.meta['rootname'] if 'rootname' in self.meta else '' bookmark = self.bookmarkChoice() if bookmark == -1: return self.meta.update({'url': url, 'bookmark': bookmark}) listitem = xbmcgui.ListItem(path=url) try: if self.meta.get('use_animated_poster', False): poster = self.meta.get('gif_poster') else: poster = self.meta.get('poster') listitem.setProperty('StartPercent', str(self.meta.get('bookmark'))) listitem.setArt({ 'poster': poster, 'fanart': self.meta.get('fanart'), 'banner': self.meta.get('banner'), 'clearart': self.meta.get('clearart'), 'clearlogo': self.meta.get('clearlogo'), 'landscape': self.meta.get('landscape'), 'discart': self.meta.get('discart') }) listitem.setCast(self.meta['cast']) if self.meta['vid_type'] == 'movie': listitem.setUniqueIDs({ 'imdb': str(self.meta['imdb_id']), 'tmdb': str(self.meta['tmdb_id']) }) listitem.setInfo( 'video', { 'mediatype': 'movie', 'trailer': str(self.meta['trailer']), 'title': self.meta['title'], 'size': '0', 'duration': self.meta['duration'], 'plot': self.meta['plot'], 'rating': self.meta['rating'], 'premiered': self.meta['premiered'], 'studio': self.meta['studio'], 'year': self.meta['year'], 'genre': self.meta['genre'], 'tagline': self.meta['tagline'], 'code': self.meta['imdb_id'], 'imdbnumber': self.meta['imdb_id'], 'director': self.meta['director'], 'writer': self.meta['writer'], 'votes': self.meta['votes'] }) elif self.meta['vid_type'] == 'episode': listitem.setUniqueIDs({ 'imdb': str(self.meta['imdb_id']), 'tmdb': str(self.meta['tmdb_id']), 'tvdb': str(self.meta['tvdb_id']) }) listitem.setInfo( 'video', { 'mediatype': 'episode', 'trailer': str(self.meta['trailer']), 'title': self.meta['ep_name'], 'imdbnumber': self.meta['imdb_id'], 'tvshowtitle': self.meta['title'], 'size': '0', 'plot': self.meta['plot'], 'year': self.meta['year'], 'votes': self.meta['votes'], 'premiered': self.meta['premiered'], 'studio': self.meta['studio'], 'genre': self.meta['genre'], 'season': int(self.meta['season']), 'episode': int(self.meta['episode']), 'duration': str(self.meta['duration']), 'rating': self.meta['rating'] }) except Exception as e: from modules.utils import logger logger('exception in meta set code', e) pass library_item = True if 'from_library' in self.meta else False if library_item: xbmcplugin.setResolvedUrl(__handle__, True, listitem) else: self.play(url, listitem) self.monitor() except Exception as e: from modules.utils import logger logger('exception in main code', e) return