Skip to content
/ filmdb Public

Filmdb - API and CLI for film ratings (experiment)

License

Notifications You must be signed in to change notification settings

kowal/filmdb

Repository files navigation

FilmDB

Build Status

Codacy Badge Coverage Status Code Climate Codeship Status for kowal/filmdb

This project is work in progress..

What is this?

Simple tool for fetching movies stats. Provides CLI app and API to be used in other applications.

The idea is to provide tool which can:

  • Fetch movie titles from various Sources
  • For each title, fetch ratings from multple Services and calculate averages

CLI

Run movies-report -h to see available commands.

Usage: movies-report [OPTIONS]
    -u, --url URL                    URL with movies to check
    -k, --keep KEEP_CONNECTION       Keep connection until all job are finished
    -j, --job JOB_ID                 Read Status of job

Examples

Run in background

$ movies-report -u 'http://chomikuj.pl/Lektor.pl'
# [FilmDB] Fetching page ..
# [FilmDB] Building report (background). ..
# [FilmDB] Scheduled job => 109

Check job status using --job flag:

$ movies-report -j 109
# [FilmDB] Results: (45/60)
# +----------------------------+---------+------+
# | Title                      | Filmweb | Imdb |
# +----------------------------+---------+------+
# | Last Minute                |    -    | 4.3  |
# | Dont Cry                   |    -    |  -   |
# | Jednostka - Entity         |    -    | 6.0  |
# | ...                        |    -    |  -   |

To keep alive application process until all results are fetched, use --keep flag. Current progres will be visualized (sparks represents ratings for each film).

$ movies-report -k true -u 'http://chomikuj.pl/Lektor.pl'
# [FilmDB] Fetching page ..
# [FilmDB] Building report (background). Please wait..
# [FilmDB] Fetching stats [59/60] ▁▆▅▁▆▁▁▁▁▁▇▁▇▁▁▁▇▁▁▆▅▆▇▄▁▁▇▆▇▇▆ 98%
#
# +----------------------------+---------+------+
# | Title                      | Filmweb | Imdb |
# +----------------------------+---------+------+
# | Bezpieczna Przystań        |   7.4   |  -   |
# | Last Minute                |   5.2   | 4.3  |
# | ...

API / Design

Core Classes

FilmDB          # Main namespace, allows managing Sources, Services and Strategies
FilmDB::Query   # Identifies film from given Source, fetches stats from Services
FilmDB::Source  # Extracts movies list from a web page
FilmDB::Service # Film information back-end, provides ratings, etc.

FilmDB::Strategy # Abstract strategy, defines i-face for running FilmDB::Query
::Simple         # Basic strategy, which queries movies one by one
::Async          # Fetching info about movies is done in background

# FilmDB
FilmDB.register_source 'http://chomikuj.pl',        Source::Chomikuj
FilmDB.register_source 'http://trailers.apple.com', Source::AppleTrailers

FilmDB.register_service :filmweb,  FilmDB::Service::Filmweb
FilmDB.register_service :imdb,     FilmDB::Service::IMDB
FilmDB.register_service :allmovie, FilmDB::Service::AllMovie

FilmDB.register_strategy :default,    FilmDB::Strategy::Simple
FilmDB.register_strategy :background, FilmDB::Strategy::Background

# FilmDB::Query
query = FilmDB::Query.new url: "http://chomikuj.pl/user/folder"
query.source_engine         # => FilmDB::Source::Chomikuj
query.build!                # => [time consuming ...]
query.build!(:background)   # => [much faster ..]
query.results               # => [specific to chosen strategy]

About

Filmdb - API and CLI for film ratings (experiment)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published