Skip to content

Commit

Permalink
Normalizing property names, restructure (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjswan authored Apr 26, 2024
1 parent a078bca commit 2e9c760
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 25 deletions.
3 changes: 2 additions & 1 deletion FanartHandler/FanartHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,8 @@ private void HandleXmlImports(string filename, string windowId,
}

// 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"))
if (_xml.Contains("#fanarthandler.movie.clearart.selected") || _xml.Contains("#fanarthandler.movie.clearlogo.selected") || _xml.Contains("#fanarthandler.movie.cd.selected") ||
_xml.Contains("#fanarthandler.tvseries.clearart.selected") || _xml.Contains("#fanarthandler.tvseries.clearlogo.selected"))
{
_flagClearArtMovies = true;
}
Expand Down
76 changes: 52 additions & 24 deletions FanartHandler/FanartSelectedOther.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public void RefreshGenericSelectedProperties(Utils.SelectedType property, ref st
if (isVideo)
{
AddSelectedMoviePropertys(SelectedItem);
AddSelectedSeriesPropertys(SelectedItem);
}

ResetRefreshTickCount();
Expand Down Expand Up @@ -849,7 +850,12 @@ public void AddSelectedMoviePropertys()

public void AddSelectedMoviePropertys(string SelectedItem)
{
// Movies
// 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;
}

string strIMDBID = Utils.GetProperty("#imdbnumber");
if (string.IsNullOrEmpty(strIMDBID))
{
Expand All @@ -859,12 +865,6 @@ public void AddSelectedMoviePropertys(string SelectedItem)
{
strIMDBID = Utils.GetProperty("#myfilms.db.imdb_id.value");
}

// 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");
Expand Down Expand Up @@ -899,7 +899,35 @@ public void AddSelectedMoviePropertys(string SelectedItem)
picFound ? Utils.GetFanartTVFileName(strIMDBID, null, null, Utils.FanartTV.MoviesCDArt) : string.Empty);
}

// TV Series
if (string.IsNullOrEmpty(strIMDBID))
{
ClearSelectedMoviePropertys();
}
}

public void ClearSelectedMoviePropertys()
{
Utils.SetProperty("movie.animated.selected.thumb", string.Empty);
Utils.SetProperty("movie.animated.selected.background", string.Empty);
Utils.SetProperty("movie.clearart.selected", string.Empty);
Utils.SetProperty("movie.clearlogo.selected", string.Empty);
Utils.SetProperty("movie.banner.selected", string.Empty);
Utils.SetProperty("movie.cd.selected", string.Empty);
}

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

public void AddSelectedSeriesPropertys(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;
}

string strTVDBID = Utils.GetProperty("#Trakt.Show.TvdbId");
if (string.IsNullOrEmpty(strTVDBID))
{
Expand All @@ -910,33 +938,26 @@ public void AddSelectedMoviePropertys(string SelectedItem)
{
bool picFound = Utils.FanartTVFileExists(strTVDBID, null, null, Utils.FanartTV.SeriesClearArt);
FanartAvailable = FanartAvailable || picFound;
Utils.SetProperty("series.clearart.selected",
Utils.SetProperty("tvseries.clearart.selected",
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.SetProperty("tvseries.clearlogo.selected",
picFound ? Utils.GetFanartTVFileName(strTVDBID, null, null, Utils.FanartTV.SeriesClearLogo) : string.Empty);
}

if (string.IsNullOrEmpty(strIMDBID) && string.IsNullOrEmpty(strTVDBID))
if (string.IsNullOrEmpty(strTVDBID))
{
ClearSelectedMoviePropertys();
ClearSelectedSeriesPropertys();
}
}

public void ClearSelectedMoviePropertys()
public void ClearSelectedSeriesPropertys()
{
Utils.SetProperty("movie.animated.selected.thumb", string.Empty);
Utils.SetProperty("movie.animated.selected.background", string.Empty);
Utils.SetProperty("movie.clearart.selected", string.Empty);
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);
Utils.SetProperty("tvseries.clearart.selected", string.Empty);
Utils.SetProperty("tvseries.clearlogo.selected", string.Empty);
}

private void EmptyMusicProperties(bool currClean = true)
{
if (currClean)
Expand All @@ -959,6 +980,7 @@ private void EmptyVideoProperties(bool currClean = true)
CurrSelectedMovieTitle = string.Empty;
}
EmptySelectedMoviesProperties();
EmptySelectedSeriesProperties();
IsSelectedVideo = false;
}

Expand Down Expand Up @@ -1023,10 +1045,16 @@ public void EmptySelectedMoviesProperties()
ClearSelectedMoviePropertys();
}

public void EmptySelectedSeriesProperties()
{
ClearSelectedSeriesPropertys();
}

public void EmptyAllSelectedProperties()
{
EmptySelectedMusicProperties();
EmptySelectedMoviesProperties();
EmptySelectedSeriesProperties();
}

public void ShowImageSelected()
Expand Down Expand Up @@ -1078,4 +1106,4 @@ public void ShowImageTwo()
}

}
}
}

0 comments on commit 2e9c760

Please sign in to comment.