Merge branch 'master' into api-only

This commit is contained in:
Omar Roth 2018-11-19 22:28:54 -06:00
commit 664ff4b2e0
7 changed files with 41 additions and 21 deletions

View File

@ -2,7 +2,7 @@
## Invidious is an alternative front-end to YouTube
- Audio-only (and no need to keep window open on mobile)
- Audio-only mode (and no need to keep window open on mobile)
- [Open-source](https://github.com/omarroth/invidious) (AGPLv3 licensed)
- No ads
- No need to create a Google account to save subscriptions

View File

@ -10,4 +10,3 @@ db:
dbname: invidious
full_refresh: false
https_only: false
geo_bypass: true

View File

@ -83,16 +83,7 @@ spawn do
end
end
proxies = {} of String => Array({ip: String, port: Int32})
if CONFIG.geo_bypass
spawn do
find_working_proxies(BYPASS_REGIONS) do |region, list|
if !list.empty?
proxies[region] = list
end
end
end
end
proxies = PROXY_LIST
# API Endpoints

View File

@ -491,8 +491,7 @@ def content_to_comment_html(content)
end
if run["navigationEndpoint"]?
url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s
if url
if url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s
url = URI.parse(url)
if !url.host || {"m.youtube.com", "www.youtube.com", "youtu.be"}.includes? url.host
@ -502,11 +501,16 @@ def content_to_comment_html(content)
url = url.full_path
end
end
else
url = run["navigationEndpoint"]["commandMetadata"]?.try &.["webCommandMetadata"]["url"].as_s
end
text = %(<a href="#{url}">#{text}</a>)
text = %(<a href="#{url}">#{text}</a>)
elsif watch_endpoint = run["navigationEndpoint"]["watchEndpoint"]?
length_seconds = watch_endpoint["startTimeSeconds"].as_i
video_id = watch_endpoint["videoId"].as_s
text = %(<a href="javascript:void(0)" onclick="player.currentTime(#{length_seconds})">#{text}</a>)
elsif url = run["navigationEndpoint"]["commandMetadata"]?.try &.["webCommandMetadata"]["url"].as_s
text = %(<a href="#{url}">#{text}</a>)
end
end
text

View File

@ -15,7 +15,6 @@ class Config
https_only: Bool?,
hmac_key: String?,
full_refresh: Bool,
geo_bypass: Bool,
domain: String?,
})
end

File diff suppressed because one or more lines are too long

View File

@ -203,7 +203,7 @@ end
def create_response(user_id, operation, key, db, expire = 6.hours)
expire = Time.now + expire
nonce = Random::Secure.hex(16)
db.exec("INSERT INTO nonces VALUES ($1) ON CONFLICT DO NOTHING", nonce)
db.exec("INSERT INTO nonces VALUES ($1, $2) ON CONFLICT DO NOTHING", nonce, expire)
challenge = "#{expire.to_unix}-#{nonce}-#{user_id}-#{operation}"
token = OpenSSL::HMAC.digest(:sha256, key, challenge)