GithubHelp home page GithubHelp logo

Comments (9)

itsoli91 avatar itsoli91 commented on June 12, 2024

same here!

from tmdblib.

LordMike avatar LordMike commented on June 12, 2024

Is this on .NET core or Framework?

GetTrendingMoviesAsync(Day) works fine in .NET Core.

from tmdblib.

jason2li avatar jason2li commented on June 12, 2024

.NET6

from tmdblib.

LordMike avatar LordMike commented on June 12, 2024

This is TestApplication built for net5.0, with SDK 7.x, run like:

            var p1 = await client.GetTrendingMoviesAsync(TimeWindow.Day);

            Console.WriteLine(p1.Page);
            foreach (var searchMovie in p1.Results)
                Console.WriteLine(searchMovie.Id + " " + searchMovie.Title);

Output:
image

from tmdblib.

itsoli91 avatar itsoli91 commented on June 12, 2024

TimeWindow.Day adds a "Day" to the end of calling url, I cloned the project and convert it to lowercase (day), now it's working fine. I'm using .NET 7

from tmdblib.

itsoli91 avatar itsoli91 commented on June 12, 2024

It is also a good practice to keep everything lowercase while they are in a URL.

from tmdblib.

LordMike avatar LordMike commented on June 12, 2024

Sure - and it is. In this library, all enum values follow C#'s Camel Case standard, so it's Day. I have then annotated all enums with [EnumValue()] with the value to use in some cases, which for Day is day. This is used in the Client, whenever it calls .GetDescription() on the enum value.

I'm not sure why you're getting Day. I asked about the .NET version because maybe the custom attributes behavior is different for .NET Framework. Another alternative is a minimal .NET that does not have reflection capabilities. EnumValue is defined within TMDbLib, so that should rule out any mixing of library versions.

If EnumValue truly does not work, you would also not be able to:

  • Use any of the Account methods
  • Call the Discover* API's and apply a sorting
  • Call the GetMovie* methods, with any extraMethods set.

The code for GetDescription does end up with a .ToString(), so if it wasn't possible to find the custom attribute, you would see Day.

from tmdblib.

itsoli91 avatar itsoli91 commented on June 12, 2024

Thank you for explanation.
Is there any specific reason that you are not using [Description("")]
This is works for me!

using System.ComponentModel;

Console.WriteLine(TimeWindow.Day);
Console.WriteLine(GetEnumDescription(TimeWindow.Day));

static string GetEnumDescription(Enum value)
{
    // Get the Description attribute value for the enum value
    var fi = value.GetType().GetField(value.ToString());
    if (fi == null)
        return value.ToString();

    var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);

    return attributes.Length > 0 ? attributes[0].Description : value.ToString();
}

public enum TimeWindow
{
    [Description("day")] Day,
    [Description("week")] Week
}

Output:

Day
day
(process 21480) exited with code 0.
Press any key to close this window . . .

from tmdblib.

benjimola avatar benjimola commented on June 12, 2024

TMDbLib.Objects.Trending.Tim

thanks for fixing the bug...

from tmdblib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.