Skip to content

Conversation

@zeroquinc
Copy link
Contributor

@zeroquinc zeroquinc commented Feb 26, 2025

Currently the webhook returns only the Episode or Movie external ID's.
This PR will also return the Show External ID's.

    "SeriesProvider_imdb": "tt0903747",
    "SeriesProvider_tmdb": "1396",
    "SeriesProvider_tvrage": "18164",
    "SeriesProvider_tvdb": "81189",
    "SeriesProvider_tvmaze": "169",
    "Provider_tvdb": "4460282",
    "Provider_imdb": "tt2301471",

Comment on lines +162 to +168
if (episode.Series?.ProviderIds is not null)
{
foreach (var (providerKey, providerValue) in episode.Series.ProviderIds)
{
dataObject[$"SeriesProvider_{providerKey.ToLowerInvariant()}"] = providerValue;
}
}
Copy link
Member

@JPVenson JPVenson Apr 26, 2025

Choose a reason for hiding this comment

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

Suggested change
if (episode.Series?.ProviderIds is not null)
{
foreach (var (providerKey, providerValue) in episode.Series.ProviderIds)
{
dataObject[$"SeriesProvider_{providerKey.ToLowerInvariant()}"] = providerValue;
}
}
if (episode.Series?.ProviderIds is not null)
{
var providers = new Dictionary<string, object>();
dataObject["SeriesProviders"] = providers;
foreach (var (providerKey, providerValue) in episode.Series.ProviderIds)
{
providers[providerKey.ToLowerInvariant()] = providerValue;
}
}

why not make this a new object instead?

Choose a reason for hiding this comment

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

why not using use ProviderIds directly ?
dataObject[SeriesProviders] = episode.Series.ProviderIds
or
dataObject[SeriesProviders] = episode.Series.ProviderIds.ToDictionary(x => x.Key, x => x.Value)
if you want a different reference.

looking at the rest of the existing code. there seems to be a conscious effort to avoid objects (look at how media streams are assigned). I don't know what the reason is. changing those could be a breaking change for people.

{
foreach (var (providerKey, providerValue) in episode.Series.ProviderIds)
{
dataObject[$"SeriesProvider_{providerKey.ToLowerInvariant()}"] = providerValue;

Choose a reason for hiding this comment

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

the dataObject dictionary is using StringComparer.OrdinalIgnoreCase comparer, so need to use ToLowerInvariant() on the keys, you're just making more allocations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants