Giter VIP home page Giter VIP logo

moviematch's Introduction

MovieMatch

I maintain IMDB watchlist and have repeatedly check yts if movies are available or not, which is mundane activity and time-consuming, yeah I am a bit lazy to do that. So creating this tiny library which automate that !!

Prerequisites

elixir v1.12.1

Installation

the package can be installed by adding moviematch to your list of dependencies in mix.exs:

def deps do
  [
    {:moviematch, "~> 0.1.0"}
  ]
end

Usage

  1. Get IMDB's watchlist movies of user having user_id as ur26610840.
iex(1)> MovieMatch.Imdb.fetch_imdb_watchlist("ur26610840")

results

%{
  "tt1034415" => "Suspiria",
  "tt1502407" => "Halloween",
  "tt3986820" => "The Endless",
  "tt4003440" => "The House That Jack Built",
  "tt4015500" => "The Tale",
  "tt4645368" => "Juste la fin du monde",
  "tt5116410" => "Tower",
  "tt5160938" => "Lizzie",
  "tt5516328" => "Ghost Stories",
  "tt5607096" => "Juliet, Naked",
  "tt5886440" => "Marrowbone",
  "tt5989218" => "Life Itself",
  "tt6053438" => "First Reformed",
  "tt6628394" => "Bad Times at the El Royale",
  "tt6823368" => "Glass",
  "tt6998518" => "Mandy",
  "tt7349950" => "It: Chapter Two",
  "tt8359848" => "Climax"
}
  1. Match movies with YTS
 iex(2)> MovieMatch.match_movies("ur26610840")

Movie information if movie found on YTS

%{
   id: "tt9601220",
   movie_info: [
     %{
       "background_image" => "https://yts.mx/assets/images/movies/black_bear_2020/background.jpg",
       "background_image_original" => "https://yts.mx/assets/images/movies/black_bear_2020/background.jpg",
       "date_uploaded" => "2020-12-04 12:16:44",
       "date_uploaded_unix" => 1607080604,
       "description_full" => "At a remote lake house in the Adirondack Mountains, a couple entertains an out-of-town guest looking for inspiration in her filmmaking. The group quickly falls into a calculated game of desire, manipulation, and jealousy, unaware of how dangerously convoluted their lives will soon become in the filmmaker's pursuit of a work of art, which blurs the boundaries between autobiography and invention. —kanaan-02150",
       "genres" => ["Action", "Comedy", "Drama"],
       "id" => 24473,
       "imdb_code" => "tt9601220",
       "language" => "en",
       "large_cover_image" => "https://yts.mx/assets/images/movies/black_bear_2020/large-cover.jpg",
       "medium_cover_image" => "https://yts.mx/assets/images/movies/black_bear_2020/medium-cover.jpg",
       "mpa_rating" => "R",
       "rating" => 6.6,
       "runtime" => 104,
       "slug" => "black-bear-2020",
       "small_cover_image" => "https://yts.mx/assets/images/movies/black_bear_2020/small-cover.jpg",
       "state" => "ok",
       "summary" => "At a remote lake house in the Adirondack Mountains, a couple entertains an out-of-town guest looking for inspiration in her filmmaking. The group quickly falls into a calculated game of desire, manipulation, and jealousy, unaware of how dangerously convoluted their lives will soon become in the filmmaker's pursuit of a work of art, which blurs the boundaries between autobiography and invention. —kanaan-02150",
       "synopsis" => "At a remote lake house in the Adirondack Mountains, a couple entertains an out-of-town guest looking for inspiration in her filmmaking. The group quickly falls into a calculated game of desire, manipulation, and jealousy, unaware of how dangerously convoluted their lives will soon become in the filmmaker's pursuit of a work of art, which blurs the boundaries between autobiography and invention. —kanaan-02150",
       "title" => "Black Bear",
       "title_english" => "Black Bear",
       "title_long" => "Black Bear (2020)",
       "torrents" => [
         %{
           "date_uploaded" => "2020-12-04 12:16:44",
           "date_uploaded_unix" => 1607080604,
           "hash" => "D28ADC2C9475FD41327BF15F25BFE423FB60E03F",
           "peers" => 3,
           "quality" => "720p",
           "seeds" => 16,
           "size" => "971.12 MB",
           "size_bytes" => 1018293125,
           "type" => "web",
           "url" => "https://yts.mx/torrent/download/D28ADC2C9475FD41327BF15F25BFE423FB60E03F"
         },
         %{
           "date_uploaded" => "2020-12-04 13:36:28",
           "date_uploaded_unix" => 1607085388,
           "hash" => "1491B008F45036F13B60800A4A928E8B65765957",
           "peers" => 3,
           "quality" => "1080p",
           "seeds" => 22,
           "size" => "1.95 GB",
           "size_bytes" => 2093796557,
           "type" => "web",
           "url" => "https://yts.mx/torrent/download/1491B008F45036F13B60800A4A928E8B65765957"
         }
       ],
       "url" => "https://yts.mx/movies/black-bear-2020",
       "year" => 2020,
       "yt_trailer_code" => "D7XVArQc7z8"
     }
   ],

Movie information if movie not found on YTS

%{id: "tt9639470", movie_info: nil, title: "Last Night in Soho"}

moviematch's People

Contributors

navyad avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

Forkers

yatender-oktalk

moviematch's Issues

Some review comments. Salt to taste.


  1. Prefer using case over cond for static matches. For instance
case movie_count do 
    1 -> true
    0 -> false
end

And if there are only two branches why not if?

  1. is_found <- is_movie?(json_response),

    This is not uselful in the with block because you are pattern matching everything. You can move this into the map in next line is_found: is_movie?(json_response)`

  2. @imdb_url AppConfig.imdb_url()

    Why declare a module constant if its only being used once?

  3. with {:ok, primary} = Map.fetch(v, "primary"),

    with blocks use <- iirc

  4. defp parse_html({:ok, response}) do

    This fn can do with some refactoring. One way to go about it could be to create a struct which has the requisite fields. That way you can sort of have some guarantees on the parsed API response.

  5. defp build_json(script_str) do

    Same as above

  6. Poison.decode!(body)

    As a general safety guideline prefer using the safe version of fns rather than the unsafe ones (fns which end with !). With safe fns you can pattern match on {:ok, response} or {:error, error}` but with the unsafe fns you would have to catch the exceptions if you don't want the process to die.

Redirect issue for HTTP get request

{:ok,
 %HTTPoison.Response{
   body: "",
   headers: [
     {"Date", "Tue, 22 Jun 2021 11:42:20 GMT"},
     {"Transfer-Encoding", "chunked"},
     {"Connection", "keep-alive"},
     {"Cache-Control", "max-age=3600"},
     {"Expires", "Tue, 22 Jun 2021 12:42:20 GMT"},
     {"Location",
      "https://yts.mx/api/v2/list_movies.json?query_term=tt11296058"},
     {"cf-request-id", "0ad5205cb800004da508b04000000001"},
     {"Expect-CT",
      "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""},
     {"Report-To",
      "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v2?s=O80%2B5KfZ6d3G3Fz0NBGlep%2BetzQAvaUDIvVW09DUB2QMtJpd1XxupK621LhGR8EqiOsOY%2B55BdaHAljyLCEumHyb0rHSqk526jMQ5NxuLUi%2FVdbX\"}],\"group\":\"cf-nel\",\"max_age\":604800}"},
     {"NEL", "{\"report_to\":\"cf-nel\",\"max_age\":604800}"},
     {"Server", "cloudflare"},
     {"CF-RAY", "663536745c654da5-BOM"},
     {"alt-svc",
      "h3-27=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-29=\":443\"; ma=86400, h3=\":443\"; ma=86400"}
   ],
   request: %HTTPoison.Request{
     body: "",
     headers: [],
     method: :get,
     options: [],
     params: %{},
     url: "https://yts.lt/api/v2/list_movies.json?query_term=tt11296058"
   },
   request_url: "https://yts.lt/api/v2/list_movies.json?query_term=tt11296058",
   status_code: 301
 }}

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.