mirror of
				https://github.com/iv-org/invidious.git
				synced 2025-11-04 06:08:31 -06:00 
			
		
		
		
	Merge branch 'master' into api-only
This commit is contained in:
		
						commit
						664ff4b2e0
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -10,4 +10,3 @@ db:
 | 
			
		||||
  dbname: invidious
 | 
			
		||||
full_refresh: false
 | 
			
		||||
https_only: false
 | 
			
		||||
geo_bypass: true
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
											
										
									
								
							@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user