mirror of
https://github.com/iv-org/invidious.git
synced 2024-08-19 18:43:22 +02:00
Add support for anonymous playlists
This commit is contained in:
parent
6fb44083ec
commit
22b9bbe702
@ -190,22 +190,26 @@ def fetch_playlist(plid, locale)
|
|||||||
description_html ||= document.xpath_node(%q(//span[@class="pl-header-description-text"]))
|
description_html ||= document.xpath_node(%q(//span[@class="pl-header-description-text"]))
|
||||||
description_html, description = html_to_content(description_html)
|
description_html, description = html_to_content(description_html)
|
||||||
|
|
||||||
anchor = document.xpath_node(%q(//ul[@class="pl-header-details"])).not_nil!
|
# YouTube allows anonymous playlists, so most of this can be empty or optional
|
||||||
author = anchor.xpath_node(%q(.//li[1]/a)).not_nil!.content
|
anchor = document.xpath_node(%q(//ul[@class="pl-header-details"]))
|
||||||
|
author = anchor.try &.xpath_node(%q(.//li[1]/a)).try &.content
|
||||||
|
author ||= ""
|
||||||
author_thumbnail = document.xpath_node(%q(//img[@class="channel-header-profile-image"])).try &.["src"]
|
author_thumbnail = document.xpath_node(%q(//img[@class="channel-header-profile-image"])).try &.["src"]
|
||||||
author_thumbnail ||= ""
|
author_thumbnail ||= ""
|
||||||
ucid = anchor.xpath_node(%q(.//li[1]/a)).not_nil!["href"].split("/")[-1]
|
ucid = anchor.try &.xpath_node(%q(.//li[1]/a)).try &.["href"].split("/")[-1]
|
||||||
|
ucid ||= ""
|
||||||
|
|
||||||
video_count = anchor.xpath_node(%q(.//li[2])).not_nil!.content.gsub(/\D/, "").to_i
|
video_count = anchor.try &.xpath_node(%q(.//li[2])).try &.content.gsub(/\D/, "").to_i?
|
||||||
views = anchor.xpath_node(%q(.//li[3])).not_nil!.content.delete("No views, ")
|
video_count ||= 0
|
||||||
if views.empty?
|
views = anchor.try &.xpath_node(%q(.//li[3])).try &.content.delete("No views, ").to_i64?
|
||||||
views = 0_i64
|
views ||= 0_i64
|
||||||
else
|
|
||||||
views = views.to_i64
|
|
||||||
end
|
|
||||||
|
|
||||||
updated = anchor.xpath_node(%q(.//li[4])).not_nil!.content.lchop("Last updated on ").lchop("Updated ")
|
updated = anchor.try &.xpath_node(%q(.//li[4])).try &.content.lchop("Last updated on ").lchop("Updated ")
|
||||||
|
if updated
|
||||||
updated = decode_date(updated)
|
updated = decode_date(updated)
|
||||||
|
else
|
||||||
|
updated = Time.now
|
||||||
|
end
|
||||||
|
|
||||||
playlist = Playlist.new(
|
playlist = Playlist.new(
|
||||||
title: title,
|
title: title,
|
||||||
|
Loading…
Reference in New Issue
Block a user