forked from Fijxu/invidious
Compare commits
39 commits
Author | SHA1 | Date | |
---|---|---|---|
|
d286cc4ec2 | ||
|
d84754bf56 | ||
|
cbf11d7697 | ||
e419cee0ff | |||
|
50e83e0446 | ||
|
9eab43e58a | ||
|
2c0d9c8292 | ||
|
82e0406ebd | ||
|
aed4fc220b | ||
|
66f90e8898 | ||
|
c23d85c6e5 | ||
|
201d9ab743 | ||
|
505b0a13c1 | ||
|
81be6991ae | ||
|
34737b23a4 | ||
|
e8fb37475a | ||
|
0d0c5ed2be | ||
|
d8e4daa615 | ||
|
84f456f8a9 | ||
3cb8b69846 | |||
7c990e1627 | |||
0cb11bbab2 | |||
e6eee402dd | |||
75452d2537 | |||
3ee98051e4 | |||
e17ca9735d | |||
98cfcbf4b8 | |||
5e1b795895 | |||
07b88415db | |||
d124a225a1 | |||
9d71ce050a | |||
41977eb7c1 | |||
025fa8b64b | |||
c85c6808b5 | |||
|
9207f41472 | ||
3718062a4b | |||
62318f8cc6 | |||
7dd75caa7d | |||
ccfbe58968 |
10 changed files with 54 additions and 75 deletions
|
@ -37,15 +37,13 @@ jobs:
|
|||
type=sha,format=short,prefix={{date 'YYYY.MM.DD'}}-,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
|
||||
|
||||
- uses: https://code.forgejo.org/docker/build-push-action@v6
|
||||
- uses: https://code.forgejo.org/docker/build-push-action@v5
|
||||
name: Build images
|
||||
with:
|
||||
context: .
|
||||
file: docker/Dockerfile
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
platforms: linux/amd64
|
||||
# cache-from: type=gha
|
||||
# cache-to: type=gha,mode=max
|
||||
push: true
|
||||
build-args: |
|
||||
"release=1"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM crystallang/crystal:1.14.0-alpine AS builder
|
||||
FROM crystallang/crystal:1.12.1-alpine AS builder
|
||||
|
||||
RUN apk add --no-cache sqlite-static yaml-static
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ shards:
|
|||
inotify:
|
||||
git: https://github.com/petoem/inotify.cr.git
|
||||
version: 1.0.3
|
||||
|
||||
http_proxy:
|
||||
git: https://github.com/mamantoha/http_proxy.git
|
||||
version: 0.10.3
|
||||
|
|
|
@ -23,31 +23,14 @@ def produce_channel_content_continuation(ucid, content_type, page = 1, auto_gene
|
|||
else 15 # Fallback to "videos"
|
||||
end
|
||||
|
||||
sort_type_numerical =
|
||||
case content_type
|
||||
when "videos" then 3
|
||||
when "livestreams" then 5
|
||||
else 3 # Fallback to "videos"
|
||||
sort_by_numerical =
|
||||
case sort_by
|
||||
when "newest" then 1_i64
|
||||
when "popular" then 2_i64
|
||||
when "oldest" then 4_i64
|
||||
else 1_i64 # Fallback to "newest"
|
||||
end
|
||||
|
||||
if content_type == "livestreams"
|
||||
sort_by_numerical =
|
||||
case sort_by
|
||||
when "newest" then 12_i64
|
||||
when "popular" then 14_i64
|
||||
when "oldest" then 13_i64
|
||||
else 12_i64 # Fallback to "newest"
|
||||
end
|
||||
else
|
||||
sort_by_numerical =
|
||||
case sort_by
|
||||
when "newest" then 1_i64
|
||||
when "popular" then 2_i64
|
||||
when "oldest" then 4_i64
|
||||
else 1_i64 # Fallback to "newest"
|
||||
end
|
||||
end
|
||||
|
||||
object_inner_1 = {
|
||||
"110:embedded" => {
|
||||
"3:embedded" => {
|
||||
|
@ -58,7 +41,7 @@ def produce_channel_content_continuation(ucid, content_type, page = 1, auto_gene
|
|||
"2:embedded" => {
|
||||
"1:string" => "00000000-0000-0000-0000-000000000000",
|
||||
},
|
||||
"#{sort_type_numerical}:varint" => sort_by_numerical,
|
||||
"3:varint" => sort_by_numerical,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -6,14 +6,9 @@ module Tokens
|
|||
def refresh_tokens
|
||||
@@po_token = REDIS_DB.get("invidious:po_token")
|
||||
@@visitor_data = REDIS_DB.get("invidious:visitor_data")
|
||||
if !@@po_token.nil? && !@@visitor_data.nil?
|
||||
LOGGER.debug("RefreshTokens: Successfully updated tokens")
|
||||
else
|
||||
LOGGER.warn("RefreshTokens: Tokens are empty!")
|
||||
end
|
||||
LOGGER.trace("RefreshTokens: Tokens are:")
|
||||
LOGGER.trace("RefreshTokens: po_token: #{@@po_token}")
|
||||
LOGGER.trace("RefreshTokens: visitor_data: #{@@visitor_data}")
|
||||
LOGGER.debug("RefreshTokens: Tokens are:")
|
||||
LOGGER.debug("RefreshTokens: po_token: #{@@po_token}")
|
||||
LOGGER.debug("RefreshTokens: visitor_data: #{@@visitor_data}")
|
||||
end
|
||||
|
||||
def get_tokens
|
||||
|
|
|
@ -4,28 +4,51 @@ module Invidious::HttpServer
|
|||
module Utils
|
||||
extend self
|
||||
|
||||
@@proxy_alive : String = ""
|
||||
@@proxy_list : Array(String) = [] of String
|
||||
@@current_proxy : String = ""
|
||||
@@count : Int64 = Time.utc.to_unix
|
||||
|
||||
def check_external_proxy
|
||||
CONFIG.external_videoplayback_proxy.each do |proxy|
|
||||
begin
|
||||
response = HTTP::Client.get("#{proxy[:url]}/health")
|
||||
if response.status_code == 200
|
||||
@@proxy_alive = proxy[:url]
|
||||
LOGGER.debug("CheckExternalProxy: Proxy set to: '#{proxy[:url]}'")
|
||||
break
|
||||
if @@proxy_list.includes?(proxy[:url])
|
||||
next
|
||||
end
|
||||
if proxy[:balance]
|
||||
@@proxy_list << proxy[:url]
|
||||
LOGGER.debug("CheckExternalProxy: Adding proxy '#{proxy[:url]}' to the list of proxies")
|
||||
end
|
||||
break if proxy[:balance] == false && !@@proxy_list.empty?
|
||||
@@proxy_list << proxy[:url]
|
||||
end
|
||||
rescue
|
||||
if @@proxy_list.includes?(proxy[:url])
|
||||
LOGGER.debug("CheckExternalProxy: Proxy '#{proxy[:url]}' is not available, removing it from the list of proxies")
|
||||
@@proxy_list.delete(proxy[:url])
|
||||
end
|
||||
LOGGER.debug("CheckExternalProxy: Proxy '#{proxy[:url]}' is not available")
|
||||
end
|
||||
end
|
||||
if @@proxy_alive.empty?
|
||||
LOGGER.warn("CheckExternalProxy: No proxies alive! Using own server proxy")
|
||||
end
|
||||
LOGGER.trace("CheckExternalProxy: List of proxies:")
|
||||
LOGGER.trace("#{@@proxy_list.inspect}")
|
||||
end
|
||||
|
||||
# TODO: If the function is called many times, it will return a random
|
||||
# proxy from the list. That is not how it should be.
|
||||
# It should return the same proxy, in multiple function calls
|
||||
def select_proxy
|
||||
if (@@count - (Time.utc.to_unix - 30)) <= 0
|
||||
return if @@proxy_list.size <= 0
|
||||
@@current_proxy = @@proxy_list[Random.rand(@@proxy_list.size)]
|
||||
LOGGER.debug("Current proxy is: '#{@@current_proxy}'")
|
||||
@@count = Time.utc.to_unix
|
||||
end
|
||||
end
|
||||
|
||||
def get_external_proxy
|
||||
return @@proxy_alive
|
||||
return @@current_proxy
|
||||
end
|
||||
|
||||
def proxy_video_url(raw_url : String, *, region : String? = nil, absolute : Bool = false)
|
||||
|
@ -38,8 +61,8 @@ module Invidious::HttpServer
|
|||
url.query_params = params
|
||||
|
||||
if absolute
|
||||
if !@@proxy_alive.empty?
|
||||
return "#{@@proxy_alive}#{url.request_target}"
|
||||
if !(proxy = get_external_proxy()).empty?
|
||||
return "#{proxy}#{url.request_target}"
|
||||
else
|
||||
return "#{HOST_URL}#{url.request_target}"
|
||||
end
|
||||
|
|
|
@ -5,8 +5,9 @@ class Invidious::Jobs::CheckExternalProxy < Invidious::Jobs::BaseJob
|
|||
def begin
|
||||
loop do
|
||||
HttpServer::Utils.check_external_proxy
|
||||
LOGGER.info("CheckExternalProxy: Done, sleeping for 10 seconds")
|
||||
sleep 10.seconds
|
||||
HttpServer::Utils.select_proxy
|
||||
LOGGER.info("CheckExternalProxy: Done, sleeping for 15 seconds")
|
||||
sleep 15.seconds
|
||||
Fiber.yield
|
||||
end
|
||||
end
|
||||
|
|
|
@ -152,7 +152,6 @@ module Invidious::Routes::Watch
|
|||
end
|
||||
end
|
||||
|
||||
# Removes non default audio tracks
|
||||
audio_streams.reject! do |z|
|
||||
z if z.dig?("audioTrack", "audioIsDefault") == false
|
||||
end
|
||||
|
@ -219,12 +218,6 @@ module Invidious::Routes::Watch
|
|||
captions: video.captions
|
||||
)
|
||||
|
||||
begin
|
||||
video_url = fmt_stream[0]["url"].to_s
|
||||
rescue
|
||||
video_url = nil
|
||||
end
|
||||
|
||||
templated "watch"
|
||||
end
|
||||
|
||||
|
|
|
@ -13,13 +13,11 @@
|
|||
<meta property="og:image" content="<%= HOST_URL %>/vi/<%= video.id %>/maxres.jpg">
|
||||
<meta property="og:description" content="<%= HTML.escape(video.short_description) %>">
|
||||
<meta property="og:type" content="video.other">
|
||||
<!-- This shouldn't be empty, ever. -->
|
||||
<meta property="og:video" content="<%= video_url %>">
|
||||
<meta property="og:video:url" content="<%= video_url %>">
|
||||
<meta property="og:video:secure_url" content="<%= video_url %>">
|
||||
<meta property="og:video:type" content="video/mp4">
|
||||
<meta property="og:video:width" content="640">
|
||||
<meta property="og:video:height" content="360">
|
||||
<meta property="og:video:url" content="<%= HOST_URL %>/embed/<%= video.id %>">
|
||||
<meta property="og:video:secure_url" content="<%= HOST_URL %>/embed/<%= video.id %>">
|
||||
<meta property="og:video:type" content="text/html">
|
||||
<meta property="og:video:width" content="1280">
|
||||
<meta property="og:video:height" content="720">
|
||||
<meta name="twitter:card" content="player">
|
||||
<meta name="twitter:url" content="<%= HOST_URL %>/watch?v=<%= video.id %>">
|
||||
<meta name="twitter:title" content="<%= title %>">
|
||||
|
|
|
@ -86,19 +86,6 @@ def make_client(url : URI, region = nil, force_resolve : Bool = false, &)
|
|||
end
|
||||
end
|
||||
|
||||
def make_configured_http_proxy_client
|
||||
# This method is only called when configuration for an HTTP proxy are set
|
||||
config_proxy = CONFIG.http_proxy.not_nil!
|
||||
|
||||
return HTTP::Proxy::Client.new(
|
||||
config_proxy.host,
|
||||
config_proxy.port,
|
||||
|
||||
username: config_proxy.user,
|
||||
password: config_proxy.password,
|
||||
)
|
||||
end
|
||||
|
||||
# Fetches a HTTP pool for the specified subdomain of ytimg.com
|
||||
#
|
||||
# Creates a new one when the specified pool for the subdomain does not exist
|
||||
|
|
Loading…
Reference in a new issue