defmodule Extube.Xtube do @moduledoc """ Xtube API Wrapper. For more information on the hubtraffic Xtube API, see here """ @doc """ Queries the hubtraffic API to search for videos given a map of parameters. Parameters right now include the following: `:category` comma seperated, only categories from provided list, 10 different categories max `:search` Text (Optional) - text is space separated `:ordering` (Optional) - possible values are latest/mostviewed/rating `:period` (Optional) - only work with ordering parameter. Possible values are lastweek/lastmonth/alltime `:tags` String (Optional) - comma seperated, only tags from provided list, 50 different tags max `:user` String (Optional) - comma seperated, 20 different user max """ def search_videos(params \\ %{}) do base_url = "https://www.pornhub.com/webmasters/search?" Extube.handle_hubtraffic_call(base_url, params) end @doc """ Retrieves additional information about specific video by id parameter. ## Parameters: `id` (Required) Integer """ def get_video_by_id(video_id) do base = "https://www.xtube.com/webmaster/api.php?action=getVideoById&" Extube.handle_hubtraffic_call(base, %{ id: video_id, }) end @doc """ Retrieves embed code for specific video by video_id parameter, which is useful to automatically embed videos. ## Parameters: `id` (Required) Integer """ def get_video_embed_code(video_id) do base = "https://www.xtube.com/webmaster/api.php?action=getVideoEmbedCode&" Extube.handle_hubtraffic_call(base, %{ id: video_id }) end @doc """ Retrieves all videos which are deleted during the last 2 weeks """ def get_deleted_videos do base = "https://www.xtube.com/webmaster/api.php?action=getDeletedVideos" Extube.handle_hubtraffic_call(base, %{}) end @doc """ Retrieves state of a specific video specified by is_video_active parameter, which is useful in order to keep your embedded videos up to date. ## Parameters: `id` (Required) Integer """ def is_video_active(video_id) do base = "https://www.xtube.com/webmaster/api.php?action=isVideoActive&" Extube.handle_hubtraffic_call(base, %{ id: video_id }) end @doc """ Retrieves all available categories. """ def get_categories_list do Extube.handle_hubtraffic_call("http://www.xtube.com/webmaster/api.php?action=getCategoryList", %{}) end @doc """ Retrieves all tags available. """ def get_tags_list do base = "http://www.xtube.com/webmaster/api.php?action=getTagList" Extube.handle_hubtraffic_call(base, %{}) end @doc """ Retrieves all amateurs available. """ def get_amateur_list do Extube.handle_hubtraffic_call("http://www.xtube.com/webmaster/api.php?action=getAmateurList", %{}) end @doc """ Retrieves all amateurs available with details (page url and amateurs's thumb). """ def get_amateur_list_detailed do Extube.handle_hubtraffic_call("http://www.xtube.com/webmaster/api.php?action=getAmateurListDetailed", %{}) end end