mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Move 'extract_videos' and 'extract_selected_tab' too
This commit is contained in:
parent
8805ee7c8c
commit
e17c8b1f4d
2 changed files with 19 additions and 19 deletions
|
@ -251,25 +251,6 @@ def html_to_content(description_html : String)
|
||||||
return description
|
return description
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_videos(initial_data : Hash(String, JSON::Any), author_fallback : String? = nil, author_id_fallback : String? = nil)
|
|
||||||
extracted = extract_items(initial_data, author_fallback, author_id_fallback)
|
|
||||||
|
|
||||||
target = [] of SearchItem
|
|
||||||
extracted.each do |i|
|
|
||||||
if i.is_a?(Category)
|
|
||||||
i.contents.each { |cate_i| target << cate_i if !cate_i.is_a? Video }
|
|
||||||
else
|
|
||||||
target << i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return target.select(&.is_a?(SearchVideo)).map(&.as(SearchVideo))
|
|
||||||
end
|
|
||||||
|
|
||||||
def extract_selected_tab(tabs)
|
|
||||||
# Extract the selected tab from the array of tabs Youtube returns
|
|
||||||
return selected_target = tabs.as_a.select(&.["tabRenderer"]?.try &.["selected"].as_bool)[0]["tabRenderer"]
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_enum(db, enum_name, struct_type = nil)
|
def check_enum(db, enum_name, struct_type = nil)
|
||||||
return # TODO
|
return # TODO
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
def extract_videos(initial_data : Hash(String, JSON::Any), author_fallback : String? = nil, author_id_fallback : String? = nil)
|
||||||
|
extracted = extract_items(initial_data, author_fallback, author_id_fallback)
|
||||||
|
|
||||||
|
target = [] of SearchItem
|
||||||
|
extracted.each do |i|
|
||||||
|
if i.is_a?(Category)
|
||||||
|
i.contents.each { |cate_i| target << cate_i if !cate_i.is_a? Video }
|
||||||
|
else
|
||||||
|
target << i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return target.select(&.is_a?(SearchVideo)).map(&.as(SearchVideo))
|
||||||
|
end
|
||||||
|
|
||||||
|
def extract_selected_tab(tabs)
|
||||||
|
# Extract the selected tab from the array of tabs Youtube returns
|
||||||
|
return selected_target = tabs.as_a.select(&.["tabRenderer"]?.try &.["selected"].as_bool)[0]["tabRenderer"]
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_continuation_token(items : Array(JSON::Any))
|
def fetch_continuation_token(items : Array(JSON::Any))
|
||||||
# Fetches the continuation token from an array of items
|
# Fetches the continuation token from an array of items
|
||||||
return items.last["continuationItemRenderer"]?
|
return items.last["continuationItemRenderer"]?
|
||||||
|
|
Loading…
Reference in a new issue