Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Trakt to use FanartHandler ClearArt paths for Movies #1

Merged
merged 9 commits into from
Apr 25, 2024
29 changes: 21 additions & 8 deletions FanartHandler/FanartHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ internal void Start()
Utils.Check(FSelected.WindowsUsingFanartSelectedPictures.Count > 0) + " Pictures Fanart, " +
Utils.Check(FSelected.WindowsUsingFanartSelectedScoreCenter.Count > 0) + " ScoreCenter Fanart");
logger.Debug(" " + Utils.Check(FSelectedOther.WindowsUsingFanartSelectedClearArtMusic.Count > 0) + " Music ClearArt, " +
Utils.Check(FSelectedOther.WindowsUsingFanartSelectedClearArtMovie.Count > 0) + " Movie ClearArt, " +
Utils.Check(FSelectedOther.WindowsUsingFanartSelectedGenreMusic.Count > 0) + " Music Genres, " +
Utils.Check(FSelectedOther.WindowsUsingFanartSelectedLabelMusic.Count > 0) + " Music Labels");
logger.Debug(" " + Utils.Check(FSelectedOther.WindowsUsingFanartSelectedStudioMovie.Count > 0) + " Movie Studios, " +
Expand Down Expand Up @@ -1643,6 +1644,7 @@ private void SetupWindowsUsingFanartHandlerVisibility(string SkinDir = (string)

var _flagClearArt = false;
var _flagClearArtPlay = false;
var _flagClearArtMovies = false;

var _flagLabelMusic = false;
var _flagLabelPlay = false;
Expand All @@ -1666,7 +1668,7 @@ private void SetupWindowsUsingFanartHandlerVisibility(string SkinDir = (string)
ref _flag1Movie, ref _flag2Movie,
ref _flag1Picture, ref _flag2Picture,
ref _flagPlay,
ref _flagClearArt, ref _flagClearArtPlay,
ref _flagClearArt, ref _flagClearArtPlay, ref _flagClearArtMovies,
ref _flagGenrePlay, ref _flagGenrePlaySingle, ref _flagGenrePlayAll, ref _flagGenrePlayVertical,
ref _flagGenreMusic, ref _flagGenreMusicSingle, ref _flagGenreMusicAll, ref _flagGenreMusicVertical,
ref _flagGenreMovie, ref _flagGenreMovieSingle, ref _flagGenreMovieAll, ref _flagGenreMovieVertical,
Expand All @@ -1690,7 +1692,7 @@ ref skinFile
ref _flag1Movie, ref _flag2Movie,
ref _flag1Picture, ref _flag2Picture,
ref _flagPlay,
ref _flagClearArt, ref _flagClearArtPlay,
ref _flagClearArt, ref _flagClearArtPlay, ref _flagClearArtMovies,
ref _flagGenrePlay, ref _flagGenrePlaySingle, ref _flagGenrePlayAll, ref _flagGenrePlayVertical,
ref _flagGenreMusic, ref _flagGenreMusicSingle, ref _flagGenreMusicAll, ref _flagGenreMusicVertical,
ref _flagGenreMovie, ref _flagGenreMovieSingle, ref _flagGenreMovieAll, ref _flagGenreMovieVertical,
Expand All @@ -1709,7 +1711,7 @@ ref skinFile
ref _flag1Movie, ref _flag2Movie,
ref _flag1Picture, ref _flag2Picture,
ref _flagPlay,
ref _flagClearArt, ref _flagClearArtPlay,
ref _flagClearArt, ref _flagClearArtPlay, ref _flagClearArtMovies,
ref _flagGenrePlay, ref _flagGenrePlaySingle, ref _flagGenrePlayAll, ref _flagGenrePlayVertical,
ref _flagGenreMusic, ref _flagGenreMusicSingle, ref _flagGenreMusicAll, ref _flagGenreMusicVertical,
ref _flagGenreMovie, ref _flagGenreMovieSingle, ref _flagGenreMovieAll, ref _flagGenreMovieVertical,
Expand All @@ -1730,7 +1732,7 @@ ref skinFile
ref _flag1Movie, ref _flag2Movie,
ref _flag1Picture, ref _flag2Picture,
ref _flagPlay,
ref _flagClearArt, ref _flagClearArtPlay,
ref _flagClearArt, ref _flagClearArtPlay, ref _flagClearArtMovies,
ref _flagGenrePlay, ref _flagGenrePlaySingle, ref _flagGenrePlayAll, ref _flagGenrePlayVertical,
ref _flagGenreMusic, ref _flagGenreMusicSingle, ref _flagGenreMusicAll, ref _flagGenreMusicVertical,
ref _flagGenreMovie, ref _flagGenreMovieSingle, ref _flagGenreMovieAll, ref _flagGenreMovieVertical,
Expand Down Expand Up @@ -1759,7 +1761,7 @@ ref skinFile
ref _flag1Movie, ref _flag2Movie,
ref _flag1Picture, ref _flag2Picture,
ref _flagPlay,
ref _flagClearArt, ref _flagClearArtPlay,
ref _flagClearArt, ref _flagClearArtPlay, ref _flagClearArtMovies,
ref _flagGenrePlay, ref _flagGenrePlaySingle, ref _flagGenrePlayAll, ref _flagGenrePlayVertical,
ref _flagGenreMusic, ref _flagGenreMusicSingle, ref _flagGenreMusicAll, ref _flagGenreMusicVertical,
ref _flagGenreMovie, ref _flagGenreMovieSingle, ref _flagGenreMovieAll, ref _flagGenreMovieVertical,
Expand All @@ -1778,7 +1780,7 @@ ref skinFile
ref _flag1Movie, ref _flag2Movie,
ref _flag1Picture, ref _flag2Picture,
ref _flagPlay,
ref _flagClearArt, ref _flagClearArtPlay,
ref _flagClearArt, ref _flagClearArtPlay, ref _flagClearArtMovies,
ref _flagGenrePlay, ref _flagGenrePlaySingle, ref _flagGenrePlayAll, ref _flagGenrePlayVertical,
ref _flagGenreMusic, ref _flagGenreMusicSingle, ref _flagGenreMusicAll, ref _flagGenreMusicVertical,
ref _flagGenreMovie, ref _flagGenreMovieSingle, ref _flagGenreMovieAll, ref _flagGenreMovieVertical,
Expand All @@ -1799,7 +1801,7 @@ ref skinFile
ref _flag1Movie, ref _flag2Movie,
ref _flag1Picture, ref _flag2Picture,
ref _flagPlay,
ref _flagClearArt, ref _flagClearArtPlay,
ref _flagClearArt, ref _flagClearArtPlay, ref _flagClearArtMovies,
ref _flagGenrePlay, ref _flagGenrePlaySingle, ref _flagGenrePlayAll, ref _flagGenrePlayVertical,
ref _flagGenreMusic, ref _flagGenreMusicSingle, ref _flagGenreMusicAll, ref _flagGenreMusicVertical,
ref _flagGenreMovie, ref _flagGenreMovieSingle, ref _flagGenreMovieAll, ref _flagGenreMovieVertical,
Expand Down Expand Up @@ -1848,6 +1850,11 @@ ref skinFile
{
FSelectedOther.WindowsUsingFanartSelectedClearArtMusic.Add(nodeValue, nodeValue);
}
// Selected Movie ClearArt
if (_flagClearArtMovies && !Utils.ContainsID(FSelectedOther.WindowsUsingFanartSelectedClearArtMovie, nodeValue))
{
FSelectedOther.WindowsUsingFanartSelectedClearArtMovie.Add(nodeValue, nodeValue);
}
#endregion

#region Labels
Expand Down Expand Up @@ -2047,7 +2054,7 @@ private void HandleXmlImports(string filename, string windowId,
ref bool _flag1Movie, ref bool _flag2Movie,
ref bool _flag1Picture, ref bool _flag2Picture,
ref bool _flagPlay,
ref bool _flagClearArt, ref bool _flagClearArtPlay,
ref bool _flagClearArt, ref bool _flagClearArtPlay, ref bool _flagClearArtMovies,
ref bool _flagGenrePlay, ref bool _flagGenrePlaySingle, ref bool _flagGenrePlayAll, ref bool _flagGenrePlayVertical,
ref bool _flagGenreMusic, ref bool _flagGenreMusicSingle, ref bool _flagGenreMusicAll, ref bool _flagGenreMusicVertical,
ref bool _flagGenreMovie, ref bool _flagGenreMovieSingle, ref bool _flagGenreMovieAll, ref bool _flagGenreMovieVertical,
Expand Down Expand Up @@ -2136,6 +2143,12 @@ private void HandleXmlImports(string filename, string windowId,
_flagClearArt = true;
}

// ClearArt Movies
if (_xml.Contains("#fanarthandler.movie.clearart.selected") || _xml.Contains("#fanarthandler.movie.clearlogo.selected") || _xml.Contains("#fanarthandler.movie.cd.selected") || _xml.Contains("#fanarthandler.series.clearart.selected") || _xml.Contains("#fanarthandler.series.clearlogo.selected"))
{
_flagClearArtMovies = true;
}

// Labels
if (_xml.Contains("#fanarthandler.music.labels.selected"))
{
Expand Down
58 changes: 55 additions & 3 deletions FanartHandler/FanartSelectedOther.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using WindowPlugins.GUITVSeries;
andrewjswan marked this conversation as resolved.
Show resolved Hide resolved

namespace FanartHandler
{
Expand All @@ -38,6 +39,7 @@ internal class FanartSelectedOther
public int RefreshTickCount { get; set; }

public Hashtable WindowsUsingFanartSelectedClearArtMusic { get; set; }
public Hashtable WindowsUsingFanartSelectedClearArtMovie { get; set; }

public Hashtable WindowsUsingFanartSelectedGenreMusic { get; set; }
public Hashtable WindowsUsingFanartSelectedLabelMusic { get; set; }
Expand All @@ -62,6 +64,7 @@ public FanartSelectedOther()
RefreshTickCount = 0;

WindowsUsingFanartSelectedClearArtMusic = new Hashtable();
WindowsUsingFanartSelectedClearArtMovie = new Hashtable();

WindowsUsingFanartSelectedGenreMusic = new Hashtable();
WindowsUsingFanartSelectedLabelMusic = new Hashtable();
Expand Down Expand Up @@ -97,6 +100,7 @@ public bool CheckValidWindowIDForFanart()
Utils.ContainsID(WindowsUsingFanartSelectedGenreMovie) ||
Utils.ContainsID(WindowsUsingFanartSelectedStudioMovie) ||
Utils.ContainsID(WindowsUsingFanartSelectedClearArtMusic) ||
Utils.ContainsID(WindowsUsingFanartSelectedClearArtMovie) ||
Utils.ContainsID(WindowsUsingFanartSelectedAwardMovie)
);
}
Expand Down Expand Up @@ -153,7 +157,8 @@ public void RefreshGenericSelectedProperties(Utils.SelectedType property, ref st

if (isVideo)
{
AddSelectedMoviePropertys();
Console.WriteLine(Utils.iActiveWindow.ToString());
andrewjswan marked this conversation as resolved.
Show resolved Hide resolved
AddSelectedMoviePropertys();
}

ResetRefreshTickCount();
Expand Down Expand Up @@ -301,7 +306,8 @@ public void RefreshSelected(RefreshWorker rw, System.ComponentModel.DoWorkEventA
{
if (Utils.ContainsID(WindowsUsingFanartSelectedGenreMovie) ||
Utils.ContainsID(WindowsUsingFanartSelectedStudioMovie) ||
Utils.ContainsID(WindowsUsingFanartSelectedAwardMovie))
Utils.ContainsID(WindowsUsingFanartSelectedAwardMovie) ||
Utils.ContainsID(WindowsUsingFanartSelectedClearArtMovie))
{
IsSelectedVideo = true;
RefreshGenericSelectedProperties(Utils.SelectedType.Movie,
Expand Down Expand Up @@ -849,6 +855,32 @@ public void AddSelectedMoviePropertys()
{
strIMDBID = Utils.GetProperty("#myfilms.db.imdb_id.value");
}
if (string.IsNullOrEmpty(strIMDBID))
{
strIMDBID = Utils.GetProperty("#Trakt.Movie.ImdbId");
}
string strTVDBID = Utils.GetProperty("#Trakt.Show.TvdbId");
if (string.IsNullOrEmpty(strTVDBID))
{
strTVDBID = Utils.GetProperty("#TVSeries.Series.ID");
}
if (string.IsNullOrEmpty(strTVDBID))
{
// TV Series ID
var window = GUIWindowManager.GetWindow(Utils.iActiveWindow);
if (window != null)
{
var selectedListItem = GUIControl.GetSelectedListItem(Utils.iActiveWindow, window.GetFocusControlId());
if (selectedListItem != null)
{
DBSeries series = selectedListItem.TVTag as DBSeries;
if (series != null)
{
strTVDBID = series[DBOnlineSeries.cID];
}
}
}
}

if (!string.IsNullOrEmpty(strIMDBID))
{
Expand All @@ -865,8 +897,25 @@ public void AddSelectedMoviePropertys()
Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesBanner) ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesBanner) : string.Empty);
Utils.SetProperty("movie.cd.selected",
Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesCDArt) ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesCDArt) : string.Empty);
FanartAvailable = FanartAvailable ||
Utils.AnimatedFileExists(strIMDBID, null, null, Utils.Animated.MoviesPoster) ||
Utils.AnimatedFileExists(strIMDBID, null, null, Utils.Animated.MoviesBackground) ||
Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesClearArt) ||
Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesClearLogo) ||
Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesBanner) ||
Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesCDArt);
andrewjswan marked this conversation as resolved.
Show resolved Hide resolved
}
else
if (!string.IsNullOrEmpty(strTVDBID))
{
Utils.SetProperty("series.clearart.selected",
Utils.FanartTVFileExists(strTVDBID, null, null, Utils.FanartTV.SeriesClearArt) ? Utils.GetFanartTVFileName(strTVDBID, null, null, Utils.FanartTV.SeriesClearArt) : string.Empty);
Utils.SetProperty("series.clearlogo.selected",
Utils.FanartTVFileExists(strTVDBID, null, null, Utils.FanartTV.SeriesClearLogo) ? Utils.GetFanartTVFileName(strTVDBID, null, null, Utils.FanartTV.SeriesClearLogo) : string.Empty);
FanartAvailable = FanartAvailable ||
Utils.FanartTVFileExists(strTVDBID, null, null, Utils.FanartTV.SeriesClearArt) ||
Utils.FanartTVFileExists(strTVDBID, null, null, Utils.FanartTV.SeriesClearLogo);
}
if (string.IsNullOrEmpty(strIMDBID) && string.IsNullOrEmpty(strTVDBID))
{
ClearSelectedMoviePropertys();
}
Expand All @@ -880,6 +929,9 @@ public void ClearSelectedMoviePropertys()
Utils.SetProperty("movie.clearlogo.selected", string.Empty);
Utils.SetProperty("movie.banner.selected", string.Empty);
Utils.SetProperty("movie.cd.selected", string.Empty);

Utils.SetProperty("series.clearart.selected", string.Empty);
Utils.SetProperty("series.clearlogo.selected", string.Empty);
andrewjswan marked this conversation as resolved.
Show resolved Hide resolved
}

private void EmptyMusicProperties(bool currClean = true)
Expand Down
28 changes: 27 additions & 1 deletion FanartHandler/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,7 @@ public static void GetSelectedItem(ref string SelectedItem, ref string SelectedA
}
else if (iActiveWindow == 96742) // Moving Pictures
{
SelectedItem = Utils.GetProperty("#selecteditem");
SelectedItem = Utils.GetProperty("#MovingPictures.SelectedMovie.title");
SelectedStudios = Utils.GetProperty("#MovingPictures.SelectedMovie.studios");
SelectedGenre = Utils.GetProperty("#MovingPictures.SelectedMovie.genres");
// logger.Debug("*** "+SelectedItem+" - "+SelectedStudios+" - "+SelectedGenre);
Expand Down Expand Up @@ -2634,6 +2634,32 @@ public static void GetSelectedItem(ref string SelectedItem, ref string SelectedA
}
catch { }
}
else if (iActiveWindow == 87266 || // Trakt Trending Movies
iActiveWindow == 87700 || // Trakt Calendar Movies
iActiveWindow == 87101 || // Trakt Popular Movies
iActiveWindow == 87263 || // Trakt Recommendations Movies
iActiveWindow == 87605 || // Trakt Anticipated Movies
iActiveWindow == 87607 || // Trakt Box Office
iActiveWindow == 87265 || // Trakt Trending Series
iActiveWindow == 87102 || // Trakt Popular Series
iActiveWindow == 87262 || // Trakt Recommendations Series
iActiveWindow == 87259 || // Trakt Calendar Series
iActiveWindow == 87606 || // Trakt Anticipated Series
iActiveWindow == 87281 || // Trakt Series Seasons
iActiveWindow == 87282) // Trakt Series Episodes
{
SelectedItem = Utils.GetProperty("#selecteditem");
// Remove ClearArt on Trakt Folders
var window = GUIWindowManager.GetWindow(Utils.iActiveWindow);
if (window != null)
{
var selectedListItem = GUIControl.GetSelectedListItem(Utils.iActiveWindow, window.GetFocusControlId());
if (selectedListItem == null || selectedListItem.IsFolder)
{
SelectedItem = string.Empty;
}
}
}
else
SelectedItem = Utils.GetProperty("#selecteditem");

Expand Down