Fix links to invalid genre channels

pull/319/head
Omar Roth 6 years ago
parent ba36ab9559
commit 1f6078cf25

@ -670,13 +670,20 @@ def fetch_video(id, proxies, region)
genre = html.xpath_node(%q(//meta[@itemprop="genre"])).try &.["content"] genre = html.xpath_node(%q(//meta[@itemprop="genre"])).try &.["content"]
genre ||= "" genre ||= ""
genre_url = html.xpath_node(%(//a[text()="#{genre}"])).try &.["href"] genre_url = html.xpath_node(%(//ul[contains(@class, "watch-info-tag-list")]/li/a[text()="#{genre}"])).try &.["href"]
# Sometimes YouTube tries to link to invalid/missing channels, so we fix that here
case genre case genre
when "Education"
genre_url = "/channel/UCdxpofrI-dO6oYfsqHDHphw"
when "Gaming"
genre_url = "/channel/UCOpNcN46UbXVtpKMrmU4Abg"
when "Movies" when "Movies"
genre_url = "/channel/UClgRkhTL3_hImCAmdLfDE4g" genre_url = "/channel/UClgRkhTL3_hImCAmdLfDE4g"
when "Education" when "Nonprofits & Activism"
# Education channel is linked but does not exist genre_url = "/channel/UCfFyYRYslvuhwMDnx6KjUvw"
genre_url = "/channel/UC3yA8nDwraeOfnYfBWun83g" when "Trailers"
genre_url = "/channel/UClgRkhTL3_hImCAmdLfDE4g"
end end
genre_url ||= "" genre_url ||= ""

Loading…
Cancel
Save