Giter Club home page Giter Club logo

anitube_crawler_api_example's Introduction

anitube_crawler_api

Build Status

Anitube website crawler API. This dart package is a simple library to fetch animes and episodes data from the brazilian Anitube website.
This package gets the website html pages, parse them and returns the data using a well formatted data model classes.

This package is part of the AnimeStore mobile app project.

Features

  • Fetch the most recent episode posts
  • Fetch the most recent anime posts
  • Fetch the most visualized animes
  • Fetch the daily releases
  • Fetch animes genres available
  • Fetch anime details with episode list
  • Fetch episodes details with video stream link

Usage

To use this plugin, add anitube_crawler_api as a dependency in your pubspec.yaml file. For example:

  dependencies:
    anitube_crawler_api: 0.2.6+2

The API

The main API is very simple. You just need to use the AniTubeApi class methods to get all the data that you want.

///you need include this file only.
import 'package:anitube_crawler_api/anitube_crawler_api.dart';
/// create a instance.
final AniTubeApi api = AniTubeApi();

Getting the Anitube homepage data

HomePageInfo homePage = await api.getHomePageData(timeout: localTimeout));
// HomePageInfo brings all information about the anitube website home page 
// using a well formated model.
// Checking the data that homePage brings to you.
print(homePage.dayReleases ); // Data type is List<AnimeItem>
print(homePage.latestEpisodes); // Data type is List<EpisodeItem>
print(homePage.mostRecentAnimes); // Data type is List<AnimeItem>
print(homePage.mostShowedAnimes); // Data type is List<AnimeItem>

Getting details about an "anime" like title, author, episodes reference list, genre and more...

  // getting the first anime released.
 AnimeItem anime = homePage.dayReleases[0];
 
 // use id property of AnimeItem instance.
 AnimeDetails details = await api.getAnimeDetails( anime.id,timeout: localTimeout);
 
 // check the anime details property
 print(details);

Getting episode details like the stream Url

  // details is an AnimeDetails instance.
  var episodeList = details.episodes; // getting List<EpisodeItem>
  // getting the first episode from the list
  var desiredEpisode = episodeList[ 0 ];
 
 // use id property of EpisodeItem instance.
 EpisodeDetails episode = await api.getEpisodeDetails( desiredEpisode.id,timeout: localTimeout);
 
 // printing episode title
 print(episode.title)
 // printing episode stream URL
 print(episode.streamUrl);
 // checking EpisodeDetails class properties
 print(episode);

Getting all genres available.

  List<String> genres = await api.getGenresAvailable();
  // print the list with all avaialble genre names.
  print(genres);

Getting all the animes in anitube website.

  // AnimeListPageInfo instance holds data about the current
  // anime list page included the anime item list and the current page
  // number and the max page number both are useful to do pagination.
  AnimeListPageInfo pageInfo = await api.getAnimeListPageData(
    // 1 is the default page number
    pageNumber = 1,
  );
  // prints the current page number
  print(pageInfo.pageNumber);
  
  // prints the last page number
  print(pageInfo.maxPageNumber);
  
  // prints the list with AnimeItem objects which comes with the current page.
  print(pageInfo.animes);

Animes Search

The search engine used is from the anitube website. Sometimes it returns undesired results but most cases it works well.

    // the search can be anything. A letter, a anime name, studio name etc.
    String query = "Shigeki no kyojin";
  
    AnimeListPageInfo searchPageInfo =  await api.search(
        query,
        pageNumber = 1, // the default page number is 1.
    );
  
    // prints the current search page number
    print(searchPageInfo.pageNumber);
  
    // prints the last page number
    print(searchPageInfo.maxPageNumber);
  
    // prints the list with AnimeItem objects which comes with the current search page.
    print(searchPageInfo.animes);
    
    //NOTE: sometimes a query can have more than 1 page, in this cases
    // if you want more results to the same query string value YOU MUST call search method again using the same query but a different pageNumber
    
    // getting the page 2 for the query string.
    AnimeListPageInfo searchPageInfo2 =  await api.search(
        query,
        pageNumber = 2,);

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.