defmodule Extube do @moduledoc """ Extube is a wrapper for the hubtraffic API. It gathers data from multiple tube sites including - [x] Pornhub - [x] Redtube - [ ] Tube8 - [ ] Youporn - [x] Xtube - [ ] Spankwire - [ ] Keezmovies - [ ] Extremetube. """ def handle_hubtraffic_call(base_url, params) do url = base_url <> URI.encode_query(params) IO.puts(url) {:ok, data} = HTTPoison.get(url) data_map = Poison.decode!(data.body) case hubtraffic_error_code(data_map["code"]) do :error -> {:error, data_map["message"]} :success -> {:success, data_map} end end def hubtraffic_error_code(code) do error_codes = [ "1001", "1002", "1003", "2001", "2002", "3001", "3002", "3003", ] case (code in error_codes) do true -> :error false -> :success end end end