proxy 'sponsor.ajay.app'
This commit is contained in:
parent
f7f2b9fa06
commit
a8916b9308
@ -66,7 +66,7 @@ def proxy_site(env, start_response, video=False):
|
|||||||
# such as 8192 lest that causes the socket library to limit the
|
# such as 8192 lest that causes the socket library to limit the
|
||||||
# TCP window size
|
# TCP window size
|
||||||
# Might need fine-tuning, since this gives us 4*65536
|
# Might need fine-tuning, since this gives us 4*65536
|
||||||
# The tradeoff is that larger values (such as 6 seconds) only
|
# The tradeoff is that larger values (such as 6 seconds) only
|
||||||
# allows video to buffer in those increments, meaning user must wait
|
# allows video to buffer in those increments, meaning user must wait
|
||||||
# until the entire chunk is downloaded before video starts playing
|
# until the entire chunk is downloaded before video starts playing
|
||||||
content_part = response.read(32*8192)
|
content_part = response.read(32*8192)
|
||||||
@ -85,6 +85,7 @@ site_handlers = {
|
|||||||
'ytimg.com': proxy_site,
|
'ytimg.com': proxy_site,
|
||||||
'yt3.ggpht.com': proxy_site,
|
'yt3.ggpht.com': proxy_site,
|
||||||
'lh3.googleusercontent.com': proxy_site,
|
'lh3.googleusercontent.com': proxy_site,
|
||||||
|
'sponsor.ajay.app': proxy_site,
|
||||||
'googlevideo.com': proxy_video,
|
'googlevideo.com': proxy_video,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,9 +96,9 @@ def split_url(url):
|
|||||||
match = re.match(r'(?:https?://)?([\w-]+(?:\.[\w-]+)+?)(/.*|$)', url)
|
match = re.match(r'(?:https?://)?([\w-]+(?:\.[\w-]+)+?)(/.*|$)', url)
|
||||||
if match is None:
|
if match is None:
|
||||||
raise ValueError('Invalid or unsupported url: ' + url)
|
raise ValueError('Invalid or unsupported url: ' + url)
|
||||||
|
|
||||||
return match.group(1), match.group(2)
|
return match.group(1), match.group(2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def error_code(code, start_response):
|
def error_code(code, start_response):
|
||||||
|
@ -7,6 +7,10 @@ from sys import exc_info
|
|||||||
yt_app = flask.Flask(__name__)
|
yt_app = flask.Flask(__name__)
|
||||||
yt_app.config['TEMPLATES_AUTO_RELOAD'] = True
|
yt_app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||||
yt_app.url_map.strict_slashes = False
|
yt_app.url_map.strict_slashes = False
|
||||||
|
# yt_app.jinja_env.trim_blocks = True
|
||||||
|
# yt_app.jinja_env.lstrip_blocks = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
yt_app.add_url_rule('/settings', 'settings_page', settings.settings_page, methods=['POST', 'GET'])
|
yt_app.add_url_rule('/settings', 'settings_page', settings.settings_page, methods=['POST', 'GET'])
|
||||||
|
@ -108,10 +108,6 @@ function copyTextToClipboard(text) {
|
|||||||
document.body.removeChild(textArea);
|
document.body.removeChild(textArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVideoID() {
|
|
||||||
return JSON.parse(Q(".video-info input[name=video_info_list]").value).id
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', function() {
|
window.addEventListener('DOMContentLoaded', function() {
|
||||||
cur_track_idx = getDefaultTranscriptTrackIdx();
|
cur_track_idx = getDefaultTranscriptTrackIdx();
|
||||||
|
@ -37,9 +37,8 @@ function onKeyDown(e) {
|
|||||||
else tt.mode = "showing";
|
else tt.mode = "showing";
|
||||||
}
|
}
|
||||||
else if (c == "t") {
|
else if (c == "t") {
|
||||||
let video_id = getVideoID();
|
|
||||||
let ts = Math.floor(Q("video").currentTime);
|
let ts = Math.floor(Q("video").currentTime);
|
||||||
copyTextToClipboard(`https://youtu.be/${video_id}?t=${ts}`);
|
copyTextToClipboard(`https://youtu.be/${data.video_id}?t=${ts}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
function load_sponsorblock(){
|
function load_sponsorblock(){
|
||||||
const info_elem = Q('#skip_n');
|
const info_elem = Q('#skip_n');
|
||||||
if (info_elem.innerText.length) return; // already fetched
|
if (info_elem.innerText.length) return; // already fetched
|
||||||
const video_id = getVideoID();
|
const hash = sha256(data.video_id).substr(0,4);
|
||||||
const hash = sha256(video_id).substr(0,4);
|
|
||||||
const video_obj = Q("video");
|
const video_obj = Q("video");
|
||||||
fetch(`https://sponsor.ajay.app/api/skipSegments/${hash}`)
|
let url = `/https://sponsor.ajay.app/api/skipSegments/${hash}`;
|
||||||
|
fetch(url)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
for (const video of data) {
|
for (const video of data) {
|
||||||
if (video.videoID != video_id) continue;
|
if (video.videoID != data.video_id) continue;
|
||||||
info_elem.innerText = `(${video.segments.length} segments)`;
|
info_elem.innerText = `(${video.segments.length} segments)`;
|
||||||
const cat_n = video.segments.map(e=>e.category).sort()
|
const cat_n = video.segments.map(e=>e.category).sort()
|
||||||
.reduce((acc,e) => (acc[e]=(acc[e]||0)+1, acc), {});
|
.reduce((acc,e) => (acc[e]=(acc[e]||0)+1, acc), {});
|
||||||
|
@ -4,8 +4,9 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>{{ page_title }}</title>
|
<title>{{ page_title }}</title>
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline'; media-src 'self' https://*.googlevideo.com;
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline'; media-src 'self' https://*.googlevideo.com;
|
||||||
{{ "img-src https://*.googleusercontent.com https://*.ggpht.com https://*.ytimg.com;" if not settings.proxy_images else "" }}
|
{% if not settings.proxy_images %}
|
||||||
{{ "" if not settings.use_sponsorblock_js else "connect-src 'self' https://sponsor.ajay.app;"|safe }}">
|
img-src https://*.googleusercontent.com https://*.ggpht.com https://*.ytimg.com;
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<link href="{{ theme_path }}" type="text/css" rel="stylesheet">
|
<link href="{{ theme_path }}" type="text/css" rel="stylesheet">
|
||||||
<link href="/youtube.com/static/shared.css" type="text/css" rel="stylesheet">
|
<link href="/youtube.com/static/shared.css" type="text/css" rel="stylesheet">
|
||||||
|
@ -695,6 +695,7 @@ Reload without invidious (for usage of new identity button).</a>
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<script> data = {{ js_data|tojson }} </script>
|
||||||
<script src="/youtube.com/static/js/common.js"></script>
|
<script src="/youtube.com/static/js/common.js"></script>
|
||||||
<script src="/youtube.com/static/js/transcript-table.js"></script>
|
<script src="/youtube.com/static/js/transcript-table.js"></script>
|
||||||
{% if settings.use_video_hotkeys %} <script src="/youtube.com/static/js/hotkeys.js"></script> {% endif %}
|
{% if settings.use_video_hotkeys %} <script src="/youtube.com/static/js/hotkeys.js"></script> {% endif %}
|
||||||
|
@ -489,6 +489,10 @@ def get_watch_page(video_id=None):
|
|||||||
invidious_reload_button = info['invidious_reload_button'],
|
invidious_reload_button = info['invidious_reload_button'],
|
||||||
video_url = util.URL_ORIGIN + '/watch?v=' + video_id,
|
video_url = util.URL_ORIGIN + '/watch?v=' + video_id,
|
||||||
time_start = time_start,
|
time_start = time_start,
|
||||||
|
|
||||||
|
js_data = {
|
||||||
|
'video_id': video_info['id'],
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user