Git Product home page Git Product logo

henrikfroehling / trakt.net Goto Github PK

View Code? Open in Web Editor NEW
60.0 6.0 13.0 32.42 MB

A .NET wrapper library with which developers can build .NET applications that integrate with the Trakt.tv API and access its features and data.

Home Page: https://henrikfroehling.github.io/Trakt.NET/

License: MIT License

C# 95.93% Smalltalk 4.07%
trakt nuget rest api netframework windows-10 xamarin-android xamarin-ios asp-net-core net-core

trakt.net's Introduction

Hi, I'm Henrik ๐Ÿ‘‹

  • C#, C++ and Pascal / Delphi Developer
  • Iโ€™m currently working on Trakt.NET
  • I'm currently learning compiler architectures

๐Ÿ’ฌ Ask me about C++, C#, .NET and / or Delphi

Languages & Frameworks & Tools

GitHub Stats

GitHub stats GitHub Streak

Languages

trakt.net's People

Contributors

arnaudmaichac avatar dependabot[bot] avatar github-actions[bot] avatar henrikfroehling avatar jrpetersjr avatar mcs88 avatar skyfrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

trakt.net's Issues

TraktSyncRatingsPostBuilder ignores rating in ITraktEpisode

I have found a possible bug when using the TraktSyncRatingsPostBuilder.
If you set the rating property in the episode instance, it becomes null when performing the traktSyncRatingsPostBuilder.Build().
See example below.

` ITraktEpisode traktEpisode = new TraktEpisode();
ITraktEpisodeIds ids = new TraktEpisodeIds();
ids.Tvdb = Convert.ToUInt32(episodeItem.ProviderIds["Tvdb"]);
traktEpisode.Ids = ids;
traktEpisode.Rating = rating; //Bug, ratings value is correctly entered into the property

            TraktSyncRatingsPostBuilder traktSyncRatingsPostBuilder = new TraktSyncRatingsPostBuilder();
            traktSyncRatingsPostBuilder.AddEpisode(traktEpisode);
            var build = traktSyncRatingsPostBuilder.Build(); //The rating value is missing from the build object.

            var addRatingResponse = await GetTraktClient().Sync.AddRatingsAsync(build);``

Wrong type assignment for lists

I was implementing the TraktClient.Users.AddCustomListItemsAsync function as mentioned in the documentation. After debugging 3 hours at 2 in the morning, i finally downloaded the code to debug the lib also. Found out that your statement was wrong.

_listItemsPost.Movies = new List<TraktUserCustomListItemsPostMovie>();

_listItemsPost.Movies = new List<TraktUserCustomListItemsPostMovie>(); should actually be _listItemsPost.Movies = new List<ITraktUserCustomListItemsPostMovie>();

That is why the cast here doesnt work

(_listItemsPost.Movies as List<ITraktUserCustomListItemsPostMovie>)?.Add(
and no items get added to the list.

You already did this for the People list

TraktApiSharp: 1.0.0-alpha3

Bad Request when adding items to a list

Although I fixed #61 temporary for myself, the request fails with the following error:

TraktNet.Exceptions.TraktBadRequestException
Bad Request - request couldn't be parsed

TraktNet.Exceptions.TraktBadRequestException: Bad Request - request couldn't be parsed
   at TraktNet.Requests.Handler.ResponseErrorHandler.HandleBadRequestError(ResponseErrorParameters errorParameters) in D:\Sourcecode\Github\Trakt.NET\Source\Lib\Trakt.NET\Requests\Handler\ResponseErrorHandler.cs:line 304
   at TraktNet.Requests.Handler.ResponseErrorHandler.HandleErrorsAsync(ResponseErrorParameters errorParameters, CancellationToken cancellationToken) in D:\Sourcecode\Github\Trakt.NET\Source\Lib\Trakt.NET\Requests\Handler\ResponseErrorHandler.cs:line 64
   at TraktNet.Requests.Handler.ResponseErrorHandler.HandleErrorsAsync(ExtendedHttpRequestMessage requestMessage, HttpResponseMessage responseMessage, Boolean isCheckinRequest, Boolean isDeviceRequest, Boolean isInAuthorizationPolling, Boolean isAuthorizationRequest, Boolean isAuthorizationRevoke, CancellationToken cancellationToken) in D:\Sourcecode\Github\Trakt.NET\Source\Lib\Trakt.NET\Requests\Handler\ResponseErrorHandler.cs:line 50
   at TraktNet.Requests.Handler.RequestHandler.ExecuteRequestAsync(ExtendedHttpRequestMessage requestMessage, Boolean isCheckinRequest, CancellationToken cancellationToken) in D:\Sourcecode\Github\Trakt.NET\Source\Lib\Trakt.NET\Requests\Handler\RequestHandler.cs:line 277
   at TraktNet.Requests.Handler.RequestHandler.QuerySingleItemAsync[TResponseContentType](ExtendedHttpRequestMessage requestMessage, Boolean isCheckinRequest, CancellationToken cancellationToken) in D:\Sourcecode\Github\Trakt.NET\Source\Lib\Trakt.NET\Requests\Handler\RequestHandler.cs:line 157
   at TraktNet.Requests.Handler.RequestHandler.ExecuteSingleItemRequestAsync[TResponseContentType,TRequestBodyType](IPostRequest`2 request, CancellationToken cancellationToken) in D:\Sourcecode\Github\Trakt.NET\Source\Lib\Trakt.NET\Requests\Handler\RequestHandler.cs:line 78
   at Listrr.Repositories.TraktListAPIRepository.AddMovies(IEnumerable`1 movies, TraktList list) in D:\Sourcecode\PrivateFlix.Club\Listrr\Listrr\Repositories\TraktListAPIRepository.cs:line 196
   at Listrr.Services.TraktService.AddMovies(IEnumerable`1 movies, TraktList list) in D:\Sourcecode\PrivateFlix.Club\Listrr\Listrr\Services\TraktService.cs:line 26
   at Listrr.Jobs.BackgroundJobs.ProcessListBackgroundJob.Execute(UInt32 param) in D:\Sourcecode\PrivateFlix.Club\Listrr\Listrr\Jobs\BackgroundJobs\ProcessListBackgroundJob.cs:line 28

I copied the JSON that is sent to the API, and sent it with postman myself. The request got an 201 Created response.

API Search by text query doesn't allow NullOrEmpty string

As the title above,
Library API "Search by text query" doesn't allow a null value or empty string in searchQuery parameter;
but Trakt API allow it, and is useful, for example, to search by genre only.

Can you implement this "feature" ?

Thank You so much for all.

Refreshing authorization not working with expired or invalid access token

It is not possible to refresh the authorization, if the client is "restarted".
old implementation:
https://github.com/henrikfroehling/TraktApiSharp/blob/master/Source/Lib/TraktApiSharp/Authentication/TraktAuthentication.cs#L376
new implementation:

In the new version there is only a check, if the authentication is authorized. During a refresh the authentication is always not authorized, therefore it is not possible to do a refresh. Please bring back the old check :)

Trakt.tv API Images removed on October 31, 2016

More information here

The Images-option in TraktExtendedInfo will still be available, but without any effect on media object responses. Therefore, the Images property in TraktShow, TraktMovie and other objects will always be null.
User images (TraktUser.Images) are not affected by this change.

All changes are documented in the Changelog.

For further discussion on the Trakt.tv API visit the Trakt.tv API forum (Google+ account required).

Few TVDbId doesn't recognized?

Just noticed that some show (by TVDBId) just won't added to my watch history. (The Show goes into ITraktSyncHistoryPostResponse.NotFound)
E.g.:
https://trakt.tv/shows/wynonna-earp tvdbid: 305582 https://www.thetvdb.com/series/wynonna-earp
It works fine if I provide the traktv id. Sadly even if I pass the IMDBId, GetBestId() returns the TVDBId.
Also I'm not sure if this is the library fault, but if the TVDBId is so unreliable then 'GetBestId' could be changed to prefer imdbid over tvdbid?

Version 1.0.0 ToDo

Original Issue: henrikfroehling/TraktApiSharp#16

ToDo

Version 1.0.0 Alpha 1

  • old/#17 New and better request implementation
  • old/#44 New and better response implementation
  • old/#34 Convert PCL to .NET Standard

Version 1.0.0 Alpha 2

  • old/#18 Reduce indirections in object properties
  • old/#20 Optimize deserialization of json data
  • old/#43 Remove Images option in TraktExtendedInfo
  • old/#59 System.NullReferenceException When getting popular shows

Version 1.0.0 Alpha 3

  • old/#21 Improve http client handling
  • old/#69 Add support for "networks" GET request (for version 1.0.0)
  • old/#70 Add support for "certifications/{type}" GET request (for version 1.0.0)
  • old/#71 Add support for "users/hidden/{section}" POST request (for version 1.0.0)
  • old/#72 Add support for "users/hidden/{section}/remove" POST request (for version 1.0.0)
  • old/#75 Optimize serialization of json data
  • old/#77 Fix serialization of objects in post builder
  • old/#78 Implement json deserialization for authorization objects
  • old/#79 Remove prefix Trakt from internal type names
  • old/#83 Add missing "network" property in ITraktSeason
  • old/#87 Move tests from old test project into new test project
  • old/#88 Add missing "last_episode" property in ITraktShowProgress
  • old/#89 Add "dolby_atmos" and "dts_x" in TraktMediaAudio
  • old/#103 Fix module tests
  • old/#106 Add support for X-Item-ID and X-Item-Type response headers
  • old/#107 Add support for "comments/{id}/item" GET request
  • old/#108 Add support for "comments/recent/{comment_type}/{type}" GET request
  • old/#109 Add support for "comments/{id}/likes" GET request
  • old/#110 Add missing "country" property in ITraktMovie
  • old/#111 Add "comment_count" property in ITraktMovie, ITraktShow, ITraktSeason and ITraktEpisode
  • old/#116 Add support for "people/{id}/lists/{type}/{sort}" GET request
  • old/#117 Add support for "comments/trending/{comment_type}/{type}?{include_replies}" GET request
  • old/#118 Add support for "comments/recent/{comment_type}/{type}?{include_replies}" GET request
  • old/#119 Add support for "comments/updates/{comment_type}/{type}?{include_replies}" GET request
  • old/#120 Add support for "lists/trending" GET request
  • old/#121 Add support for "lists/popular" GET request
  • old/#122 Add support for "include_replies" parameter in "users/id/comments" GET request
  • old/#123 Make "sort_how" and "sort_by" optional in "users/{id}/lists" and "users/{id}/lists/{list_id}" requests
  • old/#124 Allow multiple types as filter in "users/{id}/lists/{list_id}/items/{type}" request
  • old/#129 Add "reset_at" property in ITraktShowWatchedProgress
  • old/#130 Add flag for "progress_watched_reset" section in TraktHiddenItemsSection

Version 1.0.0 Beta 1

  • old/#57 Move all examples into their own repository
  • #3 Rename library / project / repository to "Trakt.NET"
  • #23 Fix serialization service
  • #27 Add missing "token" property in ITraktAccountSettings
  • #30 post builder feature: add support for posting collected episodes without ids
  • #33 Implement missing json object and array reader
  • #34 Implement missing json object and array writer
  • #35 Fix post builder for sync collection post
  • #36 Refreshing authorization not working with expired or invalid access token
  • #37 Revoking authorization not working with expired or invalid access token
  • #49 Epic: Improve test coverage - Part 1
  • #61 Wrong type assignment for lists
  • #62 Bad Request when adding items to a list
  • #64 Exception when search text query is empty
  • #65 Invalid implementation for Networks / List / Get networks
  • #72 Add missing filter support for text query search
  • #94 Redundant checks for ITraktMovie properties in TraktScrobbleModule

Version 1.0.0

  • #28 Update source code documentation
  • #107 Split up test project in multiple test projects (release)
  • #117 Split up TraktNET.Objects.Tests in multiple test projects (release)
  • #121 Improve / replace UriTemplate implementation (release)
  • #125 Add support for new people methods

Rename Visual Studio project

  • #10 Replace all occurrences of "TraktApiSharp" with "Trakt.NET" in Visual Studio project files (.csproj) / Rename project files
  • #11 Replace all occurrences of "TraktApiSharp" with "Trakt.NET" in Visual Studio solution files (.sln) / Rename solution files
  • #12 Replace all occurrences of "TraktApiSharp" with "Trakt.NET" in appveyor.yml
  • #13 Create new NuGet package with the name "Trakt.NET"

Investigation: Context-based usage approach

TODO

Create a context that holds all values needed in the library and which is configurable.

ITraktContext context = new TraktContext
{
    ClientId = "myClientId",
    ClientSecret = "myClientSecret",
    Authorization = TraktAuthorization.CreateWith("myAccessToken", "myRefreshToken"),
    ApiVersion = 2, // optional, because default
    ForceAuthorization = true, // optional
    UseSandboxEnvironment = true // optional
};

TraktContext is the default implementation for ITraktContext and inherits from TraktContextBase, that implements ITraktContext

public abstract class TraktContextBase : ITraktContext
{
    // ...
}

public class TraktContext : TraktContextBase
{
    // ...
}

Define custom contexts.

public class DebugContext : TraktContextBase
{
   // ...
}

public class ProductionContext : TraktContextBase
{
   // ...
}

// or
public class DebugContext : TraktContext
{
   // ...
}

public class ProductionContext : TraktContext
{
   // ...
}

Each ITraktContext instance has a unique id and therefore can be saved in a dictionary easily.
Some sort of context registry would also be possible.

string uniqueId = context.UniqueContextId;

Modules accept ITraktContext as input, which would allow dependency injection.

public sealed class TraktMoviesModule
{
    public TraktMoviesModule(ITraktContext context) { // ... }

    public async Task<TraktMovie> GetMovieAsync(string movieId) { // ... }

    public static async Task<TraktMovie> GetMovieAsync(ITraktContext context, string movieId) { // ... }
}

Extension methods for TraktContextBase

public static class TraktContextBaseExtensions
{
    public static TraktMoviesModule GetMoviesModule(this TraktContextBase context) { // ... }

    public static async Task<TraktMovie> GetMovieAsync(this TraktContextBase context, string movieId) { // ... }
}

Usage:

TraktMoviesModule moviesModule = new TraktMoviesModule(context);
TraktMovie movie = await moviesModule.GetMovieAsync("movie-id");

// or
TraktMovie movie = await TraktMoviesModule.GetMovieAsync(context, "movie-id");

// or, with extension methods for TraktContextBase
TraktMovie movie = await context.GetMovieAsync("movie-id");

Example implementation

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.