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

Add Tvdb Collection Ids #162

Merged
merged 7 commits into from
Jul 15, 2024
Merged

Add Tvdb Collection Ids #162

merged 7 commits into from
Jul 15, 2024

Conversation

scampower3
Copy link
Member

@scampower3 scampower3 commented Jul 14, 2024

A series can have multiple tvdb collection ids. So store them as a string and delimit them with semicolons.
For use for future tvdb collection management

@scampower3 scampower3 added the feature This PR or Issue requests or introduces a new feature label Jul 14, 2024
if (isOfficial is true)
{
var id = jsonElementCollection.GetProperty("id").GetInt32().ToString(CultureInfo.InvariantCulture);
collectionIds += id + ";";

Check notice

Code scanning / CodeQL

String concatenation in loop Note

String concatenation in loop: use 'StringBuilder'.
Comment on lines 464 to 475
foreach (var collection in collections)
{
if (collection is JsonElement jsonElementCollection)
{
var isOfficial = jsonElementCollection.GetProperty("isOfficial").GetBoolean();
if (isOfficial is true)
{
var id = jsonElementCollection.GetProperty("id").GetInt32().ToString(CultureInfo.InvariantCulture);
collectionIds += id + ";";
}
}
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where Note

This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
Comment on lines 464 to 465
.Where(x => x.GetProperty("isOfficial").GetBoolean())
.Select(x => x.GetProperty("id").GetInt32().ToString(CultureInfo.InvariantCulture))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks super clean but this would throw an exception if a property is missing or not a bool/int

Can't rely on tvdb to be consistent 🙃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, these two property is always present.
I can wrap a try catch around this.

Comment on lines +472 to +475
catch (Exception e)
{
_logger.LogError(e, "Failed to retrieve collection for series {TvdbId}:{SeriesName}", tvdbSeries.Id, tvdbSeries.Name);
}

Check notice

Code scanning / CodeQL

Generic catch clause Note

Generic catch clause.
@crobibero crobibero merged commit f47458a into jellyfin:master Jul 15, 2024
4 checks passed
@scampower3 scampower3 deleted the add-boxsetid branch July 15, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This PR or Issue requests or introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants