mirror of https://github.com/iv-org/invidious.git
Spin parts into components
This commit is contained in:
parent
a2e23f7022
commit
e865a801aa
|
@ -13,6 +13,10 @@ macro templated(filename)
|
||||||
render "src/views/#{{{filename}}}.ecr", "src/views/layout.ecr"
|
render "src/views/#{{{filename}}}.ecr", "src/views/layout.ecr"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
macro rendered(filename)
|
||||||
|
render "src/views/#{{{filename}}}.ecr"
|
||||||
|
end
|
||||||
|
|
||||||
class Config
|
class Config
|
||||||
YAML.mapping({
|
YAML.mapping({
|
||||||
crawl_threads: Int32,
|
crawl_threads: Int32,
|
||||||
|
@ -297,7 +301,7 @@ end
|
||||||
|
|
||||||
def decrypt_signature(a)
|
def decrypt_signature(a)
|
||||||
a = a.split("")
|
a = a.split("")
|
||||||
|
|
||||||
a.reverse!
|
a.reverse!
|
||||||
a = splice(a, 50)
|
a = splice(a, 50)
|
||||||
a.delete_at(0..1)
|
a.delete_at(0..1)
|
||||||
|
|
|
@ -386,34 +386,32 @@ get "/search" do |env|
|
||||||
html = client.get("/results?q=#{URI.escape(query)}&page=#{page}&sp=EgIQAVAU").body
|
html = client.get("/results?q=#{URI.escape(query)}&page=#{page}&sp=EgIQAVAU").body
|
||||||
html = XML.parse_html(html)
|
html = XML.parse_html(html)
|
||||||
|
|
||||||
videos = Array(Hash(String, String)).new
|
videos = [] of Video
|
||||||
|
|
||||||
html.xpath_nodes(%q(//ol[@class="item-section"]/li)).each do |item|
|
html.xpath_nodes(%q(//ol[@class="item-section"]/li)).each do |item|
|
||||||
root = item.xpath_node(%q(div[contains(@class,"yt-lockup-video")]/div))
|
root = item.xpath_node(%q(div[contains(@class,"yt-lockup-video")]/div))
|
||||||
if root
|
if root
|
||||||
video = {} of String => String
|
|
||||||
|
|
||||||
id = root.xpath_node(%q(div[contains(@class,"yt-lockup-thumbnail")]/a/@href))
|
id = root.xpath_node(%q(div[contains(@class,"yt-lockup-thumbnail")]/a/@href))
|
||||||
if id
|
if id
|
||||||
id = id.content.lchop("/watch?v=")
|
id = id.content.lchop("/watch?v=")
|
||||||
end
|
end
|
||||||
id ||= ""
|
id ||= ""
|
||||||
video["id"] = id
|
|
||||||
|
|
||||||
title = root.xpath_node(%q(div[@class="yt-lockup-content"]/h3/a))
|
title = root.xpath_node(%q(div[@class="yt-lockup-content"]/h3/a))
|
||||||
if title
|
if title
|
||||||
video["title"] = title.content
|
title = title.content
|
||||||
end
|
end
|
||||||
video["title"] ||= ""
|
title ||= ""
|
||||||
|
|
||||||
author = root.xpath_node(%q(div[@class="yt-lockup-content"]/div/a))
|
author = root.xpath_node(%q(div[@class="yt-lockup-content"]/div/a))
|
||||||
if author
|
if author
|
||||||
video["author"] = author.content
|
ucid = author["href"].rpartition("/")[-1]
|
||||||
video["ucid_url"] = author["href"]
|
author = author.content
|
||||||
end
|
end
|
||||||
video["author"] ||= ""
|
author ||= ""
|
||||||
video["ucid_url"] ||= ""
|
ucid ||= ""
|
||||||
|
|
||||||
|
video = Video.new(id, HTTP::Params.parse(""), Time.now, title, 0_i64, 0, 0, 0.0, Time.now, "", nil, author, ucid)
|
||||||
videos << video
|
videos << video
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<div class="pure-u-1 pure-u-md-1-4">
|
||||||
|
<div class="h-box">
|
||||||
|
<a style="width:100%;" href="/watch?v=<%= video.id %>">
|
||||||
|
<img style="width:100%;" src="https://i.ytimg.com/vi/<%= video.id %>/mqdefault.jpg"/>
|
||||||
|
<p style="height:100%"><%= video.title %></p>
|
||||||
|
</a>
|
||||||
|
<p>
|
||||||
|
<b><a style="width:100%;" href="/channel/<%= video.ucid %>"><%= video.author %></a></b>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<h5>Shared <%= video.published.to_s("%B %-d, %Y at %r UTC") %></h5>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,11 @@
|
||||||
|
<div class="pure-u-1 pure-u-md-1-4">
|
||||||
|
<div class="h-box">
|
||||||
|
<a style="width:100%;" href="/watch?v=<%= video.id %>">
|
||||||
|
<img style="width:100%;" src="https://i.ytimg.com/vi/<%= video.id %>/mqdefault.jpg"/>
|
||||||
|
<p><%= video.title %></p>
|
||||||
|
</a>
|
||||||
|
<p>
|
||||||
|
<b><a style="width:100%;" href="/channel/<%= video.ucid %>"><%= video.author %></a></b>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -3,19 +3,9 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% top_videos.each_slice(4) do |slice| %>
|
<% top_videos.each_slice(4) do |slice| %>
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<% slice.each do |video| %>
|
<% slice.each do |video| %>
|
||||||
<div class="pure-u-1 pure-u-md-1-4">
|
<%= rendered "components/video" %>
|
||||||
<div class="h-box">
|
<% end %>
|
||||||
<a style="width:100%;" href="/watch?v=<%= video.id %>">
|
|
||||||
<img style="width:100%;" src="https://i.ytimg.com/vi/<%= video.id %>/mqdefault.jpg"/>
|
|
||||||
<p><%= video.title %></p>
|
|
||||||
</a>
|
|
||||||
<p>
|
|
||||||
<b><a style="width:100%;" href="https://youtube.com/channel/<%= video.info["ucid"] %>"><%= video.info["author"] %></a></b>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -5,19 +5,9 @@
|
||||||
<% videos.each_slice(4) do |slice| %>
|
<% videos.each_slice(4) do |slice| %>
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<% slice.each do |video| %>
|
<% slice.each do |video| %>
|
||||||
<div class="pure-u-1 pure-u-md-1-4">
|
<%= rendered "components/video" %>
|
||||||
<div class="h-box">
|
|
||||||
<a style="width:100%;" href="/watch?v=<%= video["id"] %>">
|
|
||||||
<img style="width:100%;" src="https://i.ytimg.com/vi/<%= video["id"] %>/mqdefault.jpg"/>
|
|
||||||
<p><%= video["title"] %></p>
|
|
||||||
</a>
|
|
||||||
<p>
|
|
||||||
<b><a style="width:100%;" href="https://youtube.com<%= video["ucid_url"]%>"><%= video["author"] %></a></b>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
|
|
|
@ -3,48 +3,22 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if !notifications.empty? %>
|
<% if !notifications.empty? %>
|
||||||
<% notifications.each_slice(4) do |slice| %>
|
<% notifications.each_slice(4) do |slice| %>
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<% slice.each do |video| %>
|
<% slice.each do |video| %>
|
||||||
<div class="pure-u-1 pure-u-md-1-4">
|
<%= rendered "components/subscription_video" %>
|
||||||
<div class="h-box">
|
<% end %>
|
||||||
<a style="width:100%;" href="/watch?v=<%= video.id %>">
|
|
||||||
<img style="width:100%;" src="https://i.ytimg.com/vi/<%= video.id %>/mqdefault.jpg"/>
|
|
||||||
<p style="height:100%"><%= video.title %></p>
|
|
||||||
</a>
|
|
||||||
<p>
|
|
||||||
<b><a style="width:100%;" href="https://youtube.com/channel/<%= video.ucid %>"><%= video.author %></a></b>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<h5>Shared <%= video.published.to_s("%B %-d, %Y at %r UTC") %></h5>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
<hr style="margin-left:1em; margin-right:1em;">
|
||||||
<% end %>
|
|
||||||
<hr style="margin-left:1em; margin-right:1em;">
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% videos.each_slice(4) do |slice| %>
|
<% videos.each_slice(4) do |slice| %>
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<% slice.each do |video| %>
|
<% slice.each do |video| %>
|
||||||
<div class="pure-u-1 pure-u-md-1-4">
|
<%= rendered "components/subscription_video" %>
|
||||||
<div class="h-box">
|
<% end %>
|
||||||
<a style="width:100%;" href="/watch?v=<%= video.id %>">
|
|
||||||
<img style="width:100%;" src="https://i.ytimg.com/vi/<%= video.id %>/mqdefault.jpg"/>
|
|
||||||
<p style="height:100%"><%= video.title %></p>
|
|
||||||
</a>
|
|
||||||
<p>
|
|
||||||
<b><a style="width:100%;" href="https://youtube.com/channel/<%= video.ucid %>"><%= video.author %></a></b>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<h5>Shared <%= video.published.to_s("%B %-d, %Y at %r UTC") %></h5>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
|
|
Loading…
Reference in New Issue