def video(video_id, is_episode, lock=None, custom_title=None, series_title=None, ignore_cache=False): video_details = get.video_info(video_id, lock, ignore_cache=ignore_cache) match = json.loads(video_details)['value']['videos'][video_id] # generic_utility.log('parsing videodata: '+str(match)) if custom_title != None: title = custom_title else: title = get_value(match, 'title') year = get_value(match, 'releaseYear', '1900') thumb_url = extract_thumb_url(match) mpaa = get_mpaa(match) duration, playcount = parse_duration_playcount(match) episode, season = parse_episode_seasion(match) type = parse_type(is_episode, match) if type == 'tvshow': duration = '' if generic_utility.get_setting('use_tmdb') == 'true': type_tmdb = 'movie' if type == 'movie' else 'tv' title_tmdb = series_title if series_title != None else title load_tmdb_cover_fanart(title_tmdb, video_id, type_tmdb, year) description = get_decription(match) director = parse_director(match) genre = parse_genre(match) rating = parse_rating(match) movie_metadata = {'title':title, 'video_id':video_id, 'thumb_url': thumb_url, 'type': type, 'description': description, 'duration':duration, 'year':year, 'mpaa':mpaa, \ 'director':director, 'genre':genre, 'rating':rating, 'playcount':playcount, 'episode' : episode, 'season': season} # utility.log(str(video_add_args)) return movie_metadata
def video(video_id, lock = None, custom_title = None, series_title = None, ignore_cache = False): video_details = get.video_info(video_id, lock, ignore_cache = ignore_cache) match = json.loads(video_details)['value']['videos'][video_id] # generic_utility.log('parsing videodata: '+str(match)) if custom_title != None: title = custom_title else: title = get_value(match, 'title') year = get_value(match, 'releaseYear', '1900') thumb_url = extract_thumb_url(match) mpaa = get_mpaa(match) episode, season = parse_episode_seasion(match) type = parse_type(match) # series has no playcount if type != 'show': duration, playcount = parse_duration_playcount(match) else: playcount = 0 duration = '' if generic_utility.get_setting('use_tmdb') == 'true': type_tmdb = 'movie' if type =='movie' else 'tv' title_tmdb = series_title if series_title != None else title load_tmdb_cover_fanart(title_tmdb, video_id, type_tmdb, year) description = get_decription(match) director = parse_director(match) genre = parse_genre(match) rating = parse_rating(match) movie_metadata = {'title':title, 'video_id':video_id, 'thumb_url': thumb_url, 'type': type, 'description': description, 'duration':duration, 'year':year, 'mpaa':mpaa, \ 'director':director, 'genre':genre, 'rating':rating, 'playcount':playcount, 'episode' : episode, 'season': season} # utility.log(str(video_add_args)) return movie_metadata
def video(video_id, title, thumb_url, is_episode, hide_movies, video_type, url): added = False year = '' mpaa = '' duration = '' description = '' director = '' genre = '' rating = 0.0 video_details = get.video_info(video_id) match = re.compile('<span class="title.*?>(.+?)</span', re.DOTALL).findall(video_details) if not title: title = match[0].strip() match = re.compile('<span class="year.*?>(.+?)</span', re.DOTALL).findall(video_details) if match: year = match[0].partition('-')[0] if not thumb_url: match = re.compile('src="(.+?)"', re.DOTALL).findall(video_details) thumb_url = match[0].replace('/webp/', '/images/').replace('.webp', '.jpg') match = re.compile('<span class="mpaaRating.*?>(.+?)</span', re.DOTALL).findall(video_details) if match: mpaa = match[0].strip() match = re.compile('<span class="duration.*?>(.+?)</span', re.DOTALL).findall(video_details) if match: duration = match[0].lower() if duration.split(' ')[-1].startswith('min'): type = 'movie' video_type_temp = type duration = duration.split(' ')[0] else: video_type_temp = 'tv' if is_episode: type = 'episode' else: type = 'tvshow' duration = '' if utility.get_setting('use_tmdb') == 'true': year_temp = year title_temp = title if ' - ' in title_temp: title_temp = title_temp[title_temp.index(' - '):] if '-' in year_temp: year_temp = year_temp.split('-')[0] filename = utility.clean_filename(video_id) + '.jpg' filename_none = utility.clean_filename(video_id) + '.none' cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename) cover_file_none = xbmc.translatePath(utility.cover_cache_dir() + filename_none) if not (xbmcvfs.exists(cover_file) or xbmcvfs.exists(cover_file_none)): utility.log( 'Downloading cover art. type: %s, video_id: %s, title: %s, year: %s' % (video_type_temp, video_id, title_temp, year_temp)) get.cover(video_type_temp, video_id, title_temp, year_temp) match = re.compile('src=".+?">.*?<.*?>(.+?)<', re.DOTALL).findall(video_details) if match: description_temp = match[0] # replace all embedded unicode in unicode (Norwegian problem) description_temp = description_temp.replace('u2013', unicode('\u2013')).replace( 'u2026', unicode('\u2026')) description = utility.unescape(description_temp) match = re.compile('Director:</dt><dd>(.+?)<', re.DOTALL).findall(video_details) if match: director = match[0].strip() match = re.compile('<span class="genre.*?>(.+?)</span', re.DOTALL).findall(video_details) if match: genre = match[0] match = re.compile('<span class="rating">(.+?)</span', re.DOTALL).findall(video_details) if len(match) > 0: rating = float(match[0]) title = utility.unescape(title) next_mode = 'play_video_main' if utility.get_setting('browse_tv_shows') == 'true' and type == 'tvshow': next_mode = 'list_seasons' if '/my-list' in url and video_type_temp == video_type: add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating, remove=True) added = True elif type == 'movie' and hide_movies: pass elif video_type_temp == video_type or video_type == 'both': add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating) added = True return added
def video(video_id, title, thumb_url, is_episode, hide_movies, video_type, url): added = False director = '' genre = '' playcount = 0 video_details = get.video_info(video_id) match = json.loads(video_details)['value']['videos'][video_id] if not title: title = match['title'] year = match['releaseYear'] if not thumb_url: try: thumb_url = match['boxarts']['_665x375']['jpg']['url'] except Exception: try: thumb_url = match['boxarts']['_342x192']['jpg']['url'] except Exception: thumb_url = utility.addon_fanart() mpaa = match['maturity']['rating']['value'] duration = match['runtime'] offset = match['bookmarkPosition'] try: if (duration > 0 and float(offset) / float(duration)) >= 0.9: playcount = 1 except Exception: pass type = match['summary']['type'] if type == 'movie': video_type_temp = type else: video_type_temp = 'tv' if is_episode: type = 'episode' else: type = 'tvshow' duration = '' if utility.get_setting('use_tmdb') == 'true': year_temp = year title_temp = title if ' - ' in title_temp: title_temp = title_temp[title_temp.index(' - '):] filename = video_id + '.jpg' filename_none = video_id + '.none' cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename) cover_file_none = xbmc.translatePath(utility.cover_cache_dir() + filename_none) if not (xbmcvfs.exists(cover_file) or xbmcvfs.exists(cover_file_none)): utility.log('Downloading cover art. type: %s, video_id: %s, title: %s, year: %s' % (video_type_temp, video_id, title_temp, year_temp)) get.cover(video_type_temp, video_id, title_temp, year_temp) description = match['details']['synopsis'] try: director = match['details']['directors'][0]['name'] except Exception: pass try: genre = match['details']['genres'][0]['name'] except Exception: pass rating = match['userRating']['average'] next_mode = 'play_video_main' if utility.get_setting('browse_tv_shows') == 'true' and type == 'tvshow': next_mode = 'list_seasons' if '/my-list' in url and video_type_temp == video_type: add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating, playcount, remove=True) added = True elif type == 'movie' and hide_movies: pass elif video_type_temp == video_type or video_type == 'both': add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating, playcount) added = True return added
def video(video_id, title, thumb_url, is_episode, hide_movies, video_type, url): added = False director = '' genre = '' playcount = 0 video_details = get.video_info(video_id) match = json.loads(video_details)['value']['videos'][video_id] if not title: title = match['title'] year = match['releaseYear'] if not thumb_url: try: thumb_url = match['boxarts']['_665x375']['jpg']['url'] except Exception: try: thumb_url = match['boxarts']['_342x192']['jpg']['url'] except Exception: thumb_url = utility.addon_fanart() mpaa = match['maturity']['rating']['value'] duration = match['runtime'] offset = match['bookmarkPosition'] try: if (duration > 0 and float(offset) / float(duration)) >= 0.9: playcount = 1 except Exception: pass type = match['summary']['type'] if type == 'movie': video_type_temp = type else: video_type_temp = 'tv' if is_episode: type = 'episode' else: type = 'tvshow' duration = '' if utility.get_setting('use_tmdb') == 'true': year_temp = year title_temp = title if ' - ' in title_temp: title_temp = title_temp[title_temp.index(' - '):] filename = video_id + '.jpg' filename_none = video_id + '.none' cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename) cover_file_none = xbmc.translatePath(utility.cover_cache_dir() + filename_none) if not (xbmcvfs.exists(cover_file) or xbmcvfs.exists(cover_file_none)): utility.log( 'Downloading cover art. type: %s, video_id: %s, title: %s, year: %s' % (video_type_temp, video_id, title_temp, year_temp)) get.cover(video_type_temp, video_id, title_temp, year_temp) description = match['details']['synopsis'] try: director = match['details']['directors'][0]['name'] except Exception: pass try: genre = match['details']['genres'][0]['name'] except Exception: pass rating = match['userRating']['average'] next_mode = 'play_video_main' if utility.get_setting('browse_tv_shows') == 'true' and type == 'tvshow': next_mode = 'list_seasons' if '/my-list' in url and video_type_temp == video_type: add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating, playcount, remove=True) added = True elif type == 'movie' and hide_movies: pass elif video_type_temp == video_type or video_type == 'both': add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating, playcount) added = True return added
def video(video_id, title, thumb_url, is_episode, hide_movies, video_type, url): added = False year = '' mpaa = '' duration = '' description = '' director = '' genre = '' rating = 0.0 video_details = get.video_info(video_id) match = re.compile('<span class="title.*?>(.+?)</span', re.DOTALL).findall(video_details) if not title: title = match[0].strip() match = re.compile('<span class="year.*?>(.+?)</span', re.DOTALL).findall(video_details) if match: year = match[0].partition('-')[0] if not thumb_url: match = re.compile('src="(.+?)"', re.DOTALL).findall(video_details) thumb_url = match[0].replace('/webp/', '/images/').replace('.webp', '.jpg') match = re.compile('<span class="mpaaRating.*?>(.+?)</span', re.DOTALL).findall(video_details) if match: mpaa = match[0].strip() match = re.compile('<span class="duration.*?>(.+?)</span', re.DOTALL).findall(video_details) if match: duration = match[0].lower() if duration.split(' ')[-1].startswith('min'): type = 'movie' video_type_temp = type duration = duration.split(' ')[0] else: video_type_temp = 'tv' if is_episode: type = 'episode' else: type = 'tvshow' duration = '' if utility.get_setting('use_tmdb') == 'true': year_temp = year title_temp = title if ' - ' in title_temp: title_temp = title_temp[title_temp.index(' - '):] if '-' in year_temp: year_temp = year_temp.split('-')[0] filename = utility.clean_filename(video_id) + '.jpg' filename_none = utility.clean_filename(video_id) + '.none' cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename) cover_file_none = xbmc.translatePath(utility.cover_cache_dir() + filename_none) if not (xbmcvfs.exists(cover_file) or xbmcvfs.exists(cover_file_none)): utility.log('Downloading cover art. type: %s, video_id: %s, title: %s, year: %s' % (video_type_temp, video_id, title_temp, year_temp)) get.cover(video_type_temp, video_id, title_temp, year_temp) match = re.compile('src=".+?">.*?<.*?>(.+?)<', re.DOTALL).findall(video_details) if match: description_temp = match[0] # replace all embedded unicode in unicode (Norwegian problem) description_temp = description_temp.replace('u2013', unicode('\u2013')).replace('u2026', unicode('\u2026')) description = utility.unescape(description_temp) match = re.compile('Director:</dt><dd>(.+?)<', re.DOTALL).findall(video_details) if match: director = match[0].strip() match = re.compile('<span class="genre.*?>(.+?)</span', re.DOTALL).findall(video_details) if match: genre = match[0] match = re.compile('<span class="rating">(.+?)</span', re.DOTALL).findall(video_details) if len(match) > 0: rating = float(match[0]) title = utility.unescape(title) next_mode = 'play_video_main' if utility.get_setting('browse_tv_shows') == 'true' and type == 'tvshow': next_mode = 'list_seasons' if '/my-list' in url and video_type_temp == video_type: add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating, remove=True) added = True elif type == 'movie' and hide_movies: pass elif video_type_temp == video_type or video_type == 'both': add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa, director, genre, rating) added = True return added