Pull description into seperate function

This commit is contained in:
Omar Roth 2018-08-10 08:44:23 -05:00
parent 09d4d46fcd
commit 9a78b55c53
4 changed files with 12 additions and 38 deletions

View file

@ -164,7 +164,7 @@ def extract_channel_videos(document, author, ucid)
end
description_html = node.xpath_node(%q(.//div[contains(@class, "yt-lockup-description")]))
description = description_html_to_description(description_html)
description, description_html = html_to_description(description_html)
length_seconds = node.xpath_node(%q(.//span[@class="video-time"]))
if length_seconds

View file

@ -273,7 +273,7 @@ def generate_captcha(key)
return {challenge: challenge, token: token}
end
def description_html_to_description(description_html)
def html_to_description(description_html)
if !description_html
description = ""
description_html = ""
@ -284,5 +284,5 @@ def description_html_to_description(description_html)
description = XML.parse_html(description).content.strip("\n ")
end
return description
return description, description_html
end

View file

@ -81,15 +81,7 @@ def search(query, page = 1, search_params = build_search_params(content_type: "v
end
description_html = node.xpath_node(%q(.//div[contains(@class, "yt-lockup-description")]))
if !description_html
description = ""
description_html = ""
else
description_html = description_html.to_s
description = description_html.gsub("<br>", "\n")
description = description.gsub("<br/>", "\n")
description = XML.parse_html(description).content.strip("\n ")
end
description, description_html = html_to_description(description_html)
length_seconds = node.xpath_node(%q(.//span[@class="video-time"]))
if length_seconds