|
|
@ -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
|
|
|
|
|
|
|
|
view_count = metadata[0].content.split(" ")[0].delete(",").to_i64
|
|
|
|
|
|
|
|
published = Time.now
|
|
|
|
|
|
|
|
else
|
|
|
|
# Skip movies
|
|
|
|
# Skip movies
|
|
|
|
if metadata[0]["class"].includes? "ytd-movie-renderer"
|
|
|
|
if metadata[0].content.includes? "·"
|
|
|
|
next
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
view_count = metadata[0].content.split(" ")[0].delete(",").to_i64
|
|
|
|
|
|
|
|
published = Time.now
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
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]
|
|
|
|