summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2019-03-17 18:31:11 -0500
committerOmar Roth <omarroth@hotmail.com>2019-03-17 18:31:11 -0500
commit2ebc773863b13091d12439b24bb73ce1a012f11c (patch)
tree71818b0747a1b5b9fcc2c2bffc6d00c6d5114536
parent44f4057876e2dab0b04529d10456aa8e880c346b (diff)
downloadinvidious-2ebc773863b13091d12439b24bb73ce1a012f11c.tar.gz
invidious-2ebc773863b13091d12439b24bb73ce1a012f11c.tar.bz2
invidious-2ebc773863b13091d12439b24bb73ce1a012f11c.zip
Add mixes to genre channels
-rw-r--r--src/invidious.cr9
-rw-r--r--src/invidious/helpers/helpers.cr8
2 files changed, 15 insertions, 2 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 375bb538..0a2174ce 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -2471,7 +2471,14 @@ get "/channel/:ucid" do |env|
sort_by ||= "last"
items, continuation = fetch_channel_playlists(ucid, author, auto_generated, continuation, sort_by)
- items.select! { |item| item.is_a?(SearchPlaylist) && !item.videos.empty? }
+ items.uniq! do |item|
+ if item.responds_to?(:title)
+ item.title
+ elsif item.responds_to?(:author)
+ item.author
+ end
+ end
+ items.select! { |item| item.responds_to?(:thumbnail_id) && item.thumbnail_id }
items = items.map { |item| item.as(SearchPlaylist) }
items.each { |item| item.author = "" }
else
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index 1ed33d9e..271aa0c4 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -416,12 +416,18 @@ def extract_shelf_items(nodeset, ucid = nil, author_name = nil)
thumbnail_id = playlist_thumbnail.match(/\/vi\/(?<video_id>[a-zA-Z0-9_-]{11})\/\w+\.jpg/).try &.["video_id"]
end
+ video_count_label = child_node.xpath_node(%q(.//span[@class="formatted-video-count-label"]))
+ if video_count_label
+ video_count = video_count_label.content.strip.match(/^\d+/).try &.[0].to_i?
+ end
+ video_count ||= 50
+
items << SearchPlaylist.new(
playlist_title,
plid,
author_name,
ucid,
- 50,
+ video_count,
Array(SearchPlaylistVideo).new,
thumbnail_id
)