HristoKolev / TvDbSharper

TvDbSharper is fully featured modern REST client for the TheTVDB API v4
MIT License
29 stars 17 forks source link

GetActorsAsync(384751)).Data throws TvDbSharper.TvDbServerException (404) for shows without any cast #24

Closed mpfc75 closed 3 years ago

mpfc75 commented 3 years ago

Trying to get list of actors for series 384751. Valid series id in tvdb. When I call GetActorsAsync my app receives a 404. Shouldn't the 404 be caught by TvDBSharper and a null TvDbSharper.Dto.Actor[] returned?

If not, how should I be handling this error condition?

I notice that the tvdb web site doesn't list any cast members for this series (tmdb does however).

Thanks!

HristoKolev commented 3 years ago

Hi, I'm sorry for not answering faster. I'll take a look tomorrow and come back to you.

HristoKolev commented 3 years ago

Hi. I can't reproduce the issue. Here is the code that I use:

using System;
using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json;
using TvDbSharper;
using TvDbSharper.Dto;

namespace ManualTests
{
    static class Program
    {
        static async Task Main(string[] args)
        {

            var client = new TvDbClient();
            var authenticationData = JsonConvert.DeserializeObject<AuthenticationData>(await File.ReadAllTextAsync("../../../auth.json"));
            await client.Authentication.AuthenticateAsync(authenticationData);
            var actors = (await client.Series.GetActorsAsync(384751)).Data;

            Console.WriteLine(JsonConvert.SerializeObject(actors, Formatting.Indented));
        }
    }
}

The output is:

[
  {
    "Id": 65741188,
    "Image": "person/8189718/5fd74320ddad9.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:49:03",
    "Name": "Tory Trowbridge",
    "Role": "Delia",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741174,
    "Image": "person/329545/5fd737e5d69aa.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:01:08",
    "Name": "Lauren Holly",
    "Role": "Monique Dubois",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741180,
    "Image": "person/8180395/5fd740af5d64b.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:38:38",
    "Name": "Michael Hsu Rosen",
    "Role": "Nabil",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741191,
    "Image": "person/552879/5fd743f79dae3.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:52:38",
    "Name": "Jess Salgueiro",
    "Role": "Isabel",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741175,
    "Image": "person/8189716/5fd73918ed4bf.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:06:16",
    "Name": "Kylie Jefferson",
    "Role": "Neveah",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741181,
    "Image": "person/8063761/5fd7413400994.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:40:51",
    "Name": "Damon J. Gillespie",
    "Role": "Caleb",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741194,
    "Image": "",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "",
    "Name": "Anna Maiche",
    "Role": "Cassie Shore",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741177,
    "Image": "person/636887/5fd73cba5ea86.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:21:45",
    "Name": "Casimere Jollette",
    "Role": "Bette",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741184,
    "Image": "person/7877453/5fd74175b3eab.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:41:56",
    "Name": "Bayardo De Murguia",
    "Role": "Ramon",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741178,
    "Image": "person/8189717/5fd73dbcefa07.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:26:03",
    "Name": "Daniela Norman",
    "Role": "June",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741186,
    "Image": "person/8170809/5fd741f76fb80.jpg",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "2020-12-14 10:44:07",
    "Name": "Barton Cowperthwaite",
    "Role": "Oren",
    "SeriesId": 384751,
    "SortOrder": 0
  },
  {
    "Id": 65741179,
    "Image": "",
    "ImageAdded": "",
    "ImageAuthor": null,
    "LastUpdated": "",
    "Name": "Brennan Clost",
    "Role": "Shane",
    "SeriesId": 384751,
    "SortOrder": 0
  }
]

Can you run try it and tell me what happened?

mpfc75 commented 3 years ago

I will run your code and mine too to retest but I think the reason you didn't encounter the error is that tvdb is now showing actors for the show. When I encountered the 404 the site didn't list any.

I came across one or two more the other day but didn't make note of the IDs. I'll try and dig up another example or two.

On Tue., Dec. 15, 2020, 11:51 a.m. Hristo Kolev, notifications@github.com wrote:

Hi. I can't reproduce the issue. Here is the code that I use:

using System;using System.IO;using System.Threading.Tasks;using Newtonsoft.Json;using TvDbSharper;using TvDbSharper.Dto; namespace ManualTests { static class Program { static async Task Main(string[] args) {

        var client = new TvDbClient();
        var authenticationData = JsonConvert.DeserializeObject<AuthenticationData>(await File.ReadAllTextAsync("../../../auth.json"));
        await client.Authentication.AuthenticateAsync(authenticationData);
        var actors = (await client.Series.GetActorsAsync(384751)).Data;

        Console.WriteLine(JsonConvert.SerializeObject(actors, Formatting.Indented));
    }
}

}

The output is:

[ { "Id": 65741188, "Image": "person/8189718/5fd74320ddad9.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:49:03", "Name": "Tory Trowbridge", "Role": "Delia", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741174, "Image": "person/329545/5fd737e5d69aa.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:01:08", "Name": "Lauren Holly", "Role": "Monique Dubois", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741180, "Image": "person/8180395/5fd740af5d64b.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:38:38", "Name": "Michael Hsu Rosen", "Role": "Nabil", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741191, "Image": "person/552879/5fd743f79dae3.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:52:38", "Name": "Jess Salgueiro", "Role": "Isabel", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741175, "Image": "person/8189716/5fd73918ed4bf.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:06:16", "Name": "Kylie Jefferson", "Role": "Neveah", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741181, "Image": "person/8063761/5fd7413400994.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:40:51", "Name": "Damon J. Gillespie", "Role": "Caleb", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741194, "Image": "", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "", "Name": "Anna Maiche", "Role": "Cassie Shore", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741177, "Image": "person/636887/5fd73cba5ea86.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:21:45", "Name": "Casimere Jollette", "Role": "Bette", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741184, "Image": "person/7877453/5fd74175b3eab.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:41:56", "Name": "Bayardo De Murguia", "Role": "Ramon", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741178, "Image": "person/8189717/5fd73dbcefa07.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:26:03", "Name": "Daniela Norman", "Role": "June", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741186, "Image": "person/8170809/5fd741f76fb80.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:44:07", "Name": "Barton Cowperthwaite", "Role": "Oren", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741179, "Image": "", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "", "Name": "Brennan Clost", "Role": "Shane", "SeriesId": 384751, "SortOrder": 0 } ]

Can you run try it and tell me what happened?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HristoKolev/TvDbSharper/issues/24#issuecomment-745420868, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALL6WH2SUT4R5UWR6NBDB6TSU6H2LANCNFSM4UZBTOVA .

mpfc75 commented 3 years ago

Try 392096

I'm away from my development machine at the moment but my app just hung on that new show like it did for the other one and I checked tvdb and no actors yet.

I'll check my code soon.

On Tue., Dec. 15, 2020, 12:12 p.m. Stephen Ross, mpfc75@gmail.com wrote:

I will run your code and mine too to retest but I think the reason you didn't encounter the error is that tvdb is now showing actors for the show. When I encountered the 404 the site didn't list any.

I came across one or two more the other day but didn't make note of the IDs. I'll try and dig up another example or two.

On Tue., Dec. 15, 2020, 11:51 a.m. Hristo Kolev, notifications@github.com wrote:

Hi. I can't reproduce the issue. Here is the code that I use:

using System;using System.IO;using System.Threading.Tasks;using Newtonsoft.Json;using TvDbSharper;using TvDbSharper.Dto; namespace ManualTests { static class Program { static async Task Main(string[] args) {

        var client = new TvDbClient();
        var authenticationData = JsonConvert.DeserializeObject<AuthenticationData>(await File.ReadAllTextAsync("../../../auth.json"));
        await client.Authentication.AuthenticateAsync(authenticationData);
        var actors = (await client.Series.GetActorsAsync(384751)).Data;

        Console.WriteLine(JsonConvert.SerializeObject(actors, Formatting.Indented));
    }
}

}

The output is:

[ { "Id": 65741188, "Image": "person/8189718/5fd74320ddad9.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:49:03", "Name": "Tory Trowbridge", "Role": "Delia", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741174, "Image": "person/329545/5fd737e5d69aa.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:01:08", "Name": "Lauren Holly", "Role": "Monique Dubois", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741180, "Image": "person/8180395/5fd740af5d64b.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:38:38", "Name": "Michael Hsu Rosen", "Role": "Nabil", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741191, "Image": "person/552879/5fd743f79dae3.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:52:38", "Name": "Jess Salgueiro", "Role": "Isabel", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741175, "Image": "person/8189716/5fd73918ed4bf.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:06:16", "Name": "Kylie Jefferson", "Role": "Neveah", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741181, "Image": "person/8063761/5fd7413400994.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:40:51", "Name": "Damon J. Gillespie", "Role": "Caleb", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741194, "Image": "", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "", "Name": "Anna Maiche", "Role": "Cassie Shore", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741177, "Image": "person/636887/5fd73cba5ea86.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:21:45", "Name": "Casimere Jollette", "Role": "Bette", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741184, "Image": "person/7877453/5fd74175b3eab.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:41:56", "Name": "Bayardo De Murguia", "Role": "Ramon", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741178, "Image": "person/8189717/5fd73dbcefa07.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:26:03", "Name": "Daniela Norman", "Role": "June", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741186, "Image": "person/8170809/5fd741f76fb80.jpg", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "2020-12-14 10:44:07", "Name": "Barton Cowperthwaite", "Role": "Oren", "SeriesId": 384751, "SortOrder": 0 }, { "Id": 65741179, "Image": "", "ImageAdded": "", "ImageAuthor": null, "LastUpdated": "", "Name": "Brennan Clost", "Role": "Shane", "SeriesId": 384751, "SortOrder": 0 } ]

Can you run try it and tell me what happened?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HristoKolev/TvDbSharper/issues/24#issuecomment-745420868, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALL6WH2SUT4R5UWR6NBDB6TSU6H2LANCNFSM4UZBTOVA .

HristoKolev commented 3 years ago

If the API returned 404 the call does throw an exception. 404 in this case means that the show doesn't exist. That's how it works. If the API returns 404 for a show that exists that's a bug at their side.

mpfc75 commented 3 years ago

Oh.

But it's not a 404 for a show that exists, it is a 404 for a show that Does exist but doesn't have actors. I thought null works because it describes the (admittedly) strange situation of a show without actors.

So returning null isn't a good solution? That's different than me giving you a bad Series id - the Id is valid.

If you decide that changing your code isn't the best solution will you be opening an issue with tvdb? I don't have the raw data calls to demonstrate the problem.

On Tue., Dec. 15, 2020, 12:25 p.m. Hristo Kolev, notifications@github.com wrote:

If the API returned 404 the call does throw and exception. 404 in this case means that the show doesn't exist. That's how it works. If the API returns 404 for a show that exists that's a bug at their side.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HristoKolev/TvDbSharper/issues/24#issuecomment-745441463, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALL6WHYDHBYHETLG53P4HYTSU6LYHANCNFSM4UZBTOVA .

HristoKolev commented 3 years ago

You can look at the swagger docs - https://api.thetvdb.com/swagger.

It says that if the call GET /series/{id}/actors returns 404 - that means that the show does not exist, not that the show doesn't have any actors. 404 | Returned if the given series ID does not exist.

A quick search showed that before they killed the forums, someone reported a similar issue: https://forums.thetvdb.com/viewtopic.php?f=17&t=65292 .

I won't report it. Nobody cares.

They don't want it reported, it's a waste of time. They don't want any public discussion to take place, this is been a problem for years and now the forum and the gitlab project are disabled.

HristoKolev commented 3 years ago

The best thing you can do is wrap it in a try-catch.

mpfc75 commented 3 years ago

Yes, I see what you are saying about tvdb. It's too bad.

For the record, you understand that the show does exist? I agree that GetActorsAsync says it doesn't but GetAsync works. var show = (await client.Series.GetAsync(seriesID)).Data; // Works var actors = (await client.Series.GetActorsAsync(seriesID)).Data; // Fails

I appreciate you looking into this for me.

On Tue, Dec 15, 2020 at 1:20 PM Hristo Kolev notifications@github.com wrote:

The best thing you can do is wrap it in a try-catch.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/HristoKolev/TvDbSharper/issues/24#issuecomment-745474241, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALL6WH4AZ4XHIFKVHPKTQU3SU6SG7ANCNFSM4UZBTOVA .

HristoKolev commented 3 years ago

I'm sorry, perhaps i didn't make myself clear.

I understand that you have a problem and that it doesn't make sense for GetActorsAsync to return 404 when GetAsync doesn't.

The problem is the API, not the library. A workaround is to wrap the call in try-catch and handle the case when it throws.

mpfc75 commented 3 years ago

Root cause is bug in tvdb.