Giter VIP home page Giter VIP logo

tmdb_api's Introduction

tmdb_api

Dart Code Analysis CI pub package style: lint

A TheMovieDatabase client library for dart. To know more about TMDB visit offical site

Getting started

  1. Adding as dependencies

    Pub.dev's installation guide

    Add this to your package's pubspec.yaml file:

    dependencies:
      tmdb_api: latest //visit tmdb for latest version number
  2. Import it

    Now in your Dart code, you can use:

    import 'package:tmdb_api/tmdb_api.dart';
  3. Create Instance

    Now you need to create instance for TMDB and ApiKeys with your api keys.

    final tmdbWithCustomLogs = TMDB( //TMDB instance
        ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),//ApiKeys instance with your keys,
      );
  4. Configuring console logs

    There are 3 logconfigs presets avaliable.

    • ConfigLogger.showAll(): development use.
    • ConfigLogger.showRecommended(): development use.
    • ConfigLogger.showNone(): production use.

    You can add any off this presets to logConfig named parameter of TMDB instance Custom Logs

    final tmdbWithCustomLogs = TMDB(
        ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
        logConfig: ConfigLogger(
          showLogs: true,//must be true than only all other logs will be shown
          showErrorLogs: true,
        ),
      );

Example

For getting Trending movies

Map result = await tmdb.v3.trending.getTrending(mediaType = MediaType.all,timeWindow = TimeWindow.day);

Custom Dio instance

    final tmdbWithCustomLogs = TMDB(
        ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
        dio:Dio()// your own dio instance
      );

Setting Default api data language

    final tmdbWithCustomLogs = TMDB(
        ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
        defaultLanguage:'en-US'// sets default language for all supported endpoints
      );

Adding Interceptors

final tmdbWithCustomLogs = TMDB(
    ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
    interceptors:Interceptors()..add(/*your interceptor*/)
    );

or

final customDio = Dio();
customDio.interceptors.add(/*your interceptor*/)

final tmdbWithCustomLogs = TMDB(
    ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
    dio:dio
    );

note:Use interceptors only when you are not using a custom Dio instance.

For more API documentation

visit offical API documentation

tmdb_api's People

Contributors

0franky avatar arley011 avatar gopal-dahale avatar gutala avatar is8r avatar johndunne avatar msviswanth avatar ratakondalaarun avatar shr1k4nt avatar srihariash999 avatar

Stargazers

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

Watchers

 avatar

tmdb_api's Issues

Image Url parsers

Adds utility methods for parsing image URLs for

  • Poster
  • Backdrop
  • Logo
  • Profile
  • Stills
  • Tests

Replace with mapping

This can be replaced with List.map

final postBody = <Map<String, dynamic>>[];
items.forEach((item) => postBody.add(item._toMap()));

final postBody = <Map<String, dynamic>>[];
items.forEach((item) => postBody.add(item._toMap()));

final postBody = <Map<String, dynamic>>[];
items.forEach((item) {
postBody.add(item._toMap());
});

Pub.dev passing static analysis

Description

Recent changes to dart package site introduced package static analysis
which affects the score of this package

image

Remove deprecated exceptions

  • NullValueException
    @Deprecated('Removed infavor of nullsafety. Will be removed in v2.1.0')
    class NullValueException extends TMDBException {
    @Deprecated('Removed infavor of nullsafety. Will be removed in v2.1.0')
    NullValueException(
    String message, {
    String? source,
    String help = 'try to pass a non null values',
    }) : super(message, source: source, help: help);
    @override
    String toString() {
    return 'NullValueException() thrown message:$message | at source:$source | help:$help';
    }
    }
  • InvalidDataException
    ///When constrains are not meet
    @Deprecated('Infavor of ArgumentException. Will be removed in v2.1.0')
    class InvalidDataException extends TMDBException {
    @Deprecated('Infavor of ArgumentException. Will be removed in v2.1.0')
    InvalidDataException(
    String message, {
    String? source,
    String help = 'Data is invalid',
    }) : super(message, source: source, help: help);
    @override
    String toString() {
    return 'InvalidDataException() thrown message:$message | at source:$source | help:$help';
    }
    }

Spelling errors

There are two clear spelling issues in the package, geners (which should be Genres) and pouplar (which should be Popular). There might be more as well. These small mistakes can make the package hard to work with and create a difficult interface. It should be relatively easy to fix these issues and I'd be happy to work on a PR for this if it's assigned.

i want to get trending movie but it failed

i get this error when i want to get trending movies of the week

I/flutter (10388): TMDB_API--LOG(๐Ÿ”ด) --ERROR-- Exception while making a request. Exception = {DioError [unknown]: null
I/flutter (10388): Error: SocketException: Failed host lookup: 'api.themoviedb.org' (OS Error: No address associated with hostname, errno = 7)

Refactor

  • abstractions for versions and categories
  • v3
  • v4

Request to Add 'Public' Option to 'CreateList' Function in TMDB API

"If you could add the 'public' option to the 'createList' section within the 'lists' section of the TMDB API to the 'createList' function, I would be very happy. Also, your written package is fantastic. Thank you very much for your efforts."

{"iso_639_1":"tr","iso_3166_1":"TR","name":"aaaaa","description":"bbbb","public":"1","show_comments":"1","sort_by":"original_order.asc"}

Use late instead of ?

Use late instead of ?

Movies? _movies;
Tv? _tv;
TvSeasons? _tvSeasons;
TvEpisodes? _tvEpisodes;
// TvEpisodeGroup _tvEpisodeGroup;
People? _people;
Credit? _credit;
Certification? _certification;
Changes? _changes;
Collections? _collections;
Find? _find;
Geners? _geners;
Genres? _genres;
Keywords? _keywords;
Companies? _companies;
Trending? _trending;
Search? _search;
Discover? _discover;
Networks? _networks;
Reviews? _reviews;
Auth? _auth;
Lists? _lists;
Account? _account;
GuestSession? _guestSession;

Add option to set global default language parameter

At the time when we call the "api", it can be a very nice feature if a parameter related to changing the language was added. So I can add options related to changing the language to my application's settings.

For example;

final String apikey = 'my api key';
final String readaccesstoken = 'my readaccesstoken';
final String languages = 'tr-TR';

TMDB tmdbWithCustomLogs = TMDB(
      ApiKeys(apikey, readaccesstoken, languages),
      logConfig: ConfigLogger(
        showLogs: true,
        showErrorLogs: true,
      ),
    );

I just tried to give an example to make it a little more clear what I'm saying. I would be very grateful if you take it into account. Have a nice work day.

account/addtowatchlist bug

Future addToWatchList(
String sessionId,
int accountId,
int mediaId,
MediaType mediaType, {
bool shouldAdd = true,
}) {
if (accountId < 1 || mediaId < 1) {
throw ArgumentError('accountId<1||mediaId<1 is true');
}
String type;
//
if (mediaType == MediaType.tv) {
type = 'tv';
} else {
type = 'movie';
}

return _v._query(
  '$_endPoint/$accountId/watchlist',
  method: HttpMethod.post,
  optionalQueries: ['session_id=$sessionId'],
  postBody: {
    'media_type': type,
    'media_id': '$mediaId',
    'watchlist': '$shouldAdd',
  },
);  bool shouldAdd = true,this is bool.  but 'watchlist': '$shouldAdd', this is string.

Deprecate

  • NullValueException
  • InvalidDataException infavor of ArgumentError
  • Remove TMDBSocketException

There is no getImages for tv in v3.

Is your feature request related to a problem? Please describe.
There is an endpoint in tmdb v3 for getImages under tv.

Describe the solution you'd like
There should be a getImages endpoint for tv as it is there for movie.

Describe alternatives you've considered
I made an http request to the said endpoint. But this should be in the library

Additional context
https://developers.themoviedb.org/3/tv/get-tv-images This is the endpoint in context.

Error when use auth.createSessionWithLogin

Hi !

When i want to use v3.auth.createSessionWithLogin i have this error :

E/flutter (25249): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, String>'
E/flutter (25249): #0 Auth.createSessionWithLogin (package:tmdb_api/versions/v3/category/authentication.dart:206:44)
E/flutter (25249):
E/flutter (25249): #1 TMDBApi.loginWithCredentials (package:tmdb_authentication/tmdb_api.dart:17:9)
E/flutter (25249):
E/flutter (25249): #2 _LoginScreenState.build. (package:tmdb_authentication/screens/Login.dart:77:21)
E/flutter (25249):
E/flutter (25249):

Here my code :

import 'package:tmdb_api/tmdb_api.dart';

class TMDBApi {
  final String apiKey = "myApiKey";
  final String apiReadAccessV4 =
      "myAccesV4";
  TMDB tmdb;

  var requestToken;

  TMDBApi() {
    tmdb = new TMDB(ApiKeys(apiKey, apiReadAccessV4));
  }

  loginWithCredentials() async {
    await tmdb.v3.auth.createSessionWithLogin("myUsername", "myPassword");
  }
}

I call loginWithCredentials on button click.

Do you have any idea please ?

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.