Fix method for detecting movies in search results

This commit is contained in:
Omar Roth 2018-08-05 18:07:52 -05:00
parent 0f8e01f919
commit 9d6cdc3032

View File

@ -14,7 +14,7 @@ end
def search(query, page = 1, search_params = build_search_params(content_type: "video")) def search(query, page = 1, search_params = build_search_params(content_type: "video"))
client = make_client(YT_URL) client = make_client(YT_URL)
html = client.get("/results?q=#{URI.escape(query)}&page=#{page}&sp=#{search_params}").body html = client.get("/results?q=#{URI.escape(query)}&page=#{page}&sp=#{search_params}&disable_polymer=1").body
if html.empty? if html.empty?
return [] of SearchVideo return [] of SearchVideo
end end
@ -47,14 +47,14 @@ def search(query, page = 1, search_params = build_search_params(content_type: "v
if metadata.size == 0 if metadata.size == 0
next next
elsif metadata.size == 1 elsif metadata.size == 1
# Skip movies
if metadata[0]["class"].includes? "ytd-movie-renderer"
next
end
view_count = metadata[0].content.split(" ")[0].delete(",").to_i64 view_count = metadata[0].content.split(" ")[0].delete(",").to_i64
published = Time.now published = Time.now
else else
# Skip movies
if metadata[0].content.includes? "·"
next
end
published = decode_date(metadata[0].content) published = decode_date(metadata[0].content)
view_count = metadata[1].content.split(" ")[0] view_count = metadata[1].content.split(" ")[0]