From 678343fb1f499f53cf7198df1b1499f3be8ef148 Mon Sep 17 00:00:00 2001 From: anxdpanic Date: Fri, 9 Dec 2022 15:08:14 -0500 Subject: [PATCH] revert tags --- .../resource.language.en_gb/strings.po | 80 --- .../resource.language.en_us/strings.po | 80 --- .../resource.language.ru_ru/strings.po | 80 --- .../lib/youtube_plugin/youtube/helper/tags.py | 167 ------ .../youtube_plugin/youtube/helper/utils.py | 26 +- .../lib/youtube_plugin/youtube/helper/v3.py | 28 - .../youtube/helper/yt_context_menu.py | 39 -- .../youtube/helper/yt_specials.py | 37 -- .../lib/youtube_plugin/youtube/provider.py | 512 ++++++------------ resources/settings.xml | 1 - 10 files changed, 178 insertions(+), 872 deletions(-) delete mode 100644 resources/lib/youtube_plugin/youtube/helper/tags.py diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 0a3936632..4214e5068 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -1242,83 +1242,3 @@ msgstr "" msgctxt "#30736" msgid "Hide short videos (1 minute or less)" msgstr "" - -msgctxt "#30900" -msgid "Subscriptions groups" -msgstr "" - -msgctxt "#30901" -msgid "Add to group" -msgstr "" - -msgctxt "#30902" -msgid "Remove from group" -msgstr "" - -msgctxt "#30903" -msgid "Delete group" -msgstr "" - -msgctxt "#30904" -msgid "Create new group" -msgstr "" - -msgctxt "#30905" -msgid "Enter a name for new group" -msgstr "" - -msgctxt "#30906" -msgid "Group '%s' created" -msgstr "" - -msgctxt "#30907" -msgid "Are you sure you want to remove group '%s'?" -msgstr "" - -msgctxt "#30908" -msgid "Group '%s' removed" -msgstr "" - -msgctxt "#30909" -msgid "Select new group for channel '%s'" -msgstr "" - -msgctxt "#30910" -msgid "Сhannel '%s' added to group '%s'" -msgstr "" - -msgctxt "#30911" -msgid "Are you sure you want remove channel '%s' from group '%s'?" -msgstr "" - -msgctxt "#30912" -msgid "Сhannel '%s' removed from group '%s'" -msgstr "" - -msgctxt "#30913" -msgid "[Without groups]" -msgstr "" - -msgctxt "#30914" -msgid "Move to other group" -msgstr "" - -msgctxt "#30915" -msgid "Select new group for channel '%s' from group '%s'" -msgstr "" - -msgctxt "#30916" -msgid "Сhannel '%s' moved from group '%s' to group '%s'" -msgstr "" - -msgctxt "#30917" -msgid "Rename group" -msgstr "" - -msgctxt "#30918" -msgid "Enter a new name for group" -msgstr "" - -msgctxt "#30919" -msgid "Group '%s' renamed to '%s'" -msgstr "" diff --git a/resources/language/resource.language.en_us/strings.po b/resources/language/resource.language.en_us/strings.po index 8b9f9cbab..43053c507 100644 --- a/resources/language/resource.language.en_us/strings.po +++ b/resources/language/resource.language.en_us/strings.po @@ -1235,83 +1235,3 @@ msgstr "" msgctxt "#30736" msgid "Hide short videos (1 minute or less)" msgstr "" - -msgctxt "#30900" -msgid "Subscriptions groups" -msgstr "" - -msgctxt "#30901" -msgid "Add to group" -msgstr "" - -msgctxt "#30902" -msgid "Remove from group" -msgstr "" - -msgctxt "#30903" -msgid "Delete group" -msgstr "" - -msgctxt "#30904" -msgid "Create new group" -msgstr "" - -msgctxt "#30905" -msgid "Enter a name for new group" -msgstr "" - -msgctxt "#30906" -msgid "Group '%s' created" -msgstr "" - -msgctxt "#30907" -msgid "Are you sure you want to remove group '%s'?" -msgstr "" - -msgctxt "#30908" -msgid "Group '%s' removed" -msgstr "" - -msgctxt "#30909" -msgid "Select new group for channel '%s'" -msgstr "" - -msgctxt "#30910" -msgid "Сhannel '%s' added to group '%s'" -msgstr "" - -msgctxt "#30911" -msgid "Are you sure you want remove channel '%s' from group '%s'?" -msgstr "" - -msgctxt "#30912" -msgid "Сhannel '%s' removed from group '%s'" -msgstr "" - -msgctxt "#30913" -msgid "[Without groups]" -msgstr "" - -msgctxt "#30914" -msgid "Move to other group" -msgstr "" - -msgctxt "#30915" -msgid "Select new group for channel '%s' from group '%s'" -msgstr "" - -msgctxt "#30916" -msgid "Сhannel '%s' moved from group '%s' to group '%s'" -msgstr "" - -msgctxt "#30917" -msgid "Rename group" -msgstr "" - -msgctxt "#30918" -msgid "Enter a new name for group" -msgstr "" - -msgctxt "#30919" -msgid "Group '%s' renamed to '%s'" -msgstr "" diff --git a/resources/language/resource.language.ru_ru/strings.po b/resources/language/resource.language.ru_ru/strings.po index ddf740136..1fe116861 100644 --- a/resources/language/resource.language.ru_ru/strings.po +++ b/resources/language/resource.language.ru_ru/strings.po @@ -1235,83 +1235,3 @@ msgstr "Изменен" msgctxt "#30736" msgid "Hide short videos (1 minute or less)" msgstr "" - -msgctxt "#30900" -msgid "Subscriptions groups" -msgstr "Группы подписок" - -msgctxt "#30901" -msgid "Add to group" -msgstr "Добавить в группу" - -msgctxt "#30902" -msgid "Remove from group" -msgstr "Удалить из группы" - -msgctxt "#30903" -msgid "Delete group" -msgstr "Удалить группу" - -msgctxt "#30904" -msgid "Create new group" -msgstr "Создать группу" - -msgctxt "#30905" -msgid "Enter a name for new group" -msgstr "Введите название новой группы" - -msgctxt "#30906" -msgid "Group '%s' created" -msgstr "Группа '%s' создана" - -msgctxt "#30907" -msgid "Are you sure you want to remove group '%s'?" -msgstr "Вы уверены, что хотите удалить группу '%s'?" - -msgctxt "#30908" -msgid "Group '%s' removed" -msgstr "Группа '%s' удалена" - -msgctxt "#30909" -msgid "Select new group for channel '%s'" -msgstr "Выберете новую группу для канала '%s'" - -msgctxt "#30910" -msgid "Сhannel '%s' added to group '%s'" -msgstr "Канал '%s' добавлен в группу '%s'" - -msgctxt "#30911" -msgid "Are you sure you want remove channel '%s' from group '%s'?" -msgstr "Вы уверены, что хотите удалить канал '%s' из группы '%s'?" - -msgctxt "#30912" -msgid "Сhannel '%s' removed from group '%s'" -msgstr "Канал '%s' удален из группы '%s'" - -msgctxt "#30913" -msgid "[Without groups]" -msgstr "[Без групп]" - -msgctxt "#30914" -msgid "Move to other group" -msgstr "Переместить в другую группу" - -msgctxt "#30915" -msgid "Select new group for channel '%s' from group '%s'" -msgstr "Выберете новую группу для канала '%s' из группы '%s'" - -msgctxt "#30916" -msgid "Сhannel '%s' moved from group '%s' to group '%s'" -msgstr "Канал '%s' перемещен из группы '%s' в группу '%s'" - -msgctxt "#30917" -msgid "Rename group" -msgstr "Переименовать группу" - -msgctxt "#30918" -msgid "Enter a new name for group" -msgstr "Введите новое название группы" - -msgctxt "#30919" -msgid "Group '%s' renamed to '%s'" -msgstr "Группа '%s' переименована в '%s'" diff --git a/resources/lib/youtube_plugin/youtube/helper/tags.py b/resources/lib/youtube_plugin/youtube/helper/tags.py deleted file mode 100644 index 8adecdbdb..000000000 --- a/resources/lib/youtube_plugin/youtube/helper/tags.py +++ /dev/null @@ -1,167 +0,0 @@ -# -*- coding: utf-8 -*- -""" - - Copyright (C) 2014-2016 bromix (plugin.video.youtube) - Copyright (C) 2016-2018 plugin.video.youtube - - SPDX-License-Identifier: GPL-2.0-only - See LICENSES/GPL-2.0-only for more information. -""" - -import xbmc -import xbmcaddon -import os -import sqlite3 - -addonID = xbmcaddon.Addon().getAddonInfo("id") -db_dir = xbmc.translatePath("special://profile/addon_data/" + addonID) -db_path = os.path.join(db_dir, 'tags.db') - -db = sqlite3.connect(db_path) - - -def init(): - # import web_pdb; web_pdb.set_trace() - with db: - cur = db.cursor() - cur.execute("begin") - cur.execute("create table if not exists tags (tag TEXT, title TEXT, UNIQUE(tag))") - cur.execute("create table if not exists channels (channel TEXT, title TEXT, uri TEXT, image TEXT, kind TEXT, UNIQUE(channel))") - cur.execute("create table if not exists channel_tag (channel TEXT, tag TEXT, UNIQUE(channel,tag))") - db.commit() - cur.close() - return - - -def create_channel(channel_id, title, item_uri, image, kind): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("INSERT OR REPLACE INTO channels(channel,title,uri,image,kind) VALUES (?,?,?,?,?);", (channel_id, title, item_uri, image, kind)) - db.commit() - cur.close() - - -def create_tag(tag_id, title): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("INSERT OR REPLACE INTO tags(tag,title) VALUES (?,?);", (tag_id, title)) - db.commit() - cur.close() - - -def add_channel_tag(channel_id, tag): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("INSERT OR REPLACE INTO channel_tag(tag,channel) VALUES (?,?);", (tag, channel_id)) - db.commit() - cur.close() - - -def get_channels(tag): - # init() - cur = db.cursor() - cur.execute("begin") - if len(tag) > 0: - cur.execute("select channels.channel, channels.title, channels.uri, channels.image from channels join channel_tag on channel_tag.channel = channels.channel where channel_tag.tag = ?;", (tag,)) - else: - cur.execute("select channels.channel, channels.title, channels.uri, channels.image from channels;") - rows = cur.fetchall() - cur.close() - channels = [] - for i in range(len(rows)): - channels.append([rows[i][0], rows[i][1], rows[i][2], rows[i][3]]) - return channels - - -def get_empty_channels(): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("select channels.channel, channels.title, channels.uri, channels.image from channels left join channel_tag on channel_tag.channel = channels.channel where channel_tag.tag is NULL;") - rows = cur.fetchall() - cur.close() - channels = [] - for i in range(len(rows)): - channels.append([rows[i][0], rows[i][1], rows[i][2], rows[i][3]]) - return channels - - -def get_channel_name(channel_id): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("select title from channels where channel = ?;", (channel_id,)) - row = cur.fetchone() - cur.close() - return row[0] - - -def get_tag_name(tag): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("select title from tags where tag = ?;", (tag,)) - row = cur.fetchone() - cur.close() - return row[0] - - -def get_tags(): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("SELECT DISTINCT tag, title FROM tags;") - rows = cur.fetchall() - cur.close() - tags = [] - for i in range(len(rows)): - tags.append([rows[i][0], rows[i][1]]) - return tags - - -def get_tags_add(channel_id): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("SELECT DISTINCT tags.tag, tags.title FROM tags LEFT JOIN channel_tag on channel_tag.tag = tags.tag and channel_tag.channel = ? WHERE channel_tag.tag is NULL;", (channel_id,)) - rows = cur.fetchall() - cur.close() - tags = [] - for i in range(len(rows)): - tags.append([rows[i][0], rows[i][1]]) - return tags - - -def rename_tag(tag_id, new_name): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("UPDATE tags SET title = ? WHERE tag = ?;", (new_name, tag_id)) - db.commit() - cur.close() - - -def delete_tag(tag_id): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("DELETE FROM tags WHERE tag = ?;", (tag_id,)) - db.commit() - cur.execute("DELETE FROM channel_tag WHERE tag = ?;", (tag_id,)) - db.commit() - cur.close() - - -def delete_channel_tag(channel_id, tag_id): - # init() - cur = db.cursor() - cur.execute("begin") - cur.execute("DELETE FROM channel_tag WHERE tag = ? and channel = ?;", (tag_id, channel_id)) - db.commit() - cur.close() - - -init() diff --git a/resources/lib/youtube_plugin/youtube/helper/utils.py b/resources/lib/youtube_plugin/youtube/helper/utils.py index d6cad29cd..88a7fb7f5 100644 --- a/resources/lib/youtube_plugin/youtube/helper/utils.py +++ b/resources/lib/youtube_plugin/youtube/helper/utils.py @@ -16,7 +16,6 @@ from ... import kodion from ...kodion import utils from ...youtube.helper import yt_context_menu -from ...youtube.helper import tags try: import inputstreamhelper @@ -114,8 +113,6 @@ def update_channel_infos(provider, context, channel_id_dict, subscription_id_dic filter_string = filter_string.replace(', ', ',') filter_list = filter_string.split(',') filter_list = [x.lower() for x in filter_list] - - tags_count = len(tags.get_tags()) thumb_size = context.get_settings().use_thumbnail_size() for channel_id in list(channel_data.keys()): @@ -152,8 +149,6 @@ def update_channel_infos(provider, context, channel_id_dict, subscription_id_dic yt_context_menu.append_remove_my_subscriptions_filter(context_menu, provider, context, title) else: yt_context_menu.append_add_my_subscriptions_filter(context_menu, provider, context, title) - if tags_count > 0: - yt_context_menu.append_add_tag(context_menu, provider, context, channel_id) channel_item.set_context_menu(context_menu) @@ -332,6 +327,16 @@ def update_video_infos(provider, context, video_id_dict, playlist_item_id_dict=N video_item.set_episode(int(re_match.group('episode'))) break + # plot + channel_name = snippet.get('channelTitle', '') + description = kodion.utils.strip_html_from_text(snippet['description']) + if channel_name and settings.get_bool('youtube.view.description.show_channel_name', True): + description = '%s[CR][CR]%s' % (ui.uppercase(ui.bold(channel_name)), description) + video_item.set_studio(channel_name) + # video_item.add_cast(channel_name) + video_item.add_artist(channel_name) + video_item.set_plot(description) + # date time if not datetime and 'publishedAt' in snippet and snippet['publishedAt']: datetime = utils.datetime_parser.parse(snippet['publishedAt']) @@ -343,17 +348,6 @@ def update_video_infos(provider, context, video_id_dict, playlist_item_id_dict=N video_item.set_premiered_from_datetime(datetime) video_item.set_date_from_datetime(datetime) - # plot - channel_name = snippet.get('channelTitle', '') - description = kodion.utils.strip_html_from_text(snippet['description']) - if datetime: - description = '[' + datetime.strftime("%Y-%m-%d") + '][CR]' + description - if channel_name and settings.get_bool('youtube.view.description.show_channel_name', True): - description = '%s[CR][CR]%s' % (ui.uppercase(ui.bold(channel_name)), description) - video_item.set_studio(channel_name) - # video_item.add_cast(channel_name) - video_item.add_artist(channel_name) - video_item.set_plot(description) # try to find a better resolution for the image image = video_item.get_image() if not image: diff --git a/resources/lib/youtube_plugin/youtube/helper/v3.py b/resources/lib/youtube_plugin/youtube/helper/v3.py index c7576e7d4..6f2a9e7a7 100644 --- a/resources/lib/youtube_plugin/youtube/helper/v3.py +++ b/resources/lib/youtube_plugin/youtube/helper/v3.py @@ -12,7 +12,6 @@ from ... import kodion from ...kodion import items from . import utils -from ...youtube.helper import tags def _process_list_response(provider, context, json_data): @@ -79,17 +78,6 @@ def _process_list_response(provider, context, json_data): context_menu = [] yt_context_menu.append_subscribe_to_channel(context_menu, provider, context, channel_id) channel_item.set_context_menu(context_menu) - - #default_language = yt_item['brandingSettings']['channel'].get('defaultLanguage') - #country = yt_item['brandingSettings']['channel'].get('country') - default_language = '' - country = '' - if not default_language: - default_language = '' - if not country: - country = '' - tags.create_channel(channel_id, title, item_uri, image, kind) - result.append(channel_item) channel_id_dict[channel_id] = channel_item elif kind == 'guidecategory': @@ -122,14 +110,6 @@ def _process_list_response(provider, context, json_data): # map channel id with subscription id - we need it for the unsubscription subscription_id_dict[channel_id] = yt_item['id'] - default_language = '' - country = '' - if not default_language: - default_language = '' - if not country: - country = '' - tags.create_channel(channel_id, title, item_uri, image, kind) - result.append(channel_item) channel_id_dict[channel_id] = channel_item elif kind == 'playlist': @@ -279,14 +259,6 @@ def _process_list_response(provider, context, json_data): item_uri = context.create_uri(['channel', channel_id], item_params) channel_item = items.DirectoryItem(title, item_uri, image=image) channel_item.set_fanart(provider.get_fanart(context)) - default_language = '' - country = '' - if not default_language: - default_language = '' - if not country: - country = '' - tags.create_channel(channel_id, title, item_uri, image, kind) - result.append(channel_item) channel_id_dict[channel_id] = channel_item else: diff --git a/resources/lib/youtube_plugin/youtube/helper/yt_context_menu.py b/resources/lib/youtube_plugin/youtube/helper/yt_context_menu.py index 61fba674a..e1b56666f 100644 --- a/resources/lib/youtube_plugin/youtube/helper/yt_context_menu.py +++ b/resources/lib/youtube_plugin/youtube/helper/yt_context_menu.py @@ -119,45 +119,6 @@ def append_add_my_subscriptions_filter(context_menu, provider, context, channel_ 'action': 'add'}))) -def append_remove_tag(context_menu, provider, context, channel_id, tag): - context_menu.append((context.localize(provider.LOCAL_MAP['youtube.remove.tag']), - 'RunPlugin(%s)' % context.create_uri(['tags', 'edit'], - {'channel_id': channel_id, - 'tag': tag, - 'action': 'remove'}))) - - -def append_add_tag(context_menu, provider, context, channel_id): - context_menu.append((context.localize(provider.LOCAL_MAP['youtube.add.tag']), - 'RunPlugin(%s)' % context.create_uri(['tags', 'edit'], - {'channel_id': channel_id, - 'action': 'add'}))) - - -def append_delete_tag(context_menu, provider, context, tag): - context_menu.append((context.localize(provider.LOCAL_MAP['youtube.delete.tag']), - 'RunPlugin(%s)' % context.create_uri(['tags', 'edit'], - {'tag': tag, - 'action': 'delete'}))) - -def append_move_tag(context_menu, provider, context, channel_id, tag): - context_menu.append((context.localize(provider.LOCAL_MAP['youtube.move.tag']), - 'RunPlugin(%s)' % context.create_uri(['tags', 'edit'], - {'channel_id': channel_id, - 'tag': tag, - 'action': 'move'}))) - -def append_new_tag(context_menu, provider, context): - context_menu.append((context.localize(provider.LOCAL_MAP['youtube.new.tag']), - 'RunPlugin(%s)' % context.create_uri(['tags', 'edit'], - {'action': 'new'}))) - -def append_rename_tag(context_menu, provider, context, tag): - context_menu.append((context.localize(provider.LOCAL_MAP['youtube.rename.tag']), - 'RunPlugin(%s)' % context.create_uri(['tags', 'edit'], - {'tag': tag, - 'action': 'rename'}))) - def append_rate_video(context_menu, provider, context, video_id, refresh_container=False): if refresh_container: refresh_container = '1' diff --git a/resources/lib/youtube_plugin/youtube/helper/yt_specials.py b/resources/lib/youtube_plugin/youtube/helper/yt_specials.py index e56728de6..89ad2b119 100644 --- a/resources/lib/youtube_plugin/youtube/helper/yt_specials.py +++ b/resources/lib/youtube_plugin/youtube/helper/yt_specials.py @@ -12,41 +12,6 @@ from ...kodion.items import DirectoryItem, UriItem from ...youtube.helper import v3, tv, extract_urls, UrlResolver, UrlToItemConverter from . import utils -from ...youtube.helper import yt_context_menu -from ...youtube.helper import tags - -def _process_tags(provider, context): - result = [] - - incognito = str(context.get_param('incognito', False)).lower() == 'true' - addon_id = context.get_param('addon_id', '') - #import web_pdb; web_pdb.set_trace() - all_tags = tags.get_tags() - for tag in all_tags: - item_params = {} - if incognito: - item_params.update({'incognito': incognito}) - if addon_id: - item_params.update({'addon_id': addon_id}) - tag_id = tag[0] - title = tag[1] - item_uri = context.create_uri(['tag', tag_id], item_params) - context_menu = [] - tag_item = DirectoryItem(title, item_uri) - yt_context_menu.append_new_tag(context_menu, provider, context) - yt_context_menu.append_rename_tag(context_menu, provider, context, tag_id) - yt_context_menu.append_delete_tag(context_menu, provider, context, tag_id) - tag_item.set_context_menu(context_menu) - result.append(tag_item) - if not len(all_tags): - new_tag_uri = context.create_uri(['tags', 'edit'], {'action': 'new'}) - new_tag_item = DirectoryItem(context.localize(provider.LOCAL_MAP['youtube.new.tag']), new_tag_uri) - result.append(new_tag_item) - else: - empty_tag_uri = context.create_uri(['tag', '-empty-']) - empty_tag_item = DirectoryItem(context.localize(provider.LOCAL_MAP['youtube.empty.tag']), empty_tag_uri) - result.append(empty_tag_item) - return result def _process_related_videos(provider, context): @@ -393,8 +358,6 @@ def process(category, provider, context): return _process_parent_comments(provider, context) elif category == 'child_comments': return _process_child_comments(provider, context) - elif category == 'tags': - return _process_tags(provider, context) elif category == 'saved_playlists': return _process_saved_playlists_tv(provider, context) else: diff --git a/resources/lib/youtube_plugin/youtube/provider.py b/resources/lib/youtube_plugin/youtube/provider.py index 57690737a..fea295799 100644 --- a/resources/lib/youtube_plugin/youtube/provider.py +++ b/resources/lib/youtube_plugin/youtube/provider.py @@ -13,11 +13,8 @@ import re import shutil import socket -import hashlib -from datetime import datetime from base64 import b64decode -from ..youtube.helper import tags from ..youtube.helper import yt_subscriptions from .. import kodion from ..kodion.utils import FunctionCache, strip_html_from_text, get_client_ip_address, is_httpd_live, find_video_id @@ -40,172 +37,151 @@ class Provider(kodion.AbstractProvider): - LOCAL_MAP = { - 'youtube.search': 30102, - 'youtube.next_page': 30106, - 'youtube.watch_later': 30107, - 'youtube.video.rate.none': 30108, - 'youtube.remove': 30108, - 'youtube.sign.in': 30111, - 'youtube.sign.out': 30112, - 'youtube.rename': 30113, - 'youtube.delete': 30118, - 'youtube.api.key': 30201, - 'youtube.api.id': 30202, - 'youtube.api.secret': 30203, - 'youtube.channels': 30500, - 'youtube.playlists': 30501, - 'youtube.go_to_channel': 30502, - 'youtube.subscriptions': 30504, - 'youtube.tags': 30900, - 'youtube.add.tag': 30901, - 'youtube.remove.tag': 30902, - 'youtube.delete.tag': 30903, - 'youtube.new.tag': 30904, - 'youtube.inputnew.tag': 30905, - 'youtube.created.tag': 30906, - 'youtube.questiondelete.tag': 30907, - 'youtube.deleted.tag': 30908, - 'youtube.selectadd.tag': 30909, - 'youtube.added.tag': 30910, - 'youtube.questionremove.tag': 30911, - 'youtube.removed.tag': 30912, - 'youtube.empty.tag': 30913, - 'youtube.move.tag': 30914, - 'youtube.selectmove.tag': 30915, - 'youtube.moved.tag': 30916, - 'youtube.rename.tag': 30917, - 'youtube.inputrename.tag': 30918, - 'youtube.renamed.tag': 30919, - 'youtube.unsubscribe': 30505, - 'youtube.subscribe': 30506, - 'youtube.my_channel': 30507, - 'youtube.video.liked': 30508, - 'youtube.history': 30509, - 'youtube.my_subscriptions': 30510, - 'youtube.video.queue': 30511, - 'youtube.browse_channels': 30512, - 'youtube.popular_right_now': 30513, - 'youtube.related_videos': 30514, - 'youtube.setting.auto_remove_watch_later': 30515, - 'youtube.subscribe_to': 30517, - 'youtube.sign.go_to': 30518, - 'youtube.sign.enter_code': 30519, - 'youtube.video.add_to_playlist': 30520, - 'youtube.playlist.select': 30521, - 'youtube.playlist.create': 30522, - 'youtube.setup_wizard.select_language': 30524, - 'youtube.setup_wizard.select_region': 30525, - 'youtube.setup_wizard.adjust': 30526, - 'youtube.setup_wizard.adjust.language_and_region': 30527, - 'youtube.video.rate': 30528, - 'youtube.video.rate.like': 30529, - 'youtube.video.rate.dislike': 30530, - 'youtube.playlist.play.all': 30531, - 'youtube.playlist.play.default': 30532, - 'youtube.playlist.play.reverse': 30533, - 'youtube.playlist.play.shuffle': 30534, - 'youtube.playlist.play.select': 30535, - 'youtube.playlist.progress.updating': 30536, - 'youtube.playlist.play.from_here': 30537, - 'youtube.video.disliked': 30538, - 'youtube.live': 30539, - 'youtube.video.play_with': 30540, - 'youtube.error.rtmpe_not_supported': 30542, - 'youtube.refresh': 30543, - 'youtube.video.description.links': 30544, - 'youtube.video.description.links.not_found': 30545, - 'youtube.sign.twice.title': 30546, - 'youtube.sign.twice.text': 30547, - 'youtube.video.more': 30548, - 'youtube.error.no_video_streams_found': 30549, - 'youtube.recommendations': 30551, - 'youtube.function.cache': 30557, - 'youtube.search.history': 30558, - 'youtube.subtitle.language': 30560, - 'youtube.none': 30561, - 'youtube.prompt': 30566, - 'youtube.set.as.watchlater': 30567, - 'youtube.remove.as.watchlater': 30568, - 'youtube.set.as.history': 30571, - 'youtube.remove.as.history': 30572, - 'youtube.succeeded': 30575, - 'youtube.failed': 30576, - 'youtube.settings': 30577, - 'youtube.dash.enable.confirm': 30579, - 'youtube.reset.access.manager.confirm': 30581, - 'youtube.my_subscriptions_filtered': 30584, - 'youtube.add.my_subscriptions.filter': 30587, - 'youtube.remove.my_subscriptions.filter': 30588, - 'youtube.added.my_subscriptions.filter': 30589, - 'youtube.removed.my_subscriptions.filter': 30590, - 'youtube.updated_': 30597, - 'youtube.api.personal.enabled': 30598, - 'youtube.api.personal.failed': 30599, - 'youtube.subtitle._with_fallback': 30601, - 'youtube.subtitle.no.auto.generated': 30602, - 'youtube.quick.search': 30605, - 'youtube.quick.search.incognito': 30606, - 'youtube.clear_history': 30609, - 'youtube.clear_history_confirmation': 30610, - 'youtube.saved.playlists': 30611, - 'youtube.retry': 30612, - 'youtube.failed.watch_later.retry': 30614, - 'youtube.cancel': 30615, - 'youtube.must.be.signed.in': 30616, - 'youtube.select.listen.ip': 30644, - 'youtube.purchases': 30622, - 'youtube.requires.krypton': 30624, - 'youtube.inputstreamhelper.is.installed': 30625, - 'youtube.upcoming.live': 30646, - 'youtube.completed.live': 30647, - 'youtube.api.key.incorrect': 30648, - 'youtube.client.id.incorrect': 30649, - 'youtube.client.secret.incorrect': 30650, - 'youtube.perform.geolocation': 30653, - 'youtube.my_location': 30654, - 'youtube.switch.user': 30655, - 'youtube.user.new': 30656, - 'youtube.user.unnamed': 30657, - 'youtube.enter.user.name': 30658, - 'youtube.user.changed': 30659, - 'youtube.remove.a.user': 30662, - 'youtube.rename.a.user': 30663, - 'youtube.switch.user.now': 30665, - 'youtube.removed': 30666, - 'youtube.renamed': 30667, - 'youtube.playback.history': 30673, - 'youtube.mark.watched': 30670, - 'youtube.mark.unwatched': 30669, - 'youtube.reset.resume.point': 30674, - 'youtube.data.cache': 30687, - 'youtube.httpd.not.running': 30699, - 'youtube.client.ip': 30700, - 'youtube.client.ip.failed': 30701, - 'youtube.video.play_with_subtitles': 30702, - 'youtube.are.you.sure': 30703, - 'youtube.subtitles.download': 30705, - 'youtube.pre.download.subtitles': 30706, - 'youtube.untitled': 30707, - 'youtube.video.play_audio_only': 30708, - 'youtube.failed.watch_later.retry.2': 30709, - 'youtube.failed.watch_later.retry.3': 30710, - 'youtube.added.to.watch.later': 30713, - 'youtube.added.to.playlist': 30714, - 'youtube.removed.from.playlist': 30715, - 'youtube.liked.video': 30716, - 'youtube.disliked.video': 30717, - 'youtube.unrated.video': 30718, - 'youtube.subscribed.to.channel': 30719, - 'youtube.unsubscribed.from.channel': 30720, - 'youtube.uploads': 30726, - 'youtube.video.play_ask_for_quality': 30730, - 'youtube.key.requirement.notification': 30731, - 'youtube.video.comments': 30732, - 'youtube.video.comments.likes': 30733, - 'youtube.video.comments.replies': 30734, - 'youtube.video.comments.edited': 30735, - } + LOCAL_MAP = {'youtube.search': 30102, + 'youtube.next_page': 30106, + 'youtube.watch_later': 30107, + 'youtube.video.rate.none': 30108, + 'youtube.remove': 30108, + 'youtube.sign.in': 30111, + 'youtube.sign.out': 30112, + 'youtube.rename': 30113, + 'youtube.delete': 30118, + 'youtube.api.key': 30201, + 'youtube.api.id': 30202, + 'youtube.api.secret': 30203, + 'youtube.channels': 30500, + 'youtube.playlists': 30501, + 'youtube.go_to_channel': 30502, + 'youtube.subscriptions': 30504, + 'youtube.unsubscribe': 30505, + 'youtube.subscribe': 30506, + 'youtube.my_channel': 30507, + 'youtube.video.liked': 30508, + 'youtube.history': 30509, + 'youtube.my_subscriptions': 30510, + 'youtube.video.queue': 30511, + 'youtube.browse_channels': 30512, + 'youtube.popular_right_now': 30513, + 'youtube.related_videos': 30514, + 'youtube.setting.auto_remove_watch_later': 30515, + 'youtube.subscribe_to': 30517, + 'youtube.sign.go_to': 30518, + 'youtube.sign.enter_code': 30519, + 'youtube.video.add_to_playlist': 30520, + 'youtube.playlist.select': 30521, + 'youtube.playlist.create': 30522, + 'youtube.setup_wizard.select_language': 30524, + 'youtube.setup_wizard.select_region': 30525, + 'youtube.setup_wizard.adjust': 30526, + 'youtube.setup_wizard.adjust.language_and_region': 30527, + 'youtube.video.rate': 30528, + 'youtube.video.rate.like': 30529, + 'youtube.video.rate.dislike': 30530, + 'youtube.playlist.play.all': 30531, + 'youtube.playlist.play.default': 30532, + 'youtube.playlist.play.reverse': 30533, + 'youtube.playlist.play.shuffle': 30534, + 'youtube.playlist.play.select': 30535, + 'youtube.playlist.progress.updating': 30536, + 'youtube.playlist.play.from_here': 30537, + 'youtube.video.disliked': 30538, + 'youtube.live': 30539, + 'youtube.video.play_with': 30540, + 'youtube.error.rtmpe_not_supported': 30542, + 'youtube.refresh': 30543, + 'youtube.video.description.links': 30544, + 'youtube.video.description.links.not_found': 30545, + 'youtube.sign.twice.title': 30546, + 'youtube.sign.twice.text': 30547, + 'youtube.video.more': 30548, + 'youtube.error.no_video_streams_found': 30549, + 'youtube.recommendations': 30551, + 'youtube.function.cache': 30557, + 'youtube.search.history': 30558, + 'youtube.subtitle.language': 30560, + 'youtube.none': 30561, + 'youtube.prompt': 30566, + 'youtube.set.as.watchlater': 30567, + 'youtube.remove.as.watchlater': 30568, + 'youtube.set.as.history': 30571, + 'youtube.remove.as.history': 30572, + 'youtube.succeeded': 30575, + 'youtube.failed': 30576, + 'youtube.settings': 30577, + 'youtube.dash.enable.confirm': 30579, + 'youtube.reset.access.manager.confirm': 30581, + 'youtube.my_subscriptions_filtered': 30584, + 'youtube.add.my_subscriptions.filter': 30587, + 'youtube.remove.my_subscriptions.filter': 30588, + 'youtube.added.my_subscriptions.filter': 30589, + 'youtube.removed.my_subscriptions.filter': 30590, + 'youtube.updated_': 30597, + 'youtube.api.personal.enabled': 30598, + 'youtube.api.personal.failed': 30599, + 'youtube.subtitle._with_fallback': 30601, + 'youtube.subtitle.no.auto.generated': 30602, + 'youtube.quick.search': 30605, + 'youtube.quick.search.incognito': 30606, + 'youtube.clear_history': 30609, + 'youtube.clear_history_confirmation': 30610, + 'youtube.saved.playlists': 30611, + 'youtube.retry': 30612, + 'youtube.failed.watch_later.retry': 30614, + 'youtube.cancel': 30615, + 'youtube.must.be.signed.in': 30616, + 'youtube.select.listen.ip': 30644, + 'youtube.purchases': 30622, + 'youtube.requires.krypton': 30624, + 'youtube.inputstreamhelper.is.installed': 30625, + 'youtube.upcoming.live': 30646, + 'youtube.completed.live': 30647, + 'youtube.api.key.incorrect': 30648, + 'youtube.client.id.incorrect': 30649, + 'youtube.client.secret.incorrect': 30650, + 'youtube.perform.geolocation': 30653, + 'youtube.my_location': 30654, + 'youtube.switch.user': 30655, + 'youtube.user.new': 30656, + 'youtube.user.unnamed': 30657, + 'youtube.enter.user.name': 30658, + 'youtube.user.changed': 30659, + 'youtube.remove.a.user': 30662, + 'youtube.rename.a.user': 30663, + 'youtube.switch.user.now': 30665, + 'youtube.removed': 30666, + 'youtube.renamed': 30667, + 'youtube.playback.history': 30673, + 'youtube.mark.watched': 30670, + 'youtube.mark.unwatched': 30669, + 'youtube.reset.resume.point': 30674, + 'youtube.data.cache': 30687, + 'youtube.httpd.not.running': 30699, + 'youtube.client.ip': 30700, + 'youtube.client.ip.failed': 30701, + 'youtube.video.play_with_subtitles': 30702, + 'youtube.are.you.sure': 30703, + 'youtube.subtitles.download': 30705, + 'youtube.pre.download.subtitles': 30706, + 'youtube.untitled': 30707, + 'youtube.video.play_audio_only': 30708, + 'youtube.failed.watch_later.retry.2': 30709, + 'youtube.failed.watch_later.retry.3': 30710, + 'youtube.added.to.watch.later': 30713, + 'youtube.added.to.playlist': 30714, + 'youtube.removed.from.playlist': 30715, + 'youtube.liked.video': 30716, + 'youtube.disliked.video': 30717, + 'youtube.unrated.video': 30718, + 'youtube.subscribed.to.channel': 30719, + 'youtube.unsubscribed.from.channel': 30720, + 'youtube.uploads': 30726, + 'youtube.video.play_ask_for_quality': 30730, + 'youtube.key.requirement.notification': 30731, + 'youtube.video.comments': 30732, + 'youtube.video.comments.likes': 30733, + 'youtube.video.comments.replies': 30734, + 'youtube.video.comments.edited': 30735, + } def __init__(self): kodion.AbstractProvider.__init__(self) @@ -264,15 +240,7 @@ def get_dev_config(context, addon_id, dev_configs): dev_id = dev_main['id'] dev_secret = dev_main['secret'] context.log_debug('Using developer config: origin: |{0}| system |{1}|'.format(dev_origin, dev_system)) - return { - 'origin': dev_origin, - 'main': { - 'id': dev_id, - 'secret': dev_secret, - 'key': dev_key, - 'system': dev_system - } - } + return {'origin': dev_origin, 'main': {'id': dev_id, 'secret': dev_secret, 'key': dev_key, 'system': dev_system}} else: return dict() @@ -528,13 +496,9 @@ def _on_channel_playlists(self, context, re_match): incognito = str(context.get_param('incognito', False)).lower() == 'true' addon_id = context.get_param('addon_id', '') if incognito: - item_params.update({ - 'incognito': incognito - }) + item_params.update({'incognito': incognito}) if addon_id: - item_params.update({ - 'addon_id': addon_id - }) + item_params.update({'addon_id': addon_id}) playlists = resource_manager.get_related_playlists(channel_id) uploads_playlist = playlists.get('uploads', '') @@ -634,13 +598,9 @@ def _on_channel(self, context, re_match): addon_id = context.get_param('addon_id', '') item_params = {} if incognito: - item_params.update({ - 'incognito': incognito - }) + item_params.update({'incognito': incognito}) if addon_id: - item_params.update({ - 'addon_id': addon_id - }) + item_params.update({'addon_id': addon_id}) hide_folders = str(context.get_param('hide_folders', False)).lower() == 'true' @@ -701,9 +661,7 @@ def _on_my_location(self, context, re_match): # completed live events if settings.get_bool('youtube.folder.completed.live.show', True): live_events_item = DirectoryItem(context.localize(self.LOCAL_MAP['youtube.completed.live']), - context.create_uri(['special', 'completed_live'], params={ - 'location': True - }), + context.create_uri(['special', 'completed_live'], params={'location': True}), image=context.create_resource_path('media', 'live.png')) live_events_item.set_fanart(self.get_fanart(context)) result.append(live_events_item) @@ -711,18 +669,14 @@ def _on_my_location(self, context, re_match): # upcoming live events if settings.get_bool('youtube.folder.upcoming.live.show', True): live_events_item = DirectoryItem(context.localize(self.LOCAL_MAP['youtube.upcoming.live']), - context.create_uri(['special', 'upcoming_live'], params={ - 'location': True - }), + context.create_uri(['special', 'upcoming_live'], params={'location': True}), image=context.create_resource_path('media', 'live.png')) live_events_item.set_fanart(self.get_fanart(context)) result.append(live_events_item) # live events live_events_item = DirectoryItem(context.localize(self.LOCAL_MAP['youtube.live']), - context.create_uri(['special', 'live'], params={ - 'location': True - }), + context.create_uri(['special', 'live'], params={'location': True}), image=context.create_resource_path('media', 'live.png')) live_events_item.set_fanart(self.get_fanart(context)) result.append(live_events_item) @@ -802,11 +756,9 @@ def on_play(self, context, re_match): builtin = 'PlayMedia(%s)' if context.get_handle() == -1 else 'RunPlugin(%s)' if not redirect: context.log_debug('Redirecting playback, handle is -1') - context.execute(builtin % context.create_uri(['play'], { - 'video_id': params['video_id'] - })) + context.execute(builtin % context.create_uri(['play'], {'video_id': params['video_id']})) return - + if 'playlist_id' in params and (context.get_handle() != -1): builtin = 'RunPlugin(%s)' stream_url = context.create_uri(['play'], params) @@ -857,41 +809,6 @@ def _on_yt_specials(self, context, re_match): category = re_match.group('category') return yt_specials.process(category, self, context) - @kodion.RegisterProviderPath('^/tag/(?P[^/]+)/$') - def _on_yt_tags(self, context, re_match): - incognito = str(context.get_param('incognito', False)).lower() == 'true' - addon_id = context.get_param('addon_id', '') - result = [] - tag = re_match.group('tag') - if tag == '-empty-': - all_channels = tags.get_empty_channels() - else: - all_channels = tags.get_channels(tag) - for channel in all_channels: - item_params = {} - if incognito: - item_params.update({ - 'incognito': incognito - }) - if addon_id: - item_params.update({ - 'addon_id': addon_id - }) - channel_id = channel[0] - title = channel[1] - image = channel[3] - item_uri = context.create_uri(['channel', channel_id], item_params) - context_menu = [] - channel_item = DirectoryItem(title, item_uri, image=image) - channel_item.set_fanart(self.get_fanart(context)) - yt_context_menu.append_add_tag(context_menu, self, context, channel_id) - if tag != '-empty-': - yt_context_menu.append_move_tag(context_menu, self, context, channel_id, tag) - yt_context_menu.append_remove_tag(context_menu, self, context, channel_id, tag) - channel_item.set_context_menu(context_menu) - result.append(channel_item) - return result - # noinspection PyUnusedLocal @kodion.RegisterProviderPath('^/history/clear/$') def _on_yt_clear_history(self, context, re_match): @@ -1242,85 +1159,6 @@ def manage_my_subscription_filter(self, context, re_match): context.get_ui().show_notification(message=message) context.get_ui().refresh_container() - @kodion.RegisterProviderPath('^/tags/edit/$') - def manage_my_subscription_filter(self, context, re_match): - # import web_pdb; web_pdb.set_trace() - params = context.get_params() - action = params.get('action') - if not action: - return - if action == 'new': - keyboard = xbmc.Keyboard("", context.localize(self.LOCAL_MAP['youtube.inputnew.tag'])) - keyboard.doModal() - if (keyboard.isConfirmed()): - title = keyboard.getText() - m = hashlib.md5() - nowdatetime = datetime.now() - m.update(nowdatetime.strftime("%d%m%Y%H%M%S%f")) - m.update(title) - tag_id = m.hexdigest() - title = title.decode("utf-8") - tags.create_tag(tag_id, title) - context.get_ui().show_notification(message=context.localize(self.LOCAL_MAP['youtube.created.tag']) % title) - if action == 'delete': - tag_id = params.get('tag') - tag_name = tags.get_tag_name(tag_id) - dialog = xbmcgui.Dialog() - if dialog.yesno(context.get_name(), context.localize(self.LOCAL_MAP['youtube.questiondelete.tag']) % tag_name): - tags.delete_tag(tag_id) - context.get_ui().show_notification(message=context.localize(self.LOCAL_MAP['youtube.deleted.tag']) % tag_name) - if action == 'add': - channel_id = params.get('channel_id') - channel_name = tags.get_channel_name(channel_id) - dialog = xbmcgui.Dialog() - tags_all = tags.get_tags_add(channel_id) - tags_id = [] - tags_title = [] - for tag in tags_all: - tags_id.append(tag[0]) - tags_title.append(tag[1]) - selectedtag = dialog.select(context.localize(self.LOCAL_MAP['youtube.selectadd.tag']) % channel_name, tags_title) - if (not selectedtag == -1): - tags.add_channel_tag(channel_id, tags_id[selectedtag]) - context.get_ui().show_notification(message=context.localize(self.LOCAL_MAP['youtube.added.tag']) % (channel_name, tags_title[selectedtag])) - if action == 'remove': - channel_id = params.get('channel_id') - channel_name = tags.get_channel_name(channel_id) - tag_id = params.get('tag') - tag_name = tags.get_tag_name(tag_id) - dialog = xbmcgui.Dialog() - if dialog.yesno(context.get_name(), context.localize(self.LOCAL_MAP['youtube.questionremove.tag']) % (channel_name, tag_name)): - tags.delete_channel_tag(channel_id, tag_id) - context.get_ui().show_notification(message=context.localize(self.LOCAL_MAP['youtube.removed.tag']) % (channel_name, tag_name)) - if action == 'rename': - tag_id = params.get('tag') - tag_name = tags.get_tag_name(tag_id) - keyboard = xbmc.Keyboard(tag_name, context.localize(self.LOCAL_MAP['youtube.inputrename.tag'])) - keyboard.doModal() - if (keyboard.isConfirmed()): - new_name = keyboard.getText() - new_name = new_name.decode("utf-8") - tags.rename_tag(tag_id, new_name) - context.get_ui().show_notification(message=context.localize(self.LOCAL_MAP['youtube.renamed.tag']) % (tag_name, new_name)) - if action == 'move': - channel_id = params.get('channel_id') - channel_name = tags.get_channel_name(channel_id) - tag_id = params.get('tag') - tag_name = tags.get_tag_name(tag_id) - dialog = xbmcgui.Dialog() - tags_all = tags.get_tags_add(channel_id) - tags_id = [] - tags_title = [] - for tag in tags_all: - tags_id.append(tag[0]) - tags_title.append(tag[1]) - selectedtag = dialog.select(context.localize(self.LOCAL_MAP['youtube.selectmove.tag']) % (channel_name, tag_name), tags_title) - if (not selectedtag == -1): - tags.add_channel_tag(channel_id, tags_id[selectedtag]) - tags.delete_channel_tag(channel_id, tag_id) - context.get_ui().show_notification(message=context.localize(self.LOCAL_MAP['youtube.moved.tag']) % (channel_name, tags_title, tags_title[selectedtag])) - context.get_ui().refresh_container() - @kodion.RegisterProviderPath('^/maintain/(?P[^/]+)/(?P[^/]+)/$') def maintenance_actions(self, context, re_match): maint_type = re_match.group('maint_type') @@ -1364,16 +1202,14 @@ def maintenance_actions(self, context, re_match): except: context.get_ui().show_notification(context.localize(self.LOCAL_MAP['youtube.failed'])) elif action == 'delete': - _maint_files = { - 'function_cache': 'cache.sqlite', - 'search_cache': 'search.sqlite', - 'data_cache': 'data_cache.sqlite', - 'playback_history': 'playback_history', - 'settings_xml': 'settings.xml', - 'api_keys': 'api_keys.json', - 'access_manager': 'access_manager.json', - 'temp_files': 'special://temp/plugin.video.youtube/' - } + _maint_files = {'function_cache': 'cache.sqlite', + 'search_cache': 'search.sqlite', + 'data_cache': 'data_cache.sqlite', + 'playback_history': 'playback_history', + 'settings_xml': 'settings.xml', + 'api_keys': 'api_keys.json', + 'access_manager': 'access_manager.json', + 'temp_files': 'special://temp/plugin.video.youtube/'} _file = _maint_files.get(maint_type, '') success = False if _file: @@ -1491,12 +1327,8 @@ def on_playback_history(self, context, re_match): playback_history = context.get_playback_history() items = playback_history.get_items([video_id]) if not items or not items.get(video_id): - item_dict = { - 'play_count': '0', - 'total_time': '0.0', - 'played_time': '0.0', - 'played_percent': '0' - } + item_dict = {'play_count': '0', 'total_time': '0.0', + 'played_time': '0.0', 'played_percent': '0'} else: item_dict = items.get(video_id) if action == 'mark_unwatched': @@ -1544,12 +1376,12 @@ def on_root(self, context, re_match): if self.is_logged_in() and settings.get_bool('youtube.folder.my_subscriptions.show', True): # my subscription - - # clear cache + + #clear cache cache = context.get_data_cache() cache_items_key = 'my-subscriptions-items' cache.set(cache_items_key, '[]') - + my_subscriptions_item = DirectoryItem( context.get_ui().bold(context.localize(self.LOCAL_MAP['youtube.my_subscriptions'])), context.create_uri(['special', 'new_uploaded_videos_tv']), @@ -1693,14 +1525,6 @@ def on_root(self, context, re_match): playlists_item.set_fanart(self.get_fanart(context)) result.append(playlists_item) - # tags - if settings.get_bool('youtube.folder.tags.show', True) and (len(tags.get_channels('')) > 0): - tags_item = DirectoryItem(context.localize(self.LOCAL_MAP['youtube.tags']), - context.create_uri(['special', 'tags']), - image=context.create_resource_path('media', 'channels.png')) - tags_item.set_fanart(self.get_fanart(context)) - result.append(tags_item) - # subscriptions if settings.get_bool('youtube.folder.subscriptions.show', True): subscriptions_item = DirectoryItem(context.localize(self.LOCAL_MAP['youtube.subscriptions']), diff --git a/resources/settings.xml b/resources/settings.xml index 0fbfce6fd..dd1d7696c 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -69,7 +69,6 @@ -