From 49cfb6cb51c925b505e9712c6fdd651cd5877df1 Mon Sep 17 00:00:00 2001 From: jellyfin-bot Date: Thu, 3 Oct 2019 23:34:23 +0200 Subject: [PATCH] Fix SQL indentation --- resources/lib/database/queries.py | 231 ++--- resources/lib/objects/kodi/queries.py | 821 ++++++++++-------- resources/lib/objects/kodi/queries_music.py | 406 +++++---- resources/lib/objects/kodi/queries_texture.py | 16 +- 4 files changed, 824 insertions(+), 650 deletions(-) diff --git a/resources/lib/database/queries.py b/resources/lib/database/queries.py index 9008ed62..a11021cf 100644 --- a/resources/lib/database/queries.py +++ b/resources/lib/database/queries.py @@ -1,83 +1,99 @@ -get_item = """ SELECT kodi_id, kodi_fileid, kodi_pathid, parent_id, media_type, - jellyfin_type, media_folder, jellyfin_parent_id - FROM jellyfin - WHERE jellyfin_id = ? - """ +get_item = """ +SELECT kodi_id, kodi_fileid, kodi_pathid, parent_id, media_type, + jellyfin_type, media_folder, jellyfin_parent_id +FROM jellyfin +WHERE jellyfin_id = ? +""" get_item_obj = ["{Id}"] get_item_series_obj = ["{SeriesId}"] get_item_song_obj = ["{SongAlbumId}"] -get_item_id_by_parent = """ SELECT jellyfin_id, kodi_id - FROM jellyfin - WHERE parent_id = ? - AND media_type = ? - """ +get_item_id_by_parent = """ +SELECT jellyfin_id, kodi_id +FROM jellyfin +WHERE parent_id = ? +AND media_type = ? +""" get_item_id_by_parent_boxset_obj = ["{SetId}", "movie"] -get_item_by_parent = """ SELECT jellyfin_id, kodi_id, kodi_fileid - FROM jellyfin - WHERE parent_id = ? - AND media_type = ? - """ -get_item_by_media_folder = """ SELECT jellyfin_id, jellyfin_type - FROM jellyfin - WHERE media_folder = ? - """ +get_item_by_parent = """ +SELECT jellyfin_id, kodi_id, kodi_fileid +FROM jellyfin +WHERE parent_id = ? +AND media_type = ? +""" +get_item_by_media_folder = """ +SELECT jellyfin_id, jellyfin_type +FROM jellyfin +WHERE media_folder = ? +""" get_item_by_parent_movie_obj = ["{KodiId}", "movie"] get_item_by_parent_tvshow_obj = ["{ParentId}", "tvshow"] get_item_by_parent_season_obj = ["{ParentId}", "season"] get_item_by_parent_episode_obj = ["{ParentId}", "episode"] get_item_by_parent_album_obj = ["{ParentId}", "album"] get_item_by_parent_song_obj = ["{ParentId}", "song"] -get_item_by_wild = """ SELECT kodi_id, media_type - FROM jellyfin - WHERE jellyfin_id LIKE ? - """ +get_item_by_wild = """ +SELECT kodi_id, media_type +FROM jellyfin +WHERE jellyfin_id LIKE ? +""" get_item_by_wild_obj = ["{Id}"] -get_item_by_kodi = """ SELECT jellyfin_id, parent_id, media_folder, jellyfin_type, checksum - FROM jellyfin - WHERE kodi_id = ? - AND media_type = ? - """ -get_checksum = """ SELECT jellyfin_id, checksum - FROM jellyfin - WHERE jellyfin_type = ? - """ -get_view_name = """ SELECT view_name - FROM view - WHERE view_id = ? - """ -get_media_by_id = """ SELECT jellyfin_type - FROM jellyfin - WHERE jellyfin_id = ? - """ -get_media_by_parent_id = """ SELECT jellyfin_id, jellyfin_type, kodi_id, kodi_fileid - FROM jellyfin - WHERE jellyfin_parent_id = ? - """ -get_view = """ SELECT view_name, media_type - FROM view - WHERE view_id = ? - """ -get_views = """ SELECT * - FROM view - """ -get_views_by_media = """ SELECT * - FROM view - WHERE media_type = ? - """ -get_items_by_media = """ SELECT jellyfin_id - FROM jellyfin - WHERE media_type = ? - """ -get_version = """ SELECT idVersion - FROM version - """ +get_item_by_kodi = """ +SELECT jellyfin_id, parent_id, media_folder, jellyfin_type, checksum +FROM jellyfin +WHERE kodi_id = ? +AND media_type = ? +""" +get_checksum = """ +SELECT jellyfin_id, checksum +FROM jellyfin +WHERE jellyfin_type = ? +""" +get_view_name = """ +SELECT view_name +FROM view +WHERE view_id = ? +""" +get_media_by_id = """ +SELECT jellyfin_type +FROM jellyfin +WHERE jellyfin_id = ? +""" +get_media_by_parent_id = """ +SELECT jellyfin_id, jellyfin_type, kodi_id, kodi_fileid +FROM jellyfin +WHERE jellyfin_parent_id = ? +""" +get_view = """ +SELECT view_name, media_type +FROM view +WHERE view_id = ? +""" +get_views = """ +SELECT * +FROM view +""" +get_views_by_media = """ +SELECT * +FROM view +WHERE media_type = ? +""" +get_items_by_media = """ +SELECT jellyfin_id +FROM jellyfin +WHERE media_type = ? +""" +get_version = """ +SELECT idVersion +FROM version +""" -add_reference = """ INSERT OR REPLACE INTO jellyfin(jellyfin_id, kodi_id, kodi_fileid, kodi_pathid, jellyfin_type, - media_type, parent_id, checksum, media_folder, jellyfin_parent_id) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - """ +add_reference = """ +INSERT OR REPLACE INTO jellyfin(jellyfin_id, kodi_id, kodi_fileid, kodi_pathid, jellyfin_type, + media_type, parent_id, checksum, media_folder, jellyfin_parent_id) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +""" add_reference_movie_obj = ["{Id}", "{MovieId}", "{FileId}", "{PathId}", "Movie", "movie", None, "{Checksum}", "{LibraryId}", "{JellyfinParentId}"] add_reference_boxset_obj = ["{Id}", "{SetId}", None, None, "BoxSet", "set", None, "{Checksum}", None, None] add_reference_tvshow_obj = ["{Id}", "{ShowId}", None, "{PathId}", "Series", "tvshow", None, "{Checksum}", "{LibraryId}", "{JellyfinParentId}"] @@ -88,55 +104,66 @@ add_reference_mvideo_obj = ["{Id}", "{MvideoId}", "{FileId}", "{PathId}", "Music add_reference_artist_obj = ["{Id}", "{ArtistId}", None, None, "{ArtistType}", "artist", None, "{Checksum}", "{LibraryId}", "{JellyfinParentId}"] add_reference_album_obj = ["{Id}", "{AlbumId}", None, None, "MusicAlbum", "album", None, "{Checksum}", None, "{JellyfinParentId}"] add_reference_song_obj = ["{Id}", "{SongId}", None, "{PathId}", "Audio", "song", "{AlbumId}", "{Checksum}", None, "{JellyfinParentId}"] -add_view = """ INSERT OR REPLACE INTO view(view_id, view_name, media_type) - VALUES (?, ?, ?) - """ -add_version = """ INSERT OR REPLACE INTO version(idVersion) - VALUES (?) - """ +add_view = """ +INSERT OR REPLACE INTO view(view_id, view_name, media_type) +VALUES (?, ?, ?) +""" +add_version = """ +INSERT OR REPLACE INTO version(idVersion) +VALUES (?) +""" -update_reference = """ UPDATE jellyfin - SET checksum = ? - WHERE jellyfin_id = ? - """ +update_reference = """ +UPDATE jellyfin +SET checksum = ? +WHERE jellyfin_id = ? +""" update_reference_obj = ["{Checksum}", "{Id}"] -update_parent = """ UPDATE jellyfin - SET parent_id = ? - WHERE jellyfin_id = ? - """ +update_parent = """ +UPDATE jellyfin +SET parent_id = ? +WHERE jellyfin_id = ? +""" update_parent_movie_obj = ["{SetId}", "{Id}"] update_parent_episode_obj = ["{SeasonId}", "{Id}"] update_parent_album_obj = ["{ArtistId}", "{AlbumId}"] -delete_item = """ DELETE FROM jellyfin - WHERE jellyfin_id = ? - """ +delete_item = """ +DELETE FROM jellyfin +WHERE jellyfin_id = ? +""" delete_item_obj = ["{Id}"] -delete_item_by_parent = """ DELETE FROM jellyfin - WHERE parent_id = ? - AND media_type = ? - """ +delete_item_by_parent = """ +DELETE FROM jellyfin +WHERE parent_id = ? +AND media_type = ? +""" delete_item_by_parent_tvshow_obj = ["{ParentId}", "tvshow"] delete_item_by_parent_season_obj = ["{ParentId}", "season"] delete_item_by_parent_episode_obj = ["{ParentId}", "episode"] delete_item_by_parent_song_obj = ["{ParentId}", "song"] delete_item_by_parent_artist_obj = ["{ParentId}", "artist"] delete_item_by_parent_album_obj = ["{KodiId}", "album"] -delete_item_by_kodi = """ DELETE FROM jellyfin - WHERE kodi_id = ? - AND media_type = ? - """ -delete_item_by_wild = """ DELETE FROM jellyfin - WHERE jellyfin_id LIKE ? - """ -delete_view = """ DELETE FROM view - WHERE view_id = ? - """ +delete_item_by_kodi = """ +DELETE FROM jellyfin +WHERE kodi_id = ? +AND media_type = ? +""" +delete_item_by_wild = """ +DELETE FROM jellyfin +WHERE jellyfin_id LIKE ? +""" +delete_view = """ +DELETE FROM view +WHERE view_id = ? +""" delete_parent_boxset_obj = [None, "{Movie}"] -delete_media_by_parent_id = """ DELETE FROM jellyfin - WHERE jellyfin_parent_id = ? - """ -delete_version = """ DELETE FROM version - """ +delete_media_by_parent_id = """ +DELETE FROM jellyfin +WHERE jellyfin_parent_id = ? +""" +delete_version = """ +DELETE FROM version +""" diff --git a/resources/lib/objects/kodi/queries.py b/resources/lib/objects/kodi/queries.py index c8b7357d..75fb15da 100644 --- a/resources/lib/objects/kodi/queries.py +++ b/resources/lib/objects/kodi/queries.py @@ -3,467 +3,564 @@ Some functions require additional information, therefore obj do not always reflect the Kodi database query values. ''' -create_path = """ SELECT coalesce(max(idPath), 0) - FROM path - """ -create_file = """ SELECT coalesce(max(idFile), 0) - FROM files - """ -create_person = """ SELECT coalesce(max(actor_id), 0) - FROM actor - """ -create_genre = """ SELECT coalesce(max(genre_id), 0) - FROM genre - """ -create_studio = """ SELECT coalesce(max(studio_id), 0) - FROM studio - """ -create_bookmark = """ SELECT coalesce(max(idBookmark), 0) - FROM bookmark - """ -create_tag = """ SELECT coalesce(max(tag_id), 0) - FROM tag - """ -create_unique_id = """ SELECT coalesce(max(uniqueid_id), 0) - FROM uniqueid - """ -create_rating = """ SELECT coalesce(max(rating_id), 0) - FROM rating - """ -create_movie = """ SELECT coalesce(max(idMovie), 0) - FROM movie - """ -create_set = """ SELECT coalesce(max(idSet), 0) - FROM sets - """ -create_country = """ SELECT coalesce(max(country_id), 0) - FROM country - """ -create_musicvideo = """ SELECT coalesce(max(idMVideo), 0) - FROM musicvideo - """ -create_tvshow = """ SELECT coalesce(max(idShow), 0) - FROM tvshow - """ -create_season = """ SELECT coalesce(max(idSeason), 0) - FROM seasons - """ -create_episode = """ SELECT coalesce(max(idEpisode), 0) - FROM episode - """ +create_path = """ +SELECT coalesce(max(idPath), 0) +FROM path +""" +create_file = """ +SELECT coalesce(max(idFile), 0) +FROM files +""" +create_person = """ +SELECT coalesce(max(actor_id), 0) +FROM actor +""" +create_genre = """ +SELECT coalesce(max(genre_id), 0) +FROM genre +""" +create_studio = """ +SELECT coalesce(max(studio_id), 0) +FROM studio +""" +create_bookmark = """ +SELECT coalesce(max(idBookmark), 0) +FROM bookmark +""" +create_tag = """ +SELECT coalesce(max(tag_id), 0) +FROM tag +""" +create_unique_id = """ +SELECT coalesce(max(uniqueid_id), 0) +FROM uniqueid +""" +create_rating = """ +SELECT coalesce(max(rating_id), 0) +FROM rating +""" +create_movie = """ +SELECT coalesce(max(idMovie), 0) +FROM movie +""" +create_set = """ +SELECT coalesce(max(idSet), 0) +FROM sets +""" +create_country = """ +SELECT coalesce(max(country_id), 0) +FROM country +""" +create_musicvideo = """ +SELECT coalesce(max(idMVideo), 0) +FROM musicvideo +""" +create_tvshow = """ +SELECT coalesce(max(idShow), 0) +FROM tvshow +""" +create_season = """ +SELECT coalesce(max(idSeason), 0) +FROM seasons +""" +create_episode = """ +SELECT coalesce(max(idEpisode), 0) +FROM episode +""" -get_path = """ SELECT idPath - FROM path - WHERE strPath = ? - """ +get_path = """ +SELECT idPath +FROM path +WHERE strPath = ? +""" get_path_obj = ["{Path}"] -get_file = """ SELECT idFile - FROM files - WHERE idPath = ? - AND strFilename = ? - """ +get_file = """ +SELECT idFile +FROM files +WHERE idPath = ? +AND strFilename = ? +""" get_file_obj = ["{FileId}"] -get_filename = """ SELECT strFilename - FROM files - WHERE idFile = ? - """ -get_person = """ SELECT actor_id - FROM actor - WHERE name = ? - COLLATE NOCASE - """ -get_genre = """ SELECT genre_id - FROM genre - WHERE name = ? - COLLATE NOCASE - """ -get_studio = """ SELECT studio_id - FROM studio - WHERE name = ? - COLLATE NOCASE - """ -get_tag = """ SELECT tag_id - FROM tag - WHERE name = ? - COLLATE NOCASE - """ +get_filename = """ +SELECT strFilename +FROM files +WHERE idFile = ? +""" +get_person = """ +SELECT actor_id +FROM actor +WHERE name = ? + COLLATE NOCASE +""" +get_genre = """ +SELECT genre_id +FROM genre +WHERE name = ? + COLLATE NOCASE +""" +get_studio = """ +SELECT studio_id +FROM studio +WHERE name = ? + COLLATE NOCASE +""" +get_tag = """ +SELECT tag_id +FROM tag +WHERE name = ? + COLLATE NOCASE +""" get_tag_movie_obj = ["Favorite movies", "{MovieId}", "movie"] get_tag_mvideo_obj = ["Favorite musicvideos", "{MvideoId}", "musicvideo"] get_tag_episode_obj = ["Favorite tvshows", "{KodiId}", "tvshow"] -get_art = """ SELECT url - FROM art - WHERE media_id = ? - AND media_type = ? - AND type = ? - """ -get_movie = """ SELECT * - FROM movie - WHERE idMovie = ? - """ +get_art = """ +SELECT url +FROM art +WHERE media_id = ? +AND media_type = ? +AND type = ? +""" +get_movie = """ +SELECT * +FROM movie +WHERE idMovie = ? +""" get_movie_obj = ["{MovieId}"] -get_rating = """ SELECT rating_id - FROM rating - WHERE media_type = ? - AND media_id = ? - """ +get_rating = """ +SELECT rating_id +FROM rating +WHERE media_type = ? +AND media_id = ? +""" get_rating_movie_obj = ["movie", "{MovieId}"] get_rating_episode_obj = ["episode", "{EpisodeId}"] -get_unique_id = """ SELECT uniqueid_id - FROM uniqueid - WHERE media_type = ? - AND media_id = ? - """ +get_unique_id = """ +SELECT uniqueid_id +FROM uniqueid +WHERE media_type = ? +AND media_id = ? +""" get_unique_id_movie_obj = ["movie", "{MovieId}"] get_unique_id_tvshow_obj = ["tvshow", "{ShowId}"] get_unique_id_episode_obj = ["episode", "{EpisodeId}"] -get_country = """ SELECT country_id - FROM country - WHERE name = ? - COLLATE NOCASE - """ -get_set = """ SELECT idSet - FROM sets - WHERE strSet = ? - COLLATE NOCASE - """ -get_musicvideo = """ SELECT * - FROM musicvideo - WHERE idMVideo = ? - """ +get_country = """ +SELECT country_id +FROM country +WHERE name = ? + COLLATE NOCASE +""" +get_set = """ +SELECT idSet +FROM sets +WHERE strSet = ? + COLLATE NOCASE +""" +get_musicvideo = """ +SELECT * +FROM musicvideo +WHERE idMVideo = ? +""" get_musicvideo_obj = ["{MvideoId}"] -get_tvshow = """ SELECT * - FROM tvshow - WHERE idShow = ? - """ +get_tvshow = """ +SELECT * +FROM tvshow +WHERE idShow = ? +""" get_tvshow_obj = ["{ShowId}"] -get_episode = """ SELECT * - FROM episode - WHERE idEpisode = ? - """ +get_episode = """ +SELECT * +FROM episode +WHERE idEpisode = ? +""" get_episode_obj = ["{EpisodeId}"] -get_season = """ SELECT idSeason - FROM seasons - WHERE idShow = ? - AND season = ? - """ +get_season = """ +SELECT idSeason +FROM seasons +WHERE idShow = ? +AND season = ? +""" get_season_obj = ["{Title}", "{ShowId}", "{Index}"] get_season_special_obj = [None, "{ShowId}", -1] get_season_episode_obj = [None, "{ShowId}", "{Season}"] -get_backdrops = """ SELECT url - FROM art - WHERE media_id = ? - AND media_type = ? - AND type LIKE ? - """ -get_art = """ SELECT url - FROM art - WHERE media_id = ? - AND media_type = ? - AND type = ? - """ -get_art_url = """ SELECT url, type - FROM art - WHERE media_id = ? - AND media_type = ? - """ -get_show_by_unique_id = """ SELECT idShow - FROM tvshow_view - WHERE uniqueid_value = ? - """ +get_backdrops = """ +SELECT url +FROM art +WHERE media_id = ? +AND media_type = ? +AND type LIKE ? +""" +get_art = """ +SELECT url +FROM art +WHERE media_id = ? +AND media_type = ? +AND type = ? +""" +get_art_url = """ +SELECT url, type +FROM art +WHERE media_id = ? +AND media_type = ? +""" +get_show_by_unique_id = """ +SELECT idShow +FROM tvshow_view +WHERE uniqueid_value = ? +""" -get_total_episodes = """ SELECT totalCount - FROM tvshowcounts - WHERE idShow = ? - """ +get_total_episodes = """ +SELECT totalCount +FROM tvshowcounts +WHERE idShow = ? +""" get_total_episodes_obj = ["{ParentId}"] -add_path = """ INSERT INTO path(idPath, strPath) - VALUES (?, ?) - """ +add_path = """ +INSERT INTO path(idPath, strPath) +VALUES (?, ?) +""" add_path_obj = ["{Path}"] -add_file = """ INSERT INTO files(idFile, idPath, strFilename) - VALUES (?, ?, ?) - """ +add_file = """ +INSERT INTO files(idFile, idPath, strFilename) +VALUES (?, ?, ?) +""" add_file_obj = ["{PathId}", "{Filename}"] -add_person = """ INSERT INTO actor(actor_id, name) - VALUES (?, ?) - """ +add_person = """ +INSERT INTO actor(actor_id, name) +VALUES (?, ?) +""" add_people_movie_obj = ["{People}", "{MovieId}", "movie"] add_people_mvideo_obj = ["{People}", "{MvideoId}", "musicvideo"] add_people_tvshow_obj = ["{People}", "{ShowId}", "tvshow"] add_people_episode_obj = ["{People}", "{EpisodeId}", "episode"] -add_actor_link = """ INSERT INTO actor_link(actor_id, media_id, media_type, role, cast_order) - VALUES (?, ?, ?, ?, ?) - """ -add_link = """ INSERT INTO {LinkType}(actor_id, media_id, media_type) - VALUES (?, ?, ?) - """ -add_genre = """ INSERT INTO genre(genre_id, name) - VALUES (?, ?) - """ +add_actor_link = """ +INSERT INTO actor_link(actor_id, media_id, media_type, role, cast_order) +VALUES (?, ?, ?, ?, ?) +""" +add_link = """ +INSERT INTO {LinkType}(actor_id, media_id, media_type) +VALUES (?, ?, ?) +""" +add_genre = """ +INSERT INTO genre(genre_id, name) +VALUES (?, ?) +""" add_genres_movie_obj = ["{Genres}", "{MovieId}", "movie"] add_genres_mvideo_obj = ["{Genres}", "{MvideoId}", "musicvideo"] add_genres_tvshow_obj = ["{Genres}", "{ShowId}", "tvshow"] -add_studio = """ INSERT INTO studio(studio_id, name) - VALUES (?, ?) - """ +add_studio = """ +INSERT INTO studio(studio_id, name) +VALUES (?, ?) +""" add_studios_movie_obj = ["{Studios}", "{MovieId}", "movie"] add_studios_mvideo_obj = ["{Studios}", "{MvideoId}", "musicvideo"] add_studios_tvshow_obj = ["{Studios}", "{ShowId}", "tvshow"] -add_bookmark = """ INSERT INTO bookmark(idBookmark, idFile, timeInSeconds, totalTimeInSeconds, player, type) - VALUES (?, ?, ?, ?, ?, ?) - """ +add_bookmark = """ +INSERT INTO bookmark(idBookmark, idFile, timeInSeconds, totalTimeInSeconds, player, type) +VALUES (?, ?, ?, ?, ?, ?) +""" add_bookmark_obj = ["{FileId}", "{PlayCount}", "{DatePlayed}", "{Resume}", "{Runtime}", "DVDPlayer", 1] add_streams_obj = ["{FileId}", "{Streams}", "{Runtime}"] -add_stream_video = """ INSERT INTO streamdetails(idFile, iStreamType, strVideoCodec, fVideoAspect, iVideoWidth, - iVideoHeight, iVideoDuration, strStereoMode) - VALUES (?, ?, ?, ?, ?, ?, ?, ?) - """ +add_stream_video = """ +INSERT INTO streamdetails(idFile, iStreamType, strVideoCodec, fVideoAspect, iVideoWidth, + iVideoHeight, iVideoDuration, strStereoMode) +VALUES (?, ?, ?, ?, ?, ?, ?, ?) +""" add_stream_video_obj = ["{FileId}", 0, "{codec}", "{aspect}", "{width}", "{height}", "{Runtime}", "{3d}"] -add_stream_audio = """ INSERT INTO streamdetails(idFile, iStreamType, strAudioCodec, iAudioChannels, strAudioLanguage) - VALUES (?, ?, ?, ?, ?) - """ +add_stream_audio = """ +INSERT INTO streamdetails(idFile, iStreamType, strAudioCodec, iAudioChannels, strAudioLanguage) +VALUES (?, ?, ?, ?, ?) +""" add_stream_audio_obj = ["{FileId}", 1, "{codec}", "{channels}", "{language}"] -add_stream_sub = """ INSERT INTO streamdetails(idFile, iStreamType, strSubtitleLanguage) - VALUES (?, ?, ?) - """ +add_stream_sub = """ +INSERT INTO streamdetails(idFile, iStreamType, strSubtitleLanguage) +VALUES (?, ?, ?) +""" add_stream_sub_obj = ["{FileId}", 2, "{language}"] -add_tag = """ INSERT INTO tag(tag_id, name) - VALUES (?, ?) - """ +add_tag = """ +INSERT INTO tag(tag_id, name) +VALUES (?, ?) +""" add_tags_movie_obj = ["{Tags}", "{MovieId}", "movie"] add_tags_mvideo_obj = ["{Tags}", "{MvideoId}", "musicvideo"] add_tags_tvshow_obj = ["{Tags}", "{ShowId}", "tvshow"] -add_art = """ INSERT INTO art(media_id, media_type, type, url) - VALUES (?, ?, ?, ?) - """ -add_movie = """ INSERT INTO movie(idMovie, idFile, c00, c01, c02, c03, c04, c05, c06, c07, - c09, c10, c11, c12, c14, c15, c16, c18, c19, c21, userrating, premiered) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - """ +add_art = """ +INSERT INTO art(media_id, media_type, type, url) +VALUES (?, ?, ?, ?) +""" +add_movie = """ +INSERT INTO movie(idMovie, idFile, c00, c01, c02, c03, c04, c05, c06, c07, + c09, c10, c11, c12, c14, c15, c16, c18, c19, c21, userrating, premiered) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +""" add_movie_obj = ["{MovieId}", "{FileId}", "{Title}", "{Plot}", "{ShortPlot}", "{Tagline}", "{Votes}", "{RatingId}", "{Writers}", "{Year}", "{Unique}", "{SortTitle}", "{Runtime}", "{Mpaa}", "{Genre}", "{Directors}", "{Title}", "{Studio}", "{Trailer}", "{Country}", "{CriticRating}", "{Year}"] -add_rating = """ INSERT INTO rating(rating_id, media_id, media_type, rating_type, rating, votes) - VALUES (?, ?, ?, ?, ?, ?) - """ +add_rating = """ +INSERT INTO rating(rating_id, media_id, media_type, rating_type, rating, votes) +VALUES (?, ?, ?, ?, ?, ?) +""" add_rating_movie_obj = ["{RatingId}", "{MovieId}", "movie", "default", "{Rating}", "{Votes}"] add_rating_tvshow_obj = ["{RatingId}", "{ShowId}", "tvshow", "default", "{Rating}", "{Votes}"] add_rating_episode_obj = ["{RatingId}", "{EpisodeId}", "episode", "default", "{Rating}", "{Votes}"] -add_unique_id = """ INSERT INTO uniqueid(uniqueid_id, media_id, media_type, value, type) - VALUES (?, ?, ?, ?, ?) - """ +add_unique_id = """ +INSERT INTO uniqueid(uniqueid_id, media_id, media_type, value, type) +VALUES (?, ?, ?, ?, ?) +""" add_unique_id_movie_obj = ["{Unique}", "{MovieId}", "movie", "{UniqueId}", "{ProviderName}"] add_unique_id_tvshow_obj = ["{Unique}", "{ShowId}", "tvshow", "{UniqueId}", "{ProviderName}"] add_unique_id_episode_obj = ["{Unique}", "{EpisodeId}", "episode", "{UniqueId}", "{ProviderName}"] -add_country = """ INSERT INTO country(country_id, name) - VALUES (?, ?) - """ -add_set = """ INSERT INTO sets(idSet, strSet, strOverview) - VALUES (?, ?, ?) - """ +add_country = """ +INSERT INTO country(country_id, name) +VALUES (?, ?) +""" +add_set = """ +INSERT INTO sets(idSet, strSet, strOverview) +VALUES (?, ?, ?) +""" add_set_obj = ["{Title}", "{Overview}"] -add_musicvideo = """ INSERT INTO musicvideo(idMVideo, idFile, c00, c04, c05, c06, c07, c08, c09, c10, - c11, c12, premiered) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - """ +add_musicvideo = """ +INSERT INTO musicvideo(idMVideo, idFile, c00, c04, c05, c06, c07, c08, c09, c10, + c11, c12, premiered) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +""" add_musicvideo_obj = ["{MvideoId}", "{FileId}", "{Title}", "{Runtime}", "{Directors}", "{Studio}", "{Year}", "{Plot}", "{Album}", "{Artists}", "{Genre}", "{Index}", "{Premiere}"] -add_tvshow = """ INSERT INTO tvshow(idShow, c00, c01, c02, c04, c05, c08, c09, c10, c12, c13, c14, c15) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - """ +add_tvshow = """ +INSERT INTO tvshow(idShow, c00, c01, c02, c04, c05, c08, c09, c10, c12, c13, c14, c15) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +""" add_tvshow_obj = ["{ShowId}", "{Title}", "{Plot}", "{Status}", "{RatingId}", "{Premiere}", "{Genre}", "{Title}", "disintegrate browse bug", "{Unique}", "{Mpaa}", "{Studio}", "{SortTitle}"] -add_season = """ INSERT INTO seasons(idSeason, idShow, season) - VALUES (?, ?, ?) - """ -add_episode = """ INSERT INTO episode(idEpisode, idFile, c00, c01, c03, c04, c05, c09, c10, c12, c13, c14, - idShow, c15, c16, idSeason) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - """ +add_season = """ +INSERT INTO seasons(idSeason, idShow, season) +VALUES (?, ?, ?) +""" +add_episode = """ +INSERT INTO episode(idEpisode, idFile, c00, c01, c03, c04, c05, c09, c10, c12, c13, c14, + idShow, c15, c16, idSeason) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +""" add_episode_obj = ["{EpisodeId}", "{FileId}", "{Title}", "{Plot}", "{RatingId}", "{Writers}", "{Premiere}", "{Runtime}", "{Directors}", "{Season}", "{Index}", "{Title}", "{ShowId}", "{AirsBeforeSeason}", "{AirsBeforeEpisode}", "{SeasonId}"] -add_art = """ INSERT INTO art(media_id, media_type, type, url) - VALUES (?, ?, ?, ?) - """ +add_art = """ +INSERT INTO art(media_id, media_type, type, url) +VALUES (?, ?, ?, ?) +""" -update_path = """ UPDATE path - SET strPath = ?, strContent = ?, strScraper = ?, noUpdate = ? - WHERE idPath = ? - """ +update_path = """ +UPDATE path +SET strPath = ?, strContent = ?, strScraper = ?, noUpdate = ? +WHERE idPath = ? +""" update_path_movie_obj = ["{Path}", "movies", "metadata.local", 1, "{PathId}"] update_path_toptvshow_obj = ["{TopLevel}", "tvshows", "metadata.local", 1, "{TopPathId}"] update_path_tvshow_obj = ["{Path}", None, None, 1, "{PathId}"] update_path_episode_obj = ["{Path}", None, None, 1, "{PathId}"] update_path_mvideo_obj = ["{Path}", "musicvideos", None, 1, "{PathId}"] -update_file = """ UPDATE files - SET idPath = ?, strFilename = ?, dateAdded = ? - WHERE idFile = ? - """ +update_file = """ +UPDATE files +SET idPath = ?, strFilename = ?, dateAdded = ? +WHERE idFile = ? +""" update_file_obj = ["{PathId}", "{Filename}", "{DateAdded}", "{FileId}"] -update_genres = """ INSERT OR REPLACE INTO genre_link(genre_id, media_id, media_type) - VALUES (?, ?, ?) - """ -update_studios = """ INSERT OR REPLACE INTO studio_link(studio_id, media_id, media_type) - VALUES (?, ?, ?) - """ -update_playcount = """ UPDATE files - SET playCount = ?, lastPlayed = ? - WHERE idFile = ? - """ -update_tag = """ INSERT OR REPLACE INTO tag_link(tag_id, media_id, media_type) - VALUES (?, ?, ?) - """ -update_art = """ UPDATE art - SET url = ? - WHERE media_id = ? - AND media_type = ? - AND type = ? - """ -update_actor = """ INSERT OR REPLACE INTO actor_link(actor_id, media_id, media_type, role, cast_order) - VALUES (?, ?, ?, ?, ?) - """ +update_genres = """ +INSERT OR REPLACE INTO genre_link(genre_id, media_id, media_type) +VALUES (?, ?, ?) +""" +update_studios = """ +INSERT OR REPLACE INTO studio_link(studio_id, media_id, media_type) +VALUES (?, ?, ?) +""" +update_playcount = """ +UPDATE files +SET playCount = ?, lastPlayed = ? +WHERE idFile = ? +""" +update_tag = """ +INSERT OR REPLACE INTO tag_link(tag_id, media_id, media_type) +VALUES (?, ?, ?) +""" +update_art = """ +UPDATE art +SET url = ? +WHERE media_id = ? +AND media_type = ? +AND type = ? +""" +update_actor = """ +INSERT OR REPLACE INTO actor_link(actor_id, media_id, media_type, role, cast_order) +VALUES (?, ?, ?, ?, ?) +""" -update_link = """ INSERT OR REPLACE INTO {LinkType}(actor_id, media_id, media_type) - VALUES (?, ?, ?) - """ -update_movie = """ UPDATE movie - SET c00 = ?, c01 = ?, c02 = ?, c03 = ?, c04 = ?, c05 = ?, c06 = ?, - c07 = ?, c09 = ?, c10 = ?, c11 = ?, c12 = ?, c14 = ?, c15 = ?, - c16 = ?, c18 = ?, c19 = ?, c21 = ?, userrating = ?, premiered = ? - WHERE idMovie = ? - """ +update_link = """ +INSERT OR REPLACE INTO {LinkType}(actor_id, media_id, media_type) +VALUES (?, ?, ?) +""" +update_movie = """ +UPDATE movie +SET c00 = ?, c01 = ?, c02 = ?, c03 = ?, c04 = ?, c05 = ?, c06 = ?, + c07 = ?, c09 = ?, c10 = ?, c11 = ?, c12 = ?, c14 = ?, c15 = ?, + c16 = ?, c18 = ?, c19 = ?, c21 = ?, userrating = ?, premiered = ? +WHERE idMovie = ? +""" update_movie_obj = ["{Title}", "{Plot}", "{ShortPlot}", "{Tagline}", "{Votes}", "{RatingId}", "{Writers}", "{Year}", "{Unique}", "{SortTitle}", "{Runtime}", "{Mpaa}", "{Genre}", "{Directors}", "{Title}", "{Studio}", "{Trailer}", "{Country}", "{CriticRating}", "{Year}", "{MovieId}"] -update_rating = """ UPDATE rating - SET media_id = ?, media_type = ?, rating_type = ?, rating = ?, votes = ? - WHERE rating_id = ? - """ +update_rating = """ +UPDATE rating +SET media_id = ?, media_type = ?, rating_type = ?, rating = ?, votes = ? +WHERE rating_id = ? +""" update_rating_movie_obj = ["{MovieId}", "movie", "default", "{Rating}", "{Votes}", "{RatingId}"] update_rating_tvshow_obj = ["{ShowId}", "tvshow", "default", "{Rating}", "{Votes}", "{RatingId}"] update_rating_episode_obj = ["{EpisodeId}", "episode", "default", "{Rating}", "{Votes}", "{RatingId}"] -update_unique_id = """ UPDATE uniqueid - SET media_id = ?, media_type = ?, value = ?, type = ? - WHERE uniqueid_id = ? - """ +update_unique_id = """ +UPDATE uniqueid +SET media_id = ?, media_type = ?, value = ?, type = ? +WHERE uniqueid_id = ? +""" update_unique_id_movie_obj = ["{MovieId}", "movie", "{UniqueId}", "{ProviderName}", "{Unique}"] update_unique_id_tvshow_obj = ["{ShowId}", "tvshow", "{UniqueId}", "{ProviderName}", "{Unique}"] update_unique_id_episode_obj = ["{EpisodeId}", "episode", "{UniqueId}", "{ProviderName}", "{Unique}"] -update_country = """ INSERT OR REPLACE INTO country_link(country_id, media_id, media_type) - VALUES (?, ?, ?) - """ +update_country = """ +INSERT OR REPLACE INTO country_link(country_id, media_id, media_type) +VALUES (?, ?, ?) +""" update_country_obj = ["{Countries}", "{MovieId}", "movie"] -update_set = """ UPDATE sets - SET strSet = ?, strOverview = ? - WHERE idSet = ? - """ +update_set = """ +UPDATE sets +SET strSet = ?, strOverview = ? +WHERE idSet = ? +""" update_set_obj = ["{Title}", "{Overview}", "{SetId}"] -update_movie_set = """ UPDATE movie - SET idSet = ? - WHERE idMovie = ? - """ +update_movie_set = """ +UPDATE movie +SET idSet = ? +WHERE idMovie = ? +""" update_movie_set_obj = ["{SetId}", "{MovieId}"] -update_musicvideo = """ UPDATE musicvideo - SET c00 = ?, c04 = ?, c05 = ?, c06 = ?, c07 = ?, c08 = ?, c09 = ?, c10 = ?, - c11 = ?, c12 = ?, premiered = ? - WHERE idMVideo = ? - """ +update_musicvideo = """ +UPDATE musicvideo +SET c00 = ?, c04 = ?, c05 = ?, c06 = ?, c07 = ?, c08 = ?, c09 = ?, c10 = ?, + c11 = ?, c12 = ?, premiered = ? +WHERE idMVideo = ? +""" update_musicvideo_obj = ["{Title}", "{Runtime}", "{Directors}", "{Studio}", "{Year}", "{Plot}", "{Album}", "{Artists}", "{Genre}", "{Index}", "{Premiere}", "{MvideoId}"] -update_tvshow = """ UPDATE tvshow - SET c00 = ?, c01 = ?, c02 = ?, c04 = ?, c05 = ?, c08 = ?, c09 = ?, c10 = ?, - c12 = ?, c13 = ?, c14 = ?, c15 = ? - WHERE idShow = ? - """ +update_tvshow = """ +UPDATE tvshow +SET c00 = ?, c01 = ?, c02 = ?, c04 = ?, c05 = ?, c08 = ?, c09 = ?, c10 = ?, + c12 = ?, c13 = ?, c14 = ?, c15 = ? +WHERE idShow = ? +""" update_tvshow_obj = ["{Title}", "{Plot}", "{Status}", "{RatingId}", "{Premiere}", "{Genre}", "{Title}", "disintegrate browse bug", "{Unique}", "{Mpaa}", "{Studio}", "{SortTitle}", "{ShowId}"] -update_tvshow_link = """ INSERT OR REPLACE INTO tvshowlinkpath(idShow, idPath) - VALUES (?, ?) - """ +update_tvshow_link = """ +INSERT OR REPLACE INTO tvshowlinkpath(idShow, idPath) +VALUES (?, ?) +""" update_tvshow_link_obj = ["{ShowId}", "{PathId}"] -update_season = """ UPDATE seasons - SET name = ? - WHERE idSeason = ? - """ -update_episode = """ UPDATE episode - SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?, - c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, idSeason = ?, idShow = ? - WHERE idEpisode = ? - """ +update_season = """ +UPDATE seasons +SET name = ? +WHERE idSeason = ? +""" +update_episode = """ +UPDATE episode +SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?, + c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, idSeason = ?, idShow = ? +WHERE idEpisode = ? +""" update_episode_obj = ["{Title}", "{Plot}", "{RatingId}", "{Writers}", "{Premiere}", "{Runtime}", "{Directors}", "{Season}", "{Index}", "{Title}", "{AirsBeforeSeason}", "{AirsBeforeEpisode}", "{SeasonId}", "{ShowId}", "{EpisodeId}"] -delete_path = """ DELETE FROM path - WHERE idPath = ? - """ +delete_path = """ +DELETE FROM path +WHERE idPath = ? +""" delete_path_obj = ["{PathId}"] -delete_file = """ DELETE FROM files - WHERE idFile = ? - """ +delete_file = """ +DELETE FROM files +WHERE idFile = ? +""" delete_file_obj = ["{Path}", "{Filename}"] -delete_file_by_path = """ DELETE FROM files - WHERE idPath = ? - AND strFileName = ? - """ -delete_genres = """ DELETE FROM genre_link - WHERE media_id = ? - AND media_type = ? - """ -delete_bookmark = """ DELETE FROM bookmark - WHERE idFile = ? - """ -delete_streams = """ DELETE FROM streamdetails - WHERE idFile = ? - """ -delete_tags = """ DELETE FROM tag_link - WHERE media_id = ? - AND media_type = ? - """ -delete_tag = """ DELETE FROM tag_link - WHERE tag_id = ? - AND media_id = ? - AND media_type = ? - """ +delete_file_by_path = """ +DELETE FROM files +WHERE idPath = ? +AND strFileName = ? +""" +delete_genres = """ +DELETE FROM genre_link +WHERE media_id = ? +AND media_type = ? +""" +delete_bookmark = """ +DELETE FROM bookmark +WHERE idFile = ? +""" +delete_streams = """ +DELETE FROM streamdetails +WHERE idFile = ? +""" +delete_tags = """ +DELETE FROM tag_link +WHERE media_id = ? +AND media_type = ? +""" +delete_tag = """ +DELETE FROM tag_link +WHERE tag_id = ? +AND media_id = ? +AND media_type = ? +""" delete_tag_movie_obj = ["Favorite movies", "{MovieId}", "movie"] delete_tag_mvideo_obj = ["Favorite musicvideos", "{MvideoId}", "musicvideo"] delete_tag_episode_obj = ["Favorite tvshows", "{KodiId}", "tvshow"] -delete_movie = """ DELETE FROM movie - WHERE idMovie = ? - """ +delete_movie = """ +DELETE FROM movie +WHERE idMovie = ? +""" delete_movie_obj = ["{KodiId}", "{FileId}"] -delete_set = """ DELETE FROM sets - WHERE idSet = ? - """ +delete_set = """ +DELETE FROM sets +WHERE idSet = ? +""" delete_set_obj = ["{KodiId}"] -delete_movie_set = """ UPDATE movie - SET idSet = null - WHERE idMovie = ? - """ +delete_movie_set = """ +UPDATE movie +SET idSet = null +WHERE idMovie = ? +""" delete_movie_set_obj = ["{MovieId}"] -delete_musicvideo = """ DELETE FROM musicvideo - WHERE idMVideo = ? - """ +delete_musicvideo = """ +DELETE FROM musicvideo +WHERE idMVideo = ? +""" delete_musicvideo_obj = ["{MvideoId}", "{FileId}"] -delete_tvshow = """ DELETE FROM tvshow - WHERE idShow = ? - """ -delete_season = """ DELETE FROM seasons - WHERE idSeason = ? - """ -delete_episode = """ DELETE FROM episode - WHERE idEpisode = ? - """ -delete_backdrops = """ DELETE FROM art - WHERE media_id = ? - AND media_type = ? - AND type LIKE ? - """ +delete_tvshow = """ +DELETE FROM tvshow +WHERE idShow = ? +""" +delete_season = """ +DELETE FROM seasons +WHERE idSeason = ? +""" +delete_episode = """ +DELETE FROM episode +WHERE idEpisode = ? +""" +delete_backdrops = """ +DELETE FROM art +WHERE media_id = ? +AND media_type = ? +AND type LIKE ? +""" diff --git a/resources/lib/objects/kodi/queries_music.py b/resources/lib/objects/kodi/queries_music.py index fd163bfc..b9105a7a 100644 --- a/resources/lib/objects/kodi/queries_music.py +++ b/resources/lib/objects/kodi/queries_music.py @@ -1,212 +1,260 @@ -create_artist = """ SELECT coalesce(max(idArtist), 1) - FROM artist - """ -create_album = """ SELECT coalesce(max(idAlbum), 0) - FROM album - """ -create_song = """ SELECT coalesce(max(idSong), 0) - FROM song - """ -create_genre = """ SELECT coalesce(max(idGenre), 0) - FROM genre - """ +create_artist = """ +SELECT coalesce(max(idArtist), 1) +FROM artist +""" +create_album = """ +SELECT coalesce(max(idAlbum), 0) +FROM album +""" +create_song = """ +SELECT coalesce(max(idSong), 0) +FROM song +""" +create_genre = """ +SELECT coalesce(max(idGenre), 0) +FROM genre +""" -get_artist = """ SELECT idArtist, strArtist - FROM artist - WHERE strMusicBrainzArtistID = ? - """ +get_artist = """ +SELECT idArtist, strArtist +FROM artist +WHERE strMusicBrainzArtistID = ? +""" get_artist_obj = ["{ArtistId}", "{Name}", "{UniqueId}"] -get_artist_by_name = """ SELECT idArtist - FROM artist - WHERE strArtist = ? - COLLATE NOCASE - """ -get_artist_by_id = """ SELECT * - FROM artist - WHERE idArtist = ? - """ +get_artist_by_name = """ +SELECT idArtist +FROM artist +WHERE strArtist = ? + COLLATE NOCASE +""" +get_artist_by_id = """ +SELECT * +FROM artist +WHERE idArtist = ? +""" get_artist_by_id_obj = ["{ArtistId}"] -get_album_by_id = """ SELECT * - FROM album - WHERE idAlbum = ? - """ +get_album_by_id = """ +SELECT * +FROM album +WHERE idAlbum = ? +""" get_album_by_id_obj = ["{AlbumId}"] -get_song_by_id = """ SELECT * - FROM song - WHERE idSong = ? - """ +get_song_by_id = """ +SELECT * +FROM song +WHERE idSong = ? +""" get_song_by_id_obj = ["{SongId}"] -get_album = """ SELECT idAlbum - FROM album - WHERE strMusicBrainzAlbumID = ? - """ +get_album = """ +SELECT idAlbum +FROM album +WHERE strMusicBrainzAlbumID = ? +""" get_album_obj = ["{AlbumId}", "{Title}", "{UniqueId}", "{Artists}", "album"] -get_album_by_name = """ SELECT idAlbum, strArtists - FROM album - WHERE strAlbum = ? - """ -get_album_by_name72 = """ SELECT idAlbum, strArtistDisp - FROM album - WHERE strAlbum = ? - """ -get_album_artist = """ SELECT strArtists - FROM album - WHERE idAlbum = ? - """ -get_album_artist72 = """ SELECT strArtistDisp - FROM album - WHERE idAlbum = ? - """ +get_album_by_name = """ +SELECT idAlbum, strArtists +FROM album +WHERE strAlbum = ? +""" +get_album_by_name72 = """ +SELECT idAlbum, strArtistDisp +FROM album +WHERE strAlbum = ? +""" +get_album_artist = """ +SELECT strArtists +FROM album +WHERE idAlbum = ? +""" +get_album_artist72 = """ +SELECT strArtistDisp +FROM album +WHERE idAlbum = ? +""" get_album_artist_obj = ["{AlbumId}", "{strAlbumArtists}"] -get_genre = """ SELECT idGenre - FROM genre - WHERE strGenre = ? - COLLATE NOCASE - """ -get_total_episodes = """ SELECT totalCount - FROM tvshowcounts - WHERE idShow = ? - """ +get_genre = """ +SELECT idGenre +FROM genre +WHERE strGenre = ? + COLLATE NOCASE +""" +get_total_episodes = """ +SELECT totalCount +FROM tvshowcounts +WHERE idShow = ? +""" -add_artist = """ INSERT INTO artist(idArtist, strArtist, strMusicBrainzArtistID) - VALUES (?, ?, ?) - """ -add_album = """ INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType) - VALUES (?, ?, ?, ?) - """ -add_album72 = """ INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType, bScrapedMBID) - VALUES (?, ?, ?, ?, 1) - """ -add_single = """ INSERT INTO album(idAlbum, strGenres, iYear, strReleaseType) - VALUES (?, ?, ?, ?) - """ +add_artist = """ +INSERT INTO artist(idArtist, strArtist, strMusicBrainzArtistID) +VALUES (?, ?, ?) +""" +add_album = """ +INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType) +VALUES (?, ?, ?, ?) +""" +add_album72 = """ +INSERT INTO album(idAlbum, strAlbum, strMusicBrainzAlbumID, strReleaseType, bScrapedMBID) +VALUES (?, ?, ?, ?, 1) +""" +add_single = """ +INSERT INTO album(idAlbum, strGenres, iYear, strReleaseType) +VALUES (?, ?, ?, ?) +""" add_single_obj = ["{AlbumId}", "{Genre}", "{Year}", "single"] -add_song = """ INSERT INTO song(idSong, idAlbum, idPath, strArtists, strGenres, strTitle, iTrack, - iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed, - rating, comment, dateAdded) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - """ -add_song72 = """ INSERT INTO song(idSong, idAlbum, idPath, strArtistDisp, strGenres, strTitle, iTrack, - iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed, - rating, comment, dateAdded) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - """ +add_song = """ +INSERT INTO song(idSong, idAlbum, idPath, strArtists, strGenres, strTitle, iTrack, + iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed, + rating, comment, dateAdded) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +""" +add_song72 = """ +INSERT INTO song(idSong, idAlbum, idPath, strArtistDisp, strGenres, strTitle, iTrack, + iDuration, iYear, strFileName, strMusicBrainzTrackID, iTimesPlayed, lastplayed, + rating, comment, dateAdded) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) +""" add_song_obj = ["{SongId}", "{AlbumId}", "{PathId}", "{Artists}", "{Genre}", "{Title}", "{Index}", "{Runtime}", "{Year}", "{Filename}", "{UniqueId}", "{PlayCount}", "{DatePlayed}", "{Rating}", "{Comment}", "{DateAdded}"] -add_genre = """ INSERT INTO genre(idGenre, strGenre) - VALUES (?, ?) - """ +add_genre = """ +INSERT INTO genre(idGenre, strGenre) +VALUES (?, ?) +""" add_genres_obj = ["{AlbumId}", "{Genres}", "album"] -update_path = """ UPDATE path - SET strPath = ? - WHERE idPath = ? - """ +update_path = """ +UPDATE path +SET strPath = ? +WHERE idPath = ? +""" update_path_obj = ["{Path}", "{PathId}"] -update_role = """ INSERT OR REPLACE INTO role(idRole, strRole) - VALUES (?, ?) - """ +update_role = """ +INSERT OR REPLACE INTO role(idRole, strRole) +VALUES (?, ?) +""" update_role_obj = [1, "Composer"] -update_artist_name = """ UPDATE artist - SET strArtist = ? - WHERE idArtist = ? - """ +update_artist_name = """ +UPDATE artist +SET strArtist = ? +WHERE idArtist = ? +""" update_artist_name_obj = ["{Name}", "{ArtistId}"] -update_artist = """ UPDATE artist - SET strGenres = ?, strBiography = ?, strImage = ?, strFanart = ?, lastScraped = ? - WHERE idArtist = ? - """ -update_link = """ INSERT OR REPLACE INTO album_artist(idArtist, idAlbum, strArtist) - VALUES (?, ?, ?) - """ +update_artist = """ +UPDATE artist +SET strGenres = ?, strBiography = ?, strImage = ?, strFanart = ?, lastScraped = ? +WHERE idArtist = ? +""" +update_link = """ +INSERT OR REPLACE INTO album_artist(idArtist, idAlbum, strArtist) +VALUES (?, ?, ?) +""" update_link_obj = ["{ArtistId}", "{AlbumId}", "{Name}"] -update_discography = """ INSERT OR REPLACE INTO discography(idArtist, strAlbum, strYear) - VALUES (?, ?, ?) - """ +update_discography = """ +INSERT OR REPLACE INTO discography(idArtist, strAlbum, strYear) +VALUES (?, ?, ?) +""" update_discography_obj = ["{ArtistId}", "{Title}", "{Year}"] -update_album = """ UPDATE album - SET strArtists = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?, - iUserrating = ?, lastScraped = ?, strReleaseType = ? - WHERE idAlbum = ? - """ -update_album72 = """ UPDATE album - SET strArtistDisp = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?, - iUserrating = ?, lastScraped = ?, bScrapedMBID = 1, strReleaseType = ? - WHERE idAlbum = ? - """ +update_album = """ +UPDATE album +SET strArtists = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?, + iUserrating = ?, lastScraped = ?, strReleaseType = ? +WHERE idAlbum = ? +""" +update_album72 = """ +UPDATE album +SET strArtistDisp = ?, iYear = ?, strGenres = ?, strReview = ?, strImage = ?, + iUserrating = ?, lastScraped = ?, bScrapedMBID = 1, strReleaseType = ? +WHERE idAlbum = ? +""" update_album_obj = ["{Artists}", "{Year}", "{Genre}", "{Bio}", "{Thumb}", "{Rating}", "{LastScraped}", "album", "{AlbumId}"] -update_album_artist = """ UPDATE album - SET strArtists = ? - WHERE idAlbum = ? - """ -update_album_artist72 = """ UPDATE album - SET strArtistDisp = ? - WHERE idAlbum = ? - """ -update_song = """ UPDATE song - SET idAlbum = ?, strArtists = ?, strGenres = ?, strTitle = ?, iTrack = ?, - iDuration = ?, iYear = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?, - rating = ?, comment = ?, dateAdded = ? - WHERE idSong = ? - """ -update_song72 = """ UPDATE song - SET idAlbum = ?, strArtistDisp = ?, strGenres = ?, strTitle = ?, iTrack = ?, - iDuration = ?, iYear = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?, - rating = ?, comment = ?, dateAdded = ? - WHERE idSong = ? - """ +update_album_artist = """ +UPDATE album +SET strArtists = ? +WHERE idAlbum = ? +""" +update_album_artist72 = """ +UPDATE album +SET strArtistDisp = ? +WHERE idAlbum = ? +""" +update_song = """ +UPDATE song +SET idAlbum = ?, strArtists = ?, strGenres = ?, strTitle = ?, iTrack = ?, + iDuration = ?, iYear = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?, + rating = ?, comment = ?, dateAdded = ? +WHERE idSong = ? +""" +update_song72 = """ +UPDATE song +SET idAlbum = ?, strArtistDisp = ?, strGenres = ?, strTitle = ?, iTrack = ?, + iDuration = ?, iYear = ?, strFilename = ?, iTimesPlayed = ?, lastplayed = ?, + rating = ?, comment = ?, dateAdded = ? +WHERE idSong = ? +""" update_song_obj = ["{AlbumId}", "{Artists}", "{Genre}", "{Title}", "{Index}", "{Runtime}", "{Year}", "{Filename}", "{PlayCount}", "{DatePlayed}", "{Rating}", "{Comment}", "{DateAdded}", "{SongId}"] -update_song_artist = """ INSERT OR REPLACE INTO song_artist(idArtist, idSong, idRole, iOrder, strArtist) - VALUES (?, ?, ?, ?, ?) - """ +update_song_artist = """ +INSERT OR REPLACE INTO song_artist(idArtist, idSong, idRole, iOrder, strArtist) +VALUES (?, ?, ?, ?, ?) +""" update_song_artist_obj = ["{ArtistId}", "{SongId}", 1, "{Index}", "{Name}"] -update_song_album = """ INSERT OR REPLACE INTO albuminfosong(idAlbumInfoSong, idAlbumInfo, iTrack, - strTitle, iDuration) - VALUES (?, ?, ?, ?, ?) - """ +update_song_album = """ +INSERT OR REPLACE INTO albuminfosong(idAlbumInfoSong, idAlbumInfo, iTrack, + strTitle, iDuration) +VALUES (?, ?, ?, ?, ?) +""" update_song_album_obj = ["{SongId}", "{AlbumId}", "{Index}", "{Title}", "{Runtime}"] -update_song_rating = """ UPDATE song - SET iTimesPlayed = ?, lastplayed = ?, rating = ? - WHERE idSong = ? - """ +update_song_rating = """ +UPDATE song +SET iTimesPlayed = ?, lastplayed = ?, rating = ? +WHERE idSong = ? +""" update_song_rating_obj = ["{PlayCount}", "{DatePlayed}", "{Rating}", "{KodiId}"] -update_genre_album = """ INSERT OR REPLACE INTO album_genre(idGenre, idAlbum) - VALUES (?, ?) - """ -update_genre_song = """ INSERT OR REPLACE INTO song_genre(idGenre, idSong) - VALUES (?, ?) - """ +update_genre_album = """ +INSERT OR REPLACE INTO album_genre(idGenre, idAlbum) +VALUES (?, ?) +""" +update_genre_song = """ +INSERT OR REPLACE INTO song_genre(idGenre, idSong) +VALUES (?, ?) +""" update_genre_song_obj = ["{SongId}", "{Genres}", "song"] -delete_genres_album = """ DELETE FROM album_genre - WHERE idAlbum = ? - """ -delete_genres_song = """ DELETE FROM song_genre - WHERE idSong = ? - """ -delete_artist = """ DELETE FROM artist - WHERE idArtist = ? - """ -delete_album = """ DELETE FROM album - WHERE idAlbum = ? - """ -delete_song = """ DELETE FROM song - WHERE idSong = ? - """ -get_version = """ SELECT idVersion - FROM version - """ -update_versiontag = """ INSERT OR REPLACE INTO versiontagscan(idVersion, iNeedsScan) - VALUES (?, 0) - """ -get_versiontagcount = """ SELECT COUNT(*) - FROM versiontagscan - """ +delete_genres_album = """ +DELETE FROM album_genre +WHERE idAlbum = ? +""" +delete_genres_song = """ +DELETE FROM song_genre +WHERE idSong = ? +""" +delete_artist = """ +DELETE FROM artist +WHERE idArtist = ? +""" +delete_album = """ +DELETE FROM album +WHERE idAlbum = ? +""" +delete_song = """ +DELETE FROM song +WHERE idSong = ? +""" +get_version = """ +SELECT idVersion +FROM version +""" +update_versiontag = """ +INSERT OR REPLACE INTO versiontagscan(idVersion, iNeedsScan) +VALUES (?, 0) +""" +get_versiontagcount = """ +SELECT COUNT (*) +FROM versiontagscan +""" diff --git a/resources/lib/objects/kodi/queries_texture.py b/resources/lib/objects/kodi/queries_texture.py index 4255767a..25960941 100644 --- a/resources/lib/objects/kodi/queries_texture.py +++ b/resources/lib/objects/kodi/queries_texture.py @@ -1,10 +1,12 @@ -get_cache = """ SELECT cachedurl - FROM texture - WHERE url = ? - """ +get_cache = """ +SELECT cachedurl +FROM texture +WHERE url = ? +""" -delete_cache = """ DELETE FROM texture - WHERE url = ? - """ +delete_cache = """ +DELETE FROM texture +WHERE url = ? +"""