Skip to content

Commit

Permalink
Optimization and Cosmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjswan committed Apr 25, 2024
1 parent ce13e3a commit c43b59d
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 68 deletions.
71 changes: 41 additions & 30 deletions FanartHandler/FanartSelectedOther.cs
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,14 @@ public void AddSelectedGenreProperty(string Genres, string sTitle, Utils.Selecte
FanartAvailable = FanartAvailable || picFound;
}

public void AddSelectedMoviePropertys()
{
AddSelectedMoviePropertys(string.Empty);
}

public void AddSelectedMoviePropertys(string SelectedItem)
{
// Movies
string strIMDBID = Utils.GetProperty("#imdbnumber");
if (string.IsNullOrEmpty(strIMDBID))
{
Expand All @@ -856,57 +862,62 @@ public void AddSelectedMoviePropertys(string SelectedItem)

// Trakt does not clear the #Trakt.Movie.ImdbId value so exit function when Trakt page and SelectedItem is null, or ClearArt will turn up when it should not
if (SelectedItem == "TraktIsNull")
{
return;

}
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
// strTVDBID = UtilsTVSeries.GetTVSeriesID(50);
//}

if (!string.IsNullOrEmpty(strIMDBID))
{
bool picFound = Utils.AnimatedFileExists(strIMDBID, null, null, Utils.Animated.MoviesPoster);
FanartAvailable = FanartAvailable || picFound;
Utils.SetProperty("movie.animated.selected.thumb",
Utils.AnimatedFileExists(strIMDBID, null, null, Utils.Animated.MoviesPoster) ? Utils.GetAnimatedFileName(strIMDBID, null, null, Utils.Animated.MoviesPoster) : string.Empty);
picFound ? Utils.GetAnimatedFileName(strIMDBID, null, null, Utils.Animated.MoviesPoster) : string.Empty);
picFound = Utils.AnimatedFileExists(strIMDBID, null, null, Utils.Animated.MoviesBackground);
FanartAvailable = FanartAvailable || picFound;
Utils.SetProperty("movie.animated.selected.background",
Utils.AnimatedFileExists(strIMDBID, null, null, Utils.Animated.MoviesBackground) ? Utils.GetAnimatedFileName(strIMDBID, null, null, Utils.Animated.MoviesBackground) : string.Empty);
picFound ? Utils.GetAnimatedFileName(strIMDBID, null, null, Utils.Animated.MoviesBackground) : string.Empty);

picFound = Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesClearArt);
FanartAvailable = FanartAvailable || picFound;
Utils.SetProperty("movie.clearart.selected",
Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesClearArt) ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesClearArt) : string.Empty);
picFound ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesClearArt) : string.Empty);
picFound = Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesClearLogo);
FanartAvailable = FanartAvailable || picFound;
Utils.SetProperty("movie.clearlogo.selected",
Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesClearLogo) ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesClearLogo) : string.Empty);
picFound ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesClearLogo) : string.Empty);
picFound = Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesBanner);
FanartAvailable = FanartAvailable || picFound;
Utils.SetProperty("movie.banner.selected",
Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesBanner) ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesBanner) : string.Empty);
picFound ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesBanner) : string.Empty);
picFound = Utils.FanartTVFileExists(strIMDBID, null, null, Utils.FanartTV.MoviesCDArt);
FanartAvailable = FanartAvailable || picFound;
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);
picFound ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesCDArt) : string.Empty);
}

// TV Series
string strTVDBID = Utils.GetProperty("#Trakt.Show.TvdbId");
if (string.IsNullOrEmpty(strTVDBID))
{
strTVDBID = Utils.GetProperty("#TVSeries.Series.ID");
}

if (!string.IsNullOrEmpty(strTVDBID))
{
bool picFound = Utils.FanartTVFileExists(strTVDBID, null, null, Utils.FanartTV.SeriesClearArt);
FanartAvailable = FanartAvailable || picFound;
Utils.SetProperty("series.clearart.selected",
Utils.FanartTVFileExists(strTVDBID, null, null, Utils.FanartTV.SeriesClearArt) ? Utils.GetFanartTVFileName(strTVDBID, null, null, Utils.FanartTV.SeriesClearArt) : string.Empty);
picFound ? Utils.GetFanartTVFileName(strTVDBID, null, null, Utils.FanartTV.SeriesClearArt) : string.Empty);
picFound = Utils.FanartTVFileExists(strTVDBID, null, null, Utils.FanartTV.SeriesClearLogo);
FanartAvailable = FanartAvailable || picFound;
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);
picFound ? Utils.GetFanartTVFileName(strTVDBID, null, null, Utils.FanartTV.SeriesClearLogo) : string.Empty);
}

if (string.IsNullOrEmpty(strIMDBID) && string.IsNullOrEmpty(strTVDBID))
{
ClearSelectedMoviePropertys();
Expand Down
54 changes: 28 additions & 26 deletions FanartHandler/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2525,10 +2525,10 @@ public static void GetSelectedItem(ref string SelectedItem, ref string SelectedA
SelectedItem = GetArtistLeftOfMinusSign(SelectedItem);
}
else if (iActiveWindow == 2003 || // Dialog Video Info
iActiveWindow == 6 || // My Video
iActiveWindow == 25 || // My Video Title
iActiveWindow == 614 || // Dialog Video Artist Info
iActiveWindow == 28 || // My Video Play List
iActiveWindow == 6 || // My Video
iActiveWindow == 25 || // My Video Title
iActiveWindow == 614 || // Dialog Video Artist Info
iActiveWindow == 28 || // My Video Play List
iActiveWindow == 99555 // My Video Importer
)
{
Expand Down Expand Up @@ -2584,15 +2584,15 @@ public static void GetSelectedItem(ref string SelectedItem, ref string SelectedA
}
}
}
else if (iActiveWindow == 96742) // Moving Pictures
else if (iActiveWindow == 96742) // Moving Pictures
{
SelectedItem = Utils.GetProperty("#MovingPictures.SelectedMovie.title");
SelectedStudios = Utils.GetProperty("#MovingPictures.SelectedMovie.studios");
SelectedGenre = Utils.GetProperty("#MovingPictures.SelectedMovie.genres");
// logger.Debug("*** "+SelectedItem+" - "+SelectedStudios+" - "+SelectedGenre);
}
else if (iActiveWindow == 9811 || // TVSeries
iActiveWindow == 9813) // TVSeries Playlist
else if (iActiveWindow == 9811 || // TVSeries
iActiveWindow == 9813) // TVSeries Playlist
{
SelectedItem = UtilsTVSeries.GetTVSeriesAttributes(ref SelectedGenre, ref SelectedStudios);
if (string.IsNullOrWhiteSpace(SelectedItem))
Expand Down Expand Up @@ -2625,7 +2625,7 @@ public static void GetSelectedItem(ref string SelectedItem, ref string SelectedA
isMusicVideo = true;
}
}
else if (iActiveWindow == 25650) // Radio Time
else if (iActiveWindow == 25650) // Radio Time
{
SelectedItem = Utils.GetProperty("#RadioTime.Selected.Subtext"); // Artist - Track || TODO for: Artist - Album - Track
SelectedItem = GetArtistLeftOfMinusSign(SelectedItem, true);
Expand Down Expand Up @@ -2653,35 +2653,35 @@ 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
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 != null || selectedListItem.IsFolder)
if (selectedListItem != null)
{
if (selectedListItem.IsFolder)
{
GUIControl cntl = window.GetControl(50);
if (cntl is GUIFacadeControl)
{
GUIControl cntl = window.GetControl(50);
if (cntl is GUIFacadeControl)
{
SelectedItem = string.Empty;
}
SelectedItem = string.Empty;
}
}
}
else
{
Expand All @@ -2691,7 +2691,9 @@ public static void GetSelectedItem(ref string SelectedItem, ref string SelectedA
}
}
else
{
SelectedItem = Utils.GetProperty("#selecteditem");
}

SelectedAlbum = (string.IsNullOrWhiteSpace(SelectedAlbum) ? null : SelectedAlbum);
SelectedGenre = (string.IsNullOrWhiteSpace(SelectedGenre) ? null : SelectedGenre.Replace(" / ", "|").Replace(", ", "|"));
Expand Down
33 changes: 21 additions & 12 deletions FanartHandler/UtilsTVSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,32 +209,41 @@ internal static Hashtable GetTVSeries(Utils.Category category, Utils.SubCategory
return result;
}

internal static string GetTVSeriesID(int ControlID) // -> TV Series ID ...
internal static string GetTVSeriesID() // -> Selected TV Series ID ...
{
if (!Utils.TVSeriesEnabled)
{
return string.Empty;
}

if (Utils.iActiveWindow != 9811 && // TVSeries
Utils.iActiveWindow != 9813) // TVSeries Playlist
{
return string.Empty;
}
var window = GUIWindowManager.GetWindow(Utils.iActiveWindow);
GUIControl cntl = window.GetControl(50);
if (cntl != null && cntl is GUIFacadeControl)

try
{
GUIListItem selectedListItem = (cntl as GUIFacadeControl).SelectedListItem;
if (selectedListItem != null)
{
DBSeries series = selectedListItem.TVTag as DBSeries;
if (series != null)
var window = GUIWindowManager.GetWindow(Utils.iActiveWindow);
GUIControl cntl = window.GetControl(50); // 50 - GUIFacadeControl
if (cntl != null && cntl is GUIFacadeControl)
{
GUIListItem selectedListItem = (cntl as GUIFacadeControl).SelectedListItem;
if (selectedListItem != null)
{
return series[DBOnlineSeries.cID];
DBSeries series = selectedListItem.TVTag as DBSeries;
if (series != null)
{
return series[DBOnlineSeries.cID];
}
}
}
}
}
return string.Empty;
catch (Exception ex)
{
logger.Error("GetTVSeriesID: " + ex);
}
return string.Empty;
}

internal static string GetTVSeriesAttributes(GUIListItem currentitem, ref string sGenre, ref string sStudio) // -> TV Series name ...
Expand Down

0 comments on commit c43b59d

Please sign in to comment.