Compare commits
20 Commits
1d0b435e87
...
thumbnail-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74b719b2ea | ||
|
|
e2632c962d | ||
|
|
0009574b77 | ||
|
|
d4ed9dce5d | ||
|
|
c54d0889c1 | ||
|
|
b48d7aa161 | ||
|
|
52d7802491 | ||
|
|
d508263946 | ||
|
|
59f7c33ebd | ||
|
|
acfffb3a91 | ||
|
|
0f7e27fd77 | ||
|
|
6631447acc | ||
|
|
0f30480af4 | ||
|
|
a9893068cd | ||
|
|
d7086ead27 | ||
|
|
25dad88ed9 | ||
|
|
b6b17b1f52 | ||
|
|
7207e36510 | ||
|
|
5d739bec12 | ||
|
|
2e6e74b959 |
321
backend/main.py
321
backend/main.py
@@ -10,6 +10,7 @@ import yt_dlp
|
||||
from yt_dlp.networking.impersonate import ImpersonateTarget
|
||||
from curl_cffi import requests as impersonate_requests
|
||||
import threading
|
||||
import queue
|
||||
import io
|
||||
import time
|
||||
import hashlib
|
||||
@@ -20,23 +21,125 @@ from urllib.parse import urljoin
|
||||
# that isn't a real browser, so impersonation must be on by default.
|
||||
IMPERSONATE_TARGET = os.getenv('STREAM_IMPERSONATE', 'chrome').strip() or 'chrome'
|
||||
|
||||
# curl_cffi sessions wrap a single libcurl handle and are not safe to share
|
||||
# across threads; keep one per worker thread so the Flask `threaded=True`
|
||||
# server can proxy concurrent segments without corrupting state.
|
||||
_thread_local = threading.local()
|
||||
# curl_cffi sessions wrap a single libcurl handle: they can't be shared by two
|
||||
# requests at once, but reusing one *across* requests is what keeps the upstream
|
||||
# connection alive, and with it the TLS handshake we already paid for. A video
|
||||
# arrives as dozens of range requests (and an HLS stream as one request per
|
||||
# segment), so a handshake per request is the difference between a stall and a
|
||||
# seek.
|
||||
#
|
||||
# This used to be a thread-local, which never actually hit: the development
|
||||
# server gives every connection a brand-new thread, so each request found empty
|
||||
# thread-local storage and built a session from scratch. Sessions live in a
|
||||
# shared pool instead -- checked out for the duration of one request, returned
|
||||
# when its response is closed (which, for a streamed body, is when the last byte
|
||||
# has been sent). LIFO so the hottest connection is the one handed out next.
|
||||
try:
|
||||
_SESSION_POOL_SIZE = max(1, int(os.getenv('STREAM_SESSION_POOL', '') or 8))
|
||||
except ValueError:
|
||||
_SESSION_POOL_SIZE = 8
|
||||
_session_pool = queue.LifoQueue(maxsize=_SESSION_POOL_SIZE)
|
||||
|
||||
|
||||
def get_impersonate_session():
|
||||
sess = getattr(_thread_local, 'session', None)
|
||||
if sess is None:
|
||||
sess = impersonate_requests.Session(impersonate=IMPERSONATE_TARGET)
|
||||
_thread_local.session = sess
|
||||
return sess
|
||||
def _borrow_session():
|
||||
"""A session nobody else is using: from the pool, or a fresh one."""
|
||||
try:
|
||||
return _session_pool.get_nowait()
|
||||
except queue.Empty:
|
||||
return impersonate_requests.Session(impersonate=IMPERSONATE_TARGET)
|
||||
|
||||
# Stream params that have dedicated meaning and must never be treated as headers.
|
||||
|
||||
def _return_session(sess):
|
||||
"""Hand a session back. Beyond the pool's size the extras are closed, so a
|
||||
burst of concurrency doesn't leave idle connections open forever."""
|
||||
try:
|
||||
_session_pool.put_nowait(sess)
|
||||
except queue.Full:
|
||||
try:
|
||||
sess.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def _discard_session(sess):
|
||||
"""Drop a session that raised, rather than pooling a possibly-poisoned handle."""
|
||||
try:
|
||||
sess.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def _release_when_closed(resp, sess):
|
||||
"""Return `sess` to the pool once `resp` is closed.
|
||||
|
||||
Every caller either closes the response outright or streams it through a
|
||||
generator that closes in a `finally`, so this is where a request's exclusive
|
||||
hold on a session ends. Idempotent: a double close must not put the same
|
||||
session in the pool twice."""
|
||||
original_close = resp.close
|
||||
released = False
|
||||
|
||||
def close():
|
||||
nonlocal released
|
||||
try:
|
||||
original_close()
|
||||
finally:
|
||||
if not released:
|
||||
released = True
|
||||
_return_session(sess)
|
||||
|
||||
resp.close = close
|
||||
return resp
|
||||
|
||||
|
||||
def _is_tls_verify_error(err):
|
||||
message = str(err).lower()
|
||||
return 'certificate' in message or 'curl: (60)' in message or 'ssl: ' in message
|
||||
|
||||
|
||||
# Hosts already proven to fail certificate verification. A video is fetched in
|
||||
# many range requests, so remembering the host keeps us from paying for a
|
||||
# doomed TLS handshake on every one of them.
|
||||
_tls_unverified_hosts = set()
|
||||
|
||||
|
||||
def impersonate_get(url, **kwargs):
|
||||
"""Upstream GET that survives an origin with a broken certificate.
|
||||
|
||||
Some media hosts serve expired certs (heavyfetish's stNN CDN, for one), which
|
||||
a browser refuses outright -- part of why this proxy exists. The viewer's
|
||||
connection to *us* stays verified either way, so rather than failing the
|
||||
stream we retry once with verification off, and say so in the log. Set
|
||||
STREAM_TLS_VERIFY_ONLY=1 to keep the hard failure instead."""
|
||||
host = urllib.parse.urlparse(url).netloc
|
||||
sess = _borrow_session()
|
||||
if host in _tls_unverified_hosts:
|
||||
try:
|
||||
return _release_when_closed(sess.get(url, verify=False, **kwargs), sess)
|
||||
except Exception:
|
||||
_discard_session(sess)
|
||||
raise
|
||||
try:
|
||||
return _release_when_closed(sess.get(url, **kwargs), sess)
|
||||
except Exception as err:
|
||||
strict = os.getenv('STREAM_TLS_VERIFY_ONLY', '').strip().lower() in ('1', 'true', 'yes', 'on')
|
||||
if strict or not _is_tls_verify_error(err):
|
||||
_discard_session(sess)
|
||||
raise
|
||||
app.logger.warning("[stream] TLS verification failed for %s (%s); retrying unverified", url, err)
|
||||
_tls_unverified_hosts.add(host)
|
||||
try:
|
||||
return _release_when_closed(sess.get(url, verify=False, **kwargs), sess)
|
||||
except Exception:
|
||||
_discard_session(sess)
|
||||
raise
|
||||
|
||||
# Request params that have dedicated meaning and must never be treated as headers.
|
||||
# `referer` is mapped to a real Referer header by collect_passthrough_headers, but
|
||||
# `live` is purely a playback hint and must not leak upstream as a header.
|
||||
STREAM_RESERVED_PARAMS = {'url', 'live'}
|
||||
# `live` is purely a playback hint and must not leak upstream as a header. `full`
|
||||
# is /api/resolve's "give me everything" switch and is likewise ours, not the
|
||||
# origin's.
|
||||
STREAM_RESERVED_PARAMS = {'url', 'live', 'full'}
|
||||
# Headers that affect the transport layer rather than the resource itself; allowing
|
||||
# these to be forwarded could enable request smuggling or vhost-routing abuse.
|
||||
STREAM_DISALLOWED_HEADER_NAMES = {'host', 'content-length', 'transfer-encoding', 'connection', 'expect'}
|
||||
@@ -47,6 +150,10 @@ STREAM_IMPERSONATION_MANAGED_HEADERS = {
|
||||
'user-agent', 'accept', 'accept-encoding', 'accept-language',
|
||||
'sec-ch-ua', 'sec-ch-ua-mobile', 'sec-ch-ua-platform',
|
||||
}
|
||||
# `Content-Range: bytes 0-0/12345` -> the total size of the resource. A '*'
|
||||
# total (an origin that won't say) deliberately doesn't match, so the length is
|
||||
# then simply left out rather than guessed at.
|
||||
_CONTENT_RANGE_TOTAL_RE = re.compile(r'^\s*bytes\s+\d+-\d+/(\d+)\s*$', re.I)
|
||||
# RFC 7230 token charset for header field-names.
|
||||
HEADER_NAME_RE = re.compile(r"^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$")
|
||||
# Reject control characters (CR/LF/NUL etc.) that could be used for header injection.
|
||||
@@ -184,8 +291,31 @@ _resolve_cache_lock = threading.Lock()
|
||||
# Per-format fields the frontend needs to rank formats and build stream/probe
|
||||
# URLs (see resolveStreamSources/rankFormats in videos.js). Everything else in a
|
||||
# yt-dlp format dict is dropped to keep the payload small.
|
||||
# `protocol` is what yt-dlp calls the delivery method ('https', 'm3u8_native',
|
||||
# 'http_dash_segments', ...). Passing it on saves the player a HEAD round trip
|
||||
# against the proxy -- and with it a whole upstream connection -- for URLs whose
|
||||
# extension doesn't say what they are, which is most signed CDN links.
|
||||
_RESOLVE_FORMAT_FIELDS = ('url', 'http_headers', 'height', 'width', 'tbr',
|
||||
'fps', 'vcodec', 'acodec', 'ext', 'video_ext', 'quality')
|
||||
'fps', 'vcodec', 'acodec', 'ext', 'video_ext', 'quality',
|
||||
'protocol', 'format_note')
|
||||
|
||||
|
||||
def _trim_resolve_info(info):
|
||||
"""The lean payload playback needs: the media URLs, the headers that make
|
||||
them work, and just enough per-format detail to rank them. This is what
|
||||
every hovered card asks for, so it stays small."""
|
||||
formats = []
|
||||
for fmt in ((info.get('formats') if info else None) or []):
|
||||
if not fmt.get('url'):
|
||||
continue
|
||||
formats.append({k: fmt.get(k) for k in _RESOLVE_FORMAT_FIELDS if fmt.get(k) is not None})
|
||||
|
||||
return {
|
||||
'url': info.get('url') if info else None,
|
||||
'http_headers': (info.get('http_headers') if info else None) or {},
|
||||
'isLive': bool(info.get('is_live')) if info else False,
|
||||
'formats': formats,
|
||||
}
|
||||
|
||||
# Some channels surface pages that yt-dlp can't extract because the video is
|
||||
# embedded in a third-party JS player iframe (e.g. the xtremestream family used
|
||||
@@ -200,8 +330,11 @@ def resolve_unsupported_embed(page_url):
|
||||
"""Best-effort resolver for iframe-embedded JS players yt-dlp can't handle.
|
||||
Returns an info-like dict ({'url','formats','http_headers','is_live'}) whose
|
||||
single format is the embed's HLS playlist, or None if nothing was found."""
|
||||
# Both fetches are small and fully buffered, so this holds one pooled session
|
||||
# for the whole scrape rather than going through impersonate_get (whose
|
||||
# release is tied to closing a streamed response).
|
||||
sess = _borrow_session()
|
||||
try:
|
||||
sess = get_impersonate_session()
|
||||
page = sess.get(page_url, headers={'Referer': page_url}, timeout=15)
|
||||
embed_url = None
|
||||
for src in _EMBED_IFRAME_RE.findall(page.text):
|
||||
@@ -229,14 +362,25 @@ def resolve_unsupported_embed(page_url):
|
||||
'formats': [{'url': stream_url, 'ext': 'm3u8', 'protocol': 'm3u8', 'http_headers': headers}],
|
||||
}
|
||||
except Exception:
|
||||
_discard_session(sess)
|
||||
sess = None
|
||||
return None
|
||||
finally:
|
||||
if sess is not None:
|
||||
_return_session(sess)
|
||||
|
||||
@app.route('/api/resolve', methods=['POST', 'GET'])
|
||||
def resolve_video():
|
||||
"""Resolve a page URL to its playable formats via yt-dlp and return them as
|
||||
JSON. The frontend calls this on demand (when a card is hovered or scrolled
|
||||
into view) to learn the real media URLs so it can background-probe them for
|
||||
direct, proxy-free playability."""
|
||||
direct, proxy-free playability.
|
||||
|
||||
`full=1` returns the extractor's whole info dict instead of the trimmed
|
||||
playback payload -- everything it knows about the video (description, dates,
|
||||
counts, tags, thumbnails, every format field), which is what the Show info
|
||||
panel exists to display. Both views come from one extraction and one cache
|
||||
entry, so asking for the full one costs no extra work upstream."""
|
||||
if request.method == 'POST':
|
||||
source = request.json or {}
|
||||
video_url = source.get('url')
|
||||
@@ -247,11 +391,19 @@ def resolve_video():
|
||||
if not video_url:
|
||||
return jsonify({"error": "No URL provided"}), 400
|
||||
|
||||
want_full = str(source.get('full', '')).strip().lower() in ('1', 'true', 'yes', 'on')
|
||||
|
||||
def view_of(info):
|
||||
if not want_full:
|
||||
return _trim_resolve_info(info)
|
||||
# Nothing to show, but answer in the same shape rather than `null`.
|
||||
return info if info else {}
|
||||
|
||||
now = time.time()
|
||||
with _resolve_cache_lock:
|
||||
cached = _resolve_cache.get(video_url)
|
||||
if cached and cached[0] > now:
|
||||
return jsonify(cached[1])
|
||||
return jsonify(view_of(cached[1]))
|
||||
|
||||
ydl_opts = {
|
||||
'quiet': True,
|
||||
@@ -268,6 +420,10 @@ def resolve_video():
|
||||
try:
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
info = ydl.extract_info(video_url, download=False)
|
||||
# The raw info dict holds objects that don't survive JSON (and
|
||||
# internal `__`-prefixed bookkeeping). This is the same pass yt-dlp
|
||||
# itself runs behind --dump-json.
|
||||
info = ydl.sanitize_info(info, remove_private_keys=True)
|
||||
except Exception as e:
|
||||
# Many channels point at sites yt-dlp can't extract ("Unsupported URL").
|
||||
# That's not fatal here -- the embed fallback below may still find a
|
||||
@@ -282,26 +438,17 @@ def resolve_video():
|
||||
if embed:
|
||||
info = embed
|
||||
|
||||
formats = []
|
||||
for fmt in ((info.get('formats') if info else None) or []):
|
||||
if not fmt.get('url'):
|
||||
continue
|
||||
formats.append({k: fmt.get(k) for k in _RESOLVE_FORMAT_FIELDS if fmt.get(k) is not None})
|
||||
|
||||
result = {
|
||||
'url': info.get('url') if info else None,
|
||||
'http_headers': (info.get('http_headers') if info else None) or {},
|
||||
'isLive': bool(info.get('is_live')) if info else False,
|
||||
'formats': formats,
|
||||
}
|
||||
|
||||
# The extraction is cached whole, and each caller is served the view it
|
||||
# asked for. A failed extraction (info is None) is cached the same way, so a
|
||||
# video that can't be resolved is attempted once per TTL rather than on
|
||||
# every hover.
|
||||
with _resolve_cache_lock:
|
||||
# Drop expired entries so the cache doesn't grow without bound.
|
||||
for key in [k for k, v in _resolve_cache.items() if v[0] <= now]:
|
||||
_resolve_cache.pop(key, None)
|
||||
_resolve_cache[video_url] = (now + RESOLVE_CACHE_TTL, result)
|
||||
_resolve_cache[video_url] = (now + RESOLVE_CACHE_TTL, info)
|
||||
|
||||
return jsonify(result)
|
||||
return jsonify(view_of(info))
|
||||
|
||||
@app.route('/api/image', methods=['GET', 'HEAD'])
|
||||
def image_proxy():
|
||||
@@ -348,10 +495,38 @@ def image_proxy():
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
# Captures the path *relative to the frontend dir* (the manifest's key), since
|
||||
# the served URL carries an extra `static/` prefix.
|
||||
_ASSET_REF_RE = re.compile(r'(src|href)="static/((?:js|css)/[^"?#]+)"')
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
"""Serve index.html with each local asset URL stamped with its content hash.
|
||||
|
||||
index.html itself is always revalidated, but the assets it names are not
|
||||
under our control once a CDN or a phone has them: Cloudflare rewrites our
|
||||
`no-cache` to `max-age=14400`, and an iOS home-screen app will happily run
|
||||
four-hour-old JavaScript. A content hash in the query gives every deploy new
|
||||
URLs, which no cache can satisfy from an old copy -- so a reload always
|
||||
lands on the build that's actually deployed."""
|
||||
hashes = _version_payload().get('files', {})
|
||||
|
||||
def stamp(match):
|
||||
attr, rel = match.group(1), match.group(2)
|
||||
digest = hashes.get(rel)
|
||||
return f'{attr}="static/{rel}?v={digest}"' if digest else match.group(0)
|
||||
|
||||
try:
|
||||
with open(os.path.join(_FRONTEND_DIR, 'index.html'), encoding='utf-8') as fh:
|
||||
html = _ASSET_REF_RE.sub(stamp, fh.read())
|
||||
except OSError:
|
||||
return send_from_directory(app.static_folder, 'index.html')
|
||||
|
||||
resp = Response(html, mimetype='text/html')
|
||||
resp.headers['Cache-Control'] = 'no-cache, must-revalidate'
|
||||
return resp
|
||||
|
||||
@app.route('/favicon.ico')
|
||||
def favicon():
|
||||
return send_from_directory(app.static_folder, 'favicon.ico')
|
||||
@@ -395,8 +570,7 @@ def _compute_version_payload(files):
|
||||
return {'version': combined.hexdigest(), 'files': file_hashes}
|
||||
|
||||
|
||||
@app.route('/api/version', methods=['GET'])
|
||||
def frontend_version():
|
||||
def _version_payload():
|
||||
files = _scan_frontend_files()
|
||||
# Use the newest mtime across tracked files as a cheap cache key so frequent
|
||||
# polls only re-hash contents when something on disk actually changed.
|
||||
@@ -408,8 +582,12 @@ def frontend_version():
|
||||
if _version_cache['mtime'] != latest_mtime or _version_cache['payload'] is None:
|
||||
_version_cache['payload'] = _compute_version_payload(files)
|
||||
_version_cache['mtime'] = latest_mtime
|
||||
payload = _version_cache['payload']
|
||||
resp = jsonify(payload)
|
||||
return _version_cache['payload']
|
||||
|
||||
|
||||
@app.route('/api/version', methods=['GET'])
|
||||
def frontend_version():
|
||||
resp = jsonify(_version_payload())
|
||||
resp.headers['Cache-Control'] = 'no-store'
|
||||
return resp
|
||||
|
||||
@@ -438,14 +616,21 @@ def stream_video():
|
||||
|
||||
dbg(f"method={request.method} url={video_url} live={live_hint}")
|
||||
|
||||
def media_path(url):
|
||||
# Some sites serve media from a path with a trailing slash
|
||||
# (heavyfetish: /get_file/.../11097_720p.mp4/). Without stripping it,
|
||||
# every extension test below misses and the URL takes the yt-dlp branch
|
||||
# instead -- a full extraction per request, including every seek.
|
||||
return urllib.parse.urlparse(url).path.lower().rstrip('/')
|
||||
|
||||
def is_hls(url):
|
||||
return '.m3u8' in urllib.parse.urlparse(url).path
|
||||
return '.m3u8' in media_path(url)
|
||||
|
||||
def is_dash(url):
|
||||
return urllib.parse.urlparse(url).path.lower().endswith('.mpd')
|
||||
return media_path(url).endswith('.mpd')
|
||||
|
||||
def guess_content_type(url):
|
||||
path = urllib.parse.urlparse(url).path.lower()
|
||||
path = media_path(url)
|
||||
if path.endswith('.m3u8'):
|
||||
return 'application/vnd.apple.mpegurl'
|
||||
if path.endswith('.mpd'):
|
||||
@@ -467,7 +652,7 @@ def stream_video():
|
||||
return None
|
||||
|
||||
def is_direct_media(url):
|
||||
path = urllib.parse.urlparse(url).path.lower()
|
||||
path = media_path(url)
|
||||
return any(path.endswith(ext) for ext in ('.mp4', '.m4v', '.m4s', '.ts', '.webm', '.mov'))
|
||||
|
||||
def looks_like_m3u8_bytes(chunk):
|
||||
@@ -563,7 +748,16 @@ def stream_video():
|
||||
if 'Range' in request.headers:
|
||||
safe_request_headers['Range'] = request.headers['Range']
|
||||
|
||||
resp = get_impersonate_session().get(target_url, headers=safe_request_headers, stream=True, timeout=30, allow_redirects=True)
|
||||
# A HEAD wants headers, not video -- but we don't send a HEAD upstream
|
||||
# here (hotlink-protected origins routinely answer one method and not
|
||||
# the other, and the GET is the one we know works). Ask for a single
|
||||
# byte instead: same headers, none of the transfer. The response is
|
||||
# restated as a description of the whole resource further down.
|
||||
head_probe = request.method == 'HEAD' and 'Range' not in safe_request_headers
|
||||
if head_probe:
|
||||
safe_request_headers['Range'] = 'bytes=0-0'
|
||||
|
||||
resp = impersonate_get(target_url, headers=safe_request_headers, stream=True, timeout=30, allow_redirects=True)
|
||||
# Some channel proxies (e.g. the "animeidhentai" hottub proxy) use
|
||||
# inverted hotlink protection: they 403 any request that carries a
|
||||
# Referer/Origin and only serve referer-less ones. Other CDNs require
|
||||
@@ -572,7 +766,20 @@ def stream_video():
|
||||
dbg("upstream 403 with referer; retrying without referer/origin")
|
||||
resp.close()
|
||||
referer_less = {k: v for k, v in safe_request_headers.items() if k not in ('Referer', 'Origin')}
|
||||
resp = get_impersonate_session().get(target_url, headers=referer_less, stream=True, timeout=30, allow_redirects=True)
|
||||
resp = impersonate_get(target_url, headers=referer_less, stream=True, timeout=30, allow_redirects=True)
|
||||
# Still refused: strip everything the extractor asked us to relay and go
|
||||
# in bare (Range only, plus whatever impersonation supplies). Signed CDN
|
||||
# links are often served fine to a plain browser request and refused when
|
||||
# it carries extras -- a `Sec-Fetch-Mode: navigate` on a media
|
||||
# subresource, say, which is exactly what yt-dlp's generic extractor
|
||||
# hands back and what a real player would never send.
|
||||
if resp.status_code == 403 and len(safe_request_headers) > (1 if 'Range' in safe_request_headers else 0):
|
||||
dbg("upstream still 403; retrying bare (range only)")
|
||||
resp.close()
|
||||
bare = {}
|
||||
if 'Range' in safe_request_headers:
|
||||
bare['Range'] = safe_request_headers['Range']
|
||||
resp = impersonate_get(target_url, headers=bare, stream=True, timeout=30, allow_redirects=True)
|
||||
if debug_enabled:
|
||||
dbg(f"upstream status={resp.status_code} content_type={resp.headers.get('Content-Type')} content_length={resp.headers.get('Content-Length')}")
|
||||
|
||||
@@ -610,8 +817,32 @@ def stream_video():
|
||||
)
|
||||
|
||||
if request.method == 'HEAD':
|
||||
status = resp.status_code
|
||||
# Read from the headers we already copied: curl_cffi doesn't keep a
|
||||
# response's headers readable once it has been closed.
|
||||
content_range = next((value for name, value in forwarded_headers
|
||||
if name.lower() == 'content-range'), '')
|
||||
resp.close()
|
||||
return Response("", status=resp.status_code, headers=forwarded_headers)
|
||||
if head_probe and status == 206:
|
||||
# We asked for one byte; the caller asked about the resource.
|
||||
# Restate the 206 as a 200 describing the whole thing, taking
|
||||
# the real length out of `Content-Range: bytes 0-0/<total>`.
|
||||
# (An origin that ignored the range answered 200 already, and
|
||||
# its headers need no fixing.)
|
||||
match = _CONTENT_RANGE_TOTAL_RE.match(content_range or '')
|
||||
total = match.group(1) if match else None
|
||||
forwarded_headers = [(name, value) for name, value in forwarded_headers
|
||||
if name.lower() not in ('content-range', 'content-length')]
|
||||
head_response = Response("", status=200, headers=forwarded_headers)
|
||||
if total:
|
||||
# A HEAD carries the entity headers its GET would, with no
|
||||
# body -- so the length is the resource's, not the zero
|
||||
# bytes we're sending. Werkzeug derives Content-Length from
|
||||
# the body unless told not to.
|
||||
head_response.automatically_set_content_length = False
|
||||
head_response.headers['Content-Length'] = total
|
||||
return head_response
|
||||
return Response("", status=status, headers=forwarded_headers)
|
||||
|
||||
def generate():
|
||||
try:
|
||||
@@ -685,14 +916,14 @@ def stream_video():
|
||||
for key, value in upstream_headers.items():
|
||||
if value:
|
||||
headers[key] = value
|
||||
resp = get_impersonate_session().get(playlist_url, headers=headers, stream=True, timeout=30)
|
||||
resp = impersonate_get(playlist_url, headers=headers, stream=True, timeout=30)
|
||||
# See proxy_response: retry without referer for inverted hotlink
|
||||
# protection that 403s any refered request.
|
||||
if resp.status_code == 403 and ('Referer' in headers or 'Origin' in headers):
|
||||
dbg("playlist upstream 403 with referer; retrying without referer/origin")
|
||||
resp.close()
|
||||
referer_less = {k: v for k, v in headers.items() if k not in ('Referer', 'Origin')}
|
||||
resp = get_impersonate_session().get(playlist_url, headers=referer_less, stream=True, timeout=30)
|
||||
resp = impersonate_get(playlist_url, headers=referer_less, stream=True, timeout=30)
|
||||
base_url = resp.url
|
||||
|
||||
if resp.status_code >= 400:
|
||||
|
||||
@@ -41,6 +41,13 @@ body {
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
/* No accidental zoom: `manipulation` drops double-tap-to-zoom (the app's own
|
||||
taps are handled in JS anyway) while leaving panning and deliberate
|
||||
pinch-zoom alone, and text-size-adjust stops Safari inflating text of its
|
||||
own accord after a rotation. */
|
||||
touch-action: manipulation;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
body.drawer-open {
|
||||
@@ -391,6 +398,15 @@ body.theme-light .sidebar {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
/* Explanatory line under a control -- and where the import reports back. Not a
|
||||
`label`, so it keeps sentence case and normal letter spacing. */
|
||||
.setting-note {
|
||||
margin: 8px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.setting-label-row label {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
@@ -559,6 +575,38 @@ body.theme-light .input-row input:focus {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.setting-item input[type="range"] {
|
||||
width: 100%;
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
height: 6px;
|
||||
border-radius: 999px;
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border);
|
||||
cursor: pointer;
|
||||
margin: 6px 0;
|
||||
}
|
||||
|
||||
.setting-item input[type="range"]::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-primary);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.setting-item input[type="range"]::-moz-range-thumb {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-primary);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.setting-item select {
|
||||
width: 100%;
|
||||
padding: 9px 12px;
|
||||
@@ -727,6 +775,35 @@ body.theme-light .setting-item select option {
|
||||
font-family: var(--font-display);
|
||||
}
|
||||
|
||||
.favorites-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.favorites-sort {
|
||||
height: 28px;
|
||||
padding: 0 8px;
|
||||
border-radius: var(--radius-sm, 6px);
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.favorites-actions .btn-secondary {
|
||||
height: 28px;
|
||||
padding: 0 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Browsing favorites as a grid: the bar above it would be the same list twice,
|
||||
so it collapses to its header (which carries the way back out). */
|
||||
body.favorites-view-open .favorites-list,
|
||||
body.favorites-view-open .favorites-empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.favorites-list {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
@@ -780,6 +857,8 @@ body.theme-light .setting-item select option {
|
||||
padding: 10px 12px 12px 12px;
|
||||
}
|
||||
|
||||
/* One line, always. A title too long for the card scrolls across it (see
|
||||
App.marquee) rather than wrapping the card to an uneven height. */
|
||||
.favorite-info h4 {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
@@ -787,6 +866,20 @@ body.theme-light .setting-item select option {
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-display);
|
||||
line-height: 1.3;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.favorite-title-text {
|
||||
display: inline-block;
|
||||
padding-right: 24px;
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.favorite-card.is-title-active .favorite-title-text {
|
||||
animation: video-title-marquee var(--marquee-duration, 10s) linear infinite;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.favorites-empty {
|
||||
@@ -798,7 +891,7 @@ body.theme-light .setting-item select option {
|
||||
/* Grid Container */
|
||||
.grid-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
||||
grid-auto-rows: 10px;
|
||||
gap: 16px;
|
||||
align-items: start;
|
||||
@@ -840,6 +933,12 @@ body.theme-light .setting-item select option {
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.grid-container {
|
||||
/* One full-width card per row on phones. */
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 18px;
|
||||
}
|
||||
@@ -866,11 +965,11 @@ body.theme-light .setting-item select option {
|
||||
}
|
||||
|
||||
.video-card h4 {
|
||||
font-size: 16px;
|
||||
font-size: calc(16px * var(--card-font-scale, 1));
|
||||
}
|
||||
|
||||
.video-card p {
|
||||
font-size: 13px;
|
||||
font-size: calc(13px * var(--card-font-scale, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -894,6 +993,26 @@ body.theme-light .setting-item select option {
|
||||
.input-row input {
|
||||
padding: 10px 14px;
|
||||
}
|
||||
|
||||
/* iOS zooms the whole page when you focus a control whose text is under
|
||||
16px, and it ignores user-scalable=no -- so the font size is the only
|
||||
lever that actually stops it. Every text control gets 16px on touch
|
||||
devices; the padding above keeps them looking the same size. */
|
||||
.search-container input,
|
||||
.input-row input,
|
||||
.setting-item select,
|
||||
.cmdk-input,
|
||||
input[type="text"],
|
||||
input[type="search"],
|
||||
input[type="number"],
|
||||
input[type="url"],
|
||||
input[type="email"],
|
||||
input[type="password"],
|
||||
input:not([type]),
|
||||
textarea,
|
||||
select {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
@@ -983,7 +1102,7 @@ body.theme-light .setting-item select option {
|
||||
}
|
||||
|
||||
.video-card h4 {
|
||||
font-size: 15px;
|
||||
font-size: calc(15px * var(--card-font-scale, 1));
|
||||
font-weight: 500;
|
||||
padding: 12px 12px 10px;
|
||||
line-height: 1.3;
|
||||
@@ -1016,7 +1135,7 @@ body.theme-light .setting-item select option {
|
||||
}
|
||||
|
||||
.video-card p {
|
||||
font-size: 12px;
|
||||
font-size: calc(12px * var(--card-font-scale, 1));
|
||||
color: var(--text-secondary);
|
||||
padding: 0 12px 12px 12px;
|
||||
margin: 0;
|
||||
@@ -1034,7 +1153,7 @@ body.theme-light .setting-item select option {
|
||||
}
|
||||
|
||||
.video-tag {
|
||||
font-size: 11px;
|
||||
font-size: calc(11px * var(--card-font-scale, 1));
|
||||
color: var(--text-secondary);
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border);
|
||||
@@ -1284,6 +1403,31 @@ body.theme-light .favorite-btn {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* The panel shows every field the client has, which for a resolved video is the
|
||||
extractor's whole payload -- dozens of rows. Give the list its own scroll so
|
||||
the card stays inside the viewport and the close button stays put. */
|
||||
.info-list {
|
||||
max-height: min(70vh, 620px);
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.info-section {
|
||||
font-family: var(--font-display);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.8px;
|
||||
font-size: 11px;
|
||||
color: var(--text-secondary);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
.info-pending {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -1334,75 +1478,486 @@ body.theme-light .favorite-btn {
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
.modal {
|
||||
/* --- Custom player: single fake-fullscreen state everywhere ------------ */
|
||||
.custom-player {
|
||||
display: none;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: #000;
|
||||
z-index: 2000;
|
||||
z-index: 3000;
|
||||
touch-action: none;
|
||||
transition: transform 0.25s ease, opacity 0.25s ease;
|
||||
}
|
||||
|
||||
body.theme-light .modal {
|
||||
background: #0b0b0b;
|
||||
.custom-player.open {
|
||||
display: block;
|
||||
animation: cp-open 0.22s ease;
|
||||
}
|
||||
|
||||
.modal.open {
|
||||
display: flex;
|
||||
@keyframes cp-open {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
.cp-surface {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
|
||||
/* Ambient backdrop: a blurred copy of the poster fills any letterbox bars
|
||||
behind the contained video (set via the --poster custom property). */
|
||||
.cp-surface::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-image: var(--poster);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
filter: blur(60px) saturate(1.3) brightness(0.5);
|
||||
transform: scale(1.25);
|
||||
opacity: 0.55;
|
||||
z-index: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cp-video {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.cp-flash {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
padding: 8px 18px;
|
||||
border-radius: 999px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.cp-flash.is-visible {
|
||||
animation: cp-flash-fade 0.7s ease forwards;
|
||||
}
|
||||
|
||||
@keyframes cp-flash-fade {
|
||||
0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
||||
100% { opacity: 0; transform: translate(-50%, -50%) scale(1.08); }
|
||||
}
|
||||
|
||||
.cp-spinner {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.15s ease;
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
.cp-spinner.is-visible {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.cp-spinner-ring {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 50%;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: var(--accent);
|
||||
animation: cp-spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes cp-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.cp-error {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
gap: 12px;
|
||||
padding: 20px 24px;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
border-radius: var(--radius-lg);
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
max-width: min(360px, 80vw);
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.close {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
color: #fff;
|
||||
font-size: 32px;
|
||||
.cp-error-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.cp-retry-btn,
|
||||
.cp-open-btn {
|
||||
padding: 8px 20px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--accent);
|
||||
background: transparent;
|
||||
color: var(--accent);
|
||||
cursor: pointer;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
border: none;
|
||||
font: inherit;
|
||||
text-decoration: none;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.cp-retry-btn:hover,
|
||||
.cp-open-btn:hover {
|
||||
background: rgba(201, 165, 103, 0.15);
|
||||
}
|
||||
|
||||
.cp-open-btn[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cp-replay-btn {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 50%;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border: none;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 2001;
|
||||
transition: all 0.2s ease;
|
||||
cursor: pointer;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.close:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
.cp-replay-btn .icon-svg {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
filter: invert(1);
|
||||
}
|
||||
|
||||
video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 100vh;
|
||||
object-fit: contain;
|
||||
.cp-hud {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
pointer-events: none;
|
||||
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 18%, transparent 78%, rgba(0, 0, 0, 0.6));
|
||||
opacity: 1;
|
||||
transition: opacity 0.3s ease;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
#mobile-video-host {
|
||||
position: fixed;
|
||||
left: -9999px;
|
||||
top: 0;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
.custom-player.cp-hud-idle .cp-hud {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.cp-hud * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.cp-top-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: max(14px, env(safe-area-inset-top)) 16px 0;
|
||||
}
|
||||
|
||||
.cp-close-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
flex-shrink: 0;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cp-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
font-size: 16px;
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.cp-title-text {
|
||||
display: inline-block;
|
||||
padding-right: 24px;
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.cp-title.has-marquee .cp-title-text {
|
||||
animation: video-title-marquee var(--marquee-duration, 10s) linear infinite;
|
||||
}
|
||||
|
||||
.cp-fav-btn {
|
||||
position: static;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.cp-bottom-bar {
|
||||
padding: 0 16px max(14px, env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.custom-player.is-live .cp-timeline,
|
||||
.custom-player.is-live .cp-skip-back-btn,
|
||||
.custom-player.is-live .cp-skip-fwd-btn {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cp-timeline {
|
||||
padding: 10px 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cp-timeline-track {
|
||||
position: relative;
|
||||
height: 4px;
|
||||
border-radius: 2px;
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.cp-timeline-buffered {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 0%;
|
||||
border-radius: 2px;
|
||||
background: rgba(255, 255, 255, 0.35);
|
||||
}
|
||||
|
||||
.cp-timeline-fill {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 0%;
|
||||
border-radius: 2px;
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.cp-timeline-handle {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 0%;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent);
|
||||
transform: translate(-50%, -50%) scale(0.7);
|
||||
transition: transform 0.15s ease;
|
||||
}
|
||||
|
||||
.cp-timeline:hover .cp-timeline-handle,
|
||||
.cp-timeline.is-scrubbing .cp-timeline-handle {
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
}
|
||||
|
||||
.cp-time-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.cp-time {
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
flex-shrink: 0;
|
||||
min-width: 34px;
|
||||
}
|
||||
|
||||
.cp-time-duration {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.cp-transport {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.cp-transport button {
|
||||
position: relative;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cp-play-btn {
|
||||
width: 48px !important;
|
||||
height: 48px !important;
|
||||
background: rgba(255, 255, 255, 0.12) !important;
|
||||
}
|
||||
|
||||
.cp-play-btn .icon-svg {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
.cp-skip-back-btn .icon-svg,
|
||||
.cp-skip-fwd-btn .icon-svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.cp-skip-amount {
|
||||
position: absolute;
|
||||
bottom: 2px;
|
||||
font-size: 9px;
|
||||
font-weight: 600;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border-radius: 6px;
|
||||
padding: 0 3px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cp-secondary-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.cp-mute-btn,
|
||||
.cp-pip-btn {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cp-mute-btn .icon-svg,
|
||||
.cp-pip-btn .icon-svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.cp-volume-range {
|
||||
width: 64px;
|
||||
accent-color: var(--accent);
|
||||
}
|
||||
|
||||
.cp-format-btn {
|
||||
height: 26px;
|
||||
padding: 0 8px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.35);
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
color: #fff;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cp-format-menu {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
bottom: 64px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: rgba(20, 17, 13, 0.92);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
overflow: hidden;
|
||||
z-index: 6;
|
||||
max-height: 40vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.cp-format-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 9px 18px 9px 14px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* A fixed-width tick column so every label starts on the same x, with only
|
||||
the playing format's tick actually inked. */
|
||||
.cp-format-option::before {
|
||||
content: '\2713';
|
||||
width: 1em;
|
||||
flex: none;
|
||||
opacity: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.cp-format-option:hover {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.cp-format-option.is-active {
|
||||
color: var(--accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.cp-format-option.is-active::before {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* `.cp-error`/`.cp-replay-btn`/`.cp-format-menu` above set `display` on the
|
||||
bare class so JS can toggle visibility via the `hidden` attribute alone;
|
||||
these higher-specificity overrides keep that attribute effective (an
|
||||
unconditional `display` on the class would otherwise beat the UA
|
||||
`[hidden] { display: none }` rule). */
|
||||
.cp-error[hidden],
|
||||
.cp-replay-btn[hidden],
|
||||
.cp-format-menu[hidden],
|
||||
.cp-pip-btn[hidden],
|
||||
.favorite-btn[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.cp-title { font-size: 14px; }
|
||||
.cp-volume-range { display: none; }
|
||||
}
|
||||
|
||||
.error-toast {
|
||||
position: fixed;
|
||||
right: 20px;
|
||||
@@ -1648,7 +2203,7 @@ body.feed-mode-open .mode-toggle-btn .icon-svg {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.feed-title.is-marquee .feed-title-text {
|
||||
.feed-title.has-marquee .feed-title-text {
|
||||
animation: video-title-marquee var(--marquee-duration, 10s) linear infinite;
|
||||
will-change: transform;
|
||||
}
|
||||
@@ -1776,6 +2331,38 @@ body.feed-mode-open .mode-toggle-btn .icon-svg {
|
||||
background: rgba(255, 59, 48, 0.18);
|
||||
}
|
||||
|
||||
/* Reels HUD right rail additions: PiP + quality, stacked above favorite. */
|
||||
.feed-pip-btn {
|
||||
position: absolute;
|
||||
right: 24px;
|
||||
bottom: 266px;
|
||||
z-index: 6;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
border: 1px solid rgba(255, 255, 255, 0.18);
|
||||
transition: background 0.2s ease, opacity 0.4s ease;
|
||||
}
|
||||
|
||||
.feed-pip-btn .icon-svg {
|
||||
filter: invert(100%) saturate(0%);
|
||||
}
|
||||
|
||||
.feed-format-btn {
|
||||
position: absolute;
|
||||
right: 24px;
|
||||
bottom: 322px;
|
||||
z-index: 6;
|
||||
transition: opacity 0.4s ease;
|
||||
}
|
||||
|
||||
.feed-format-menu {
|
||||
right: 76px;
|
||||
bottom: 322px;
|
||||
}
|
||||
|
||||
.feed-flash {
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
/* Reels/TikTok mode: HUD auto-hides after a short idle. Elements stay
|
||||
interactive (pointer-events untouched) so the buttons keep working while
|
||||
invisible; any pointer/scroll activity reveals them again (see App.feed). */
|
||||
@@ -1783,6 +2370,8 @@ body.feed-hud-idle .feed-info,
|
||||
body.feed-hud-idle .feed-timeline,
|
||||
body.feed-hud-idle .feed-mute-btn,
|
||||
body.feed-hud-idle .feed-fav-btn,
|
||||
body.feed-hud-idle .feed-pip-btn,
|
||||
body.feed-hud-idle .feed-format-btn,
|
||||
body.feed-hud-idle .mode-toggle-btn {
|
||||
opacity: 0;
|
||||
}
|
||||
@@ -2017,26 +2606,6 @@ body.theme-light .video-card img:not(.is-loaded) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* --- Player ambient backdrop: blurred poster behind the video --------- */
|
||||
.modal-content::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-image: var(--poster);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
filter: blur(60px) saturate(1.3) brightness(0.5);
|
||||
transform: scale(1.25);
|
||||
opacity: 0.55;
|
||||
z-index: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.modal-content > * {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* --- Reels HUD polish: serif title + brass scrubber + mute pulse ------- */
|
||||
.feed-title { font-family: var(--font-display); }
|
||||
|
||||
@@ -2058,10 +2627,3 @@ body.theme-light .video-card img:not(.is-loaded) {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* --- View Transition timing (player open/close crossfade) -------------- */
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
::view-transition-old(root),
|
||||
::view-transition-new(root) {
|
||||
animation-duration: 0.32s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
<section id="favorites-bar" class="favorites-bar" aria-label="Favorites">
|
||||
<div class="favorites-header">
|
||||
<h3>Favorites</h3>
|
||||
<div class="favorites-actions">
|
||||
<select id="favorites-sort" class="favorites-sort" aria-label="Sort favorites"></select>
|
||||
<button id="favorites-browse-btn" class="btn-secondary" type="button" aria-pressed="false">Browse all</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="favorites-list" class="favorites-list"></div>
|
||||
<div id="favorites-empty" class="favorites-empty">No favorites yet. Tap the heart on a video to save it here.</div>
|
||||
@@ -98,6 +102,14 @@
|
||||
<option value="compact">Compact</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<label for="card-size-range">Card Size</label>
|
||||
<input type="range" id="card-size-range" min="0.7" max="1.5" step="0.1" value="1">
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<label for="text-size-range">Text Size</label>
|
||||
<input type="range" id="text-size-range" min="0.8" max="1.4" step="0.1" value="1">
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<label for="feed-end-select">Reels: On Video End</label>
|
||||
<select id="feed-end-select">
|
||||
@@ -125,6 +137,17 @@
|
||||
</div>
|
||||
<div id="sources-list" class="sources-list"></div>
|
||||
</div>
|
||||
<div class="sidebar-section">
|
||||
<h4 class="sidebar-subtitle">Hot Tub Backup</h4>
|
||||
<div class="setting-item">
|
||||
<label for="import-favorites-btn">Import Favorites</label>
|
||||
<input id="import-favorites-file" type="file" accept=".sqlite3,.sqlite,.db" hidden>
|
||||
<button id="import-favorites-btn" class="btn-secondary" type="button">Choose backup file…</button>
|
||||
<p id="import-favorites-status" class="setting-note" role="status" aria-live="polite">
|
||||
Reads the favorites out of an exported Hot Tub database. The file stays on this device.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
@@ -134,12 +157,7 @@
|
||||
<img class="icon-svg" src="https://cdn.jsdelivr.net/npm/heroicons@2.0.13/24/outline/chevron-down.svg" alt="Load More">
|
||||
</button>
|
||||
|
||||
<div id="video-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<span class="close" onclick="closePlayer()">×</span>
|
||||
<video id="player" controls autoplay playsinline webkit-playsinline></video>
|
||||
</div>
|
||||
</div>
|
||||
<div id="custom-player" class="custom-player" aria-hidden="true"></div>
|
||||
|
||||
<button id="mode-toggle-btn" class="mode-toggle-btn" type="button" title="Switch to Reels view" aria-pressed="false">
|
||||
<img class="icon-svg" id="mode-toggle-icon" src="https://cdn.jsdelivr.net/npm/heroicons@2.0.13/24/outline/device-phone-mobile.svg" alt="Switch to Reels view">
|
||||
@@ -184,9 +202,14 @@
|
||||
</div>
|
||||
|
||||
<script src="static/js/state.js"></script>
|
||||
<script src="static/js/marquee.js"></script>
|
||||
<script src="static/js/storage.js"></script>
|
||||
<script src="static/js/customPlayer.js"></script>
|
||||
<script src="static/js/player.js"></script>
|
||||
<script src="static/js/favorites.js"></script>
|
||||
<script src="static/js/favoritesView.js"></script>
|
||||
<script src="static/js/sqlite.js"></script>
|
||||
<script src="static/js/hottubBackup.js"></script>
|
||||
<script src="static/js/videos.js"></script>
|
||||
<script src="static/js/feed.js"></script>
|
||||
<script src="static/js/ui.js"></script>
|
||||
|
||||
338
frontend/js/customPlayer.js
Normal file
338
frontend/js/customPlayer.js
Normal file
@@ -0,0 +1,338 @@
|
||||
window.App = window.App || {};
|
||||
App.customPlayer = App.customPlayer || {};
|
||||
|
||||
// Shared building blocks for the custom video player HUD, reused by the
|
||||
// standalone fullscreen player (player.js) and the reels feed (feed.js) so
|
||||
// both present identical skip/format/gesture/PiP behavior.
|
||||
(function() {
|
||||
// -----------------------------------------------------------------
|
||||
// Skip escalation: tapping skip-forward/back repeatedly ramps the skip
|
||||
// duration up (5 -> 10 -> 20 -> 40 -> 60s), independently per direction,
|
||||
// so mashing forward doesn't also ramp up backward. A tap lands as
|
||||
// "rapid" (and escalates further) only if it arrives within
|
||||
// RAPID_WINDOW_MS of the previous same-direction tap. After GRACE_MS of
|
||||
// silence the level steps back down by one every DECAY_STEP_MS.
|
||||
// -----------------------------------------------------------------
|
||||
const LEVELS = [5, 10, 20, 40, 60];
|
||||
const RAPID_WINDOW_MS = 1500;
|
||||
const GRACE_MS = 2000;
|
||||
const DECAY_STEP_MS = 1000;
|
||||
|
||||
App.customPlayer.createSkipEscalator = function() {
|
||||
const dirs = {
|
||||
back: { levelIndex: 0, lastTapAt: 0, decayTimer: null },
|
||||
forward: { levelIndex: 0, lastTapAt: 0, decayTimer: null }
|
||||
};
|
||||
|
||||
const clearDecay = (d) => {
|
||||
if (d.decayTimer) {
|
||||
clearTimeout(d.decayTimer);
|
||||
d.decayTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
const scheduleDecay = (d) => {
|
||||
clearDecay(d);
|
||||
d.decayTimer = setTimeout(function tick() {
|
||||
d.decayTimer = null;
|
||||
if (d.levelIndex > 0) {
|
||||
d.levelIndex -= 1;
|
||||
d.decayTimer = setTimeout(tick, DECAY_STEP_MS);
|
||||
}
|
||||
}, GRACE_MS);
|
||||
};
|
||||
|
||||
// Advances the state for a tap in `direction` and returns the number
|
||||
// of seconds that tap should skip.
|
||||
const trigger = function(direction) {
|
||||
const d = dirs[direction];
|
||||
if (!d) return LEVELS[0];
|
||||
const now = Date.now();
|
||||
if (now - d.lastTapAt <= RAPID_WINDOW_MS && d.levelIndex < LEVELS.length - 1) {
|
||||
d.levelIndex += 1;
|
||||
}
|
||||
d.lastTapAt = now;
|
||||
scheduleDecay(d);
|
||||
return LEVELS[d.levelIndex];
|
||||
};
|
||||
|
||||
const destroy = function() {
|
||||
clearDecay(dirs.back);
|
||||
clearDecay(dirs.forward);
|
||||
};
|
||||
|
||||
return { trigger, destroy };
|
||||
};
|
||||
|
||||
// Applies one skip tap to `video` using `escalator`, clamped to the
|
||||
// media's bounds. Returns the number of seconds skipped (for HUD flash
|
||||
// feedback), or 0 if the video has no usable duration yet.
|
||||
App.customPlayer.skip = function(video, direction, escalator) {
|
||||
if (!video) return 0;
|
||||
const amount = escalator.trigger(direction);
|
||||
const delta = direction === 'forward' ? amount : -amount;
|
||||
let target = video.currentTime + delta;
|
||||
if (isFinite(video.duration) && video.duration > 0) {
|
||||
target = Math.min(target, Math.max(0, video.duration - 0.1));
|
||||
}
|
||||
video.currentTime = Math.max(0, target);
|
||||
return amount;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Format switching: builds a labeled, ranked list of a video's playable
|
||||
// formats (quality/codec/container variants) for a picker menu. Reuses
|
||||
// App.videos.rankFormats (same ranking as automatic selection) with no
|
||||
// preferred-height ceiling, since a manual pick overrides that entirely.
|
||||
// -----------------------------------------------------------------
|
||||
App.customPlayer.formatLabel = function(fmt) {
|
||||
if (!fmt) return 'Auto';
|
||||
const parts = [];
|
||||
const height = App.videos.coerceNumber(fmt.height);
|
||||
const fps = App.videos.coerceNumber(fmt.fps);
|
||||
if (height) parts.push(`${height}p${fps > 30 ? Math.round(fps) : ''}`);
|
||||
// The container (mp4/webm) tells the viewer nothing useful about a
|
||||
// quality choice. The extractor's own note does -- but only when it
|
||||
// says something the quality doesn't already ("HDR", "source", a
|
||||
// codec), so drop one that merely restates it ("1080p", "1080p60").
|
||||
const note = (fmt.format_note || '').toString().trim();
|
||||
if (note && note.toLowerCase() !== (parts[0] || '').toLowerCase()) parts.push(note);
|
||||
if (!parts.length) {
|
||||
const vcodec = (fmt.vcodec || '').toString();
|
||||
parts.push(vcodec && vcodec !== 'none' ? vcodec : 'Auto');
|
||||
}
|
||||
return parts.join(' ');
|
||||
};
|
||||
|
||||
// Returns [] when there's nothing to pick from (no formats, or only one
|
||||
// usable variant) so callers know to hide the format-switch button.
|
||||
App.customPlayer.buildFormatOptions = function(video) {
|
||||
const meta = video && (video.meta || video);
|
||||
if (!meta || !Array.isArray(meta.formats) || meta.formats.length < 2) return [];
|
||||
const ranked = App.videos.rankFormats(meta.formats, null);
|
||||
if (ranked.length < 2) return [];
|
||||
return ranked.map((fmt) => ({ fmt, label: App.customPlayer.formatLabel(fmt) }));
|
||||
};
|
||||
|
||||
// Wires a format-switch button + its dropdown menu against `videoData`,
|
||||
// calling onSelect(fmt) when the user picks one. Hides the button when
|
||||
// there's nothing to pick from. Shared by the standalone player and the
|
||||
// reels feed so both present an identical menu. Returns a destroy() fn.
|
||||
// `options.getCurrentUrl` (optional) returns the URL the player is actually
|
||||
// feeding to the media element right now; the matching entry is marked
|
||||
// active every time the menu opens. Reading it live rather than at bind
|
||||
// time keeps the mark honest when playback moved on by itself -- an
|
||||
// automatic pick, a fallback to the next candidate after a failure, or a
|
||||
// re-resolve -- not just when the viewer chose from this menu.
|
||||
App.customPlayer.bindFormatMenu = function(btn, menu, videoData, onSelect, opts) {
|
||||
if (!btn || !menu) return function destroy() {};
|
||||
const getCurrentUrl = (opts && opts.getCurrentUrl) || null;
|
||||
const options = App.customPlayer.buildFormatOptions(videoData);
|
||||
if (!options.length) {
|
||||
btn.hidden = true;
|
||||
menu.hidden = true;
|
||||
menu.innerHTML = '';
|
||||
return function destroy() {};
|
||||
}
|
||||
btn.hidden = false;
|
||||
menu.hidden = true;
|
||||
menu.innerHTML = options.map((opt, i) =>
|
||||
`<button class="cp-format-option" type="button" role="menuitemradio" aria-checked="false" data-index="${i}">${opt.label}</button>`
|
||||
).join('');
|
||||
const markActive = (activeBtn) => {
|
||||
menu.querySelectorAll('.cp-format-option').forEach((b) => {
|
||||
const isActive = b === activeBtn;
|
||||
b.classList.toggle('is-active', isActive);
|
||||
b.setAttribute('aria-checked', isActive ? 'true' : 'false');
|
||||
});
|
||||
};
|
||||
const syncActive = () => {
|
||||
const current = getCurrentUrl ? (getCurrentUrl() || '') : '';
|
||||
let match = null;
|
||||
if (current) {
|
||||
options.forEach((opt, i) => {
|
||||
if (!match && opt.fmt && opt.fmt.url === current) {
|
||||
match = menu.querySelector(`.cp-format-option[data-index="${i}"]`);
|
||||
}
|
||||
});
|
||||
}
|
||||
markActive(match);
|
||||
};
|
||||
const cleanups = [];
|
||||
menu.querySelectorAll('.cp-format-option').forEach((optBtn) => {
|
||||
const onClick = (event) => {
|
||||
event.stopPropagation();
|
||||
const idx = parseInt(optBtn.dataset.index, 10);
|
||||
const opt = options[idx];
|
||||
menu.hidden = true;
|
||||
markActive(optBtn);
|
||||
if (opt) onSelect(opt.fmt);
|
||||
};
|
||||
optBtn.addEventListener('click', onClick);
|
||||
cleanups.push(() => optBtn.removeEventListener('click', onClick));
|
||||
});
|
||||
const onBtnClick = (event) => {
|
||||
event.stopPropagation();
|
||||
if (menu.hidden) {
|
||||
syncActive();
|
||||
// Opening the menu restarts the HUD's idle countdown: the menu
|
||||
// hides with the HUD, and the viewer needs the full window to
|
||||
// read the list, not whatever was left of the previous one.
|
||||
if (opts && opts.onOpen) opts.onOpen();
|
||||
}
|
||||
menu.hidden = !menu.hidden;
|
||||
};
|
||||
btn.addEventListener('click', onBtnClick);
|
||||
cleanups.push(() => btn.removeEventListener('click', onBtnClick));
|
||||
return function destroy() {
|
||||
cleanups.forEach((fn) => fn());
|
||||
};
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Picture-in-Picture: a manual toggle plus best-effort auto-PiP when the
|
||||
// tab/app is backgrounded while a video is playing (Safari does this
|
||||
// natively for inline video; Chrome/Android need an explicit call).
|
||||
// -----------------------------------------------------------------
|
||||
App.customPlayer.supportsPiP = function() {
|
||||
return !!(document.pictureInPictureEnabled);
|
||||
};
|
||||
|
||||
App.customPlayer.togglePiP = async function(video) {
|
||||
if (!video || !document.pictureInPictureEnabled || video.disablePictureInPicture) return false;
|
||||
try {
|
||||
if (document.pictureInPictureElement === video) {
|
||||
await document.exitPictureInPicture();
|
||||
} else {
|
||||
await video.requestPictureInPicture();
|
||||
}
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
App.customPlayer.bindAutoPiP = function(video) {
|
||||
if (!video) return function destroy() {};
|
||||
const trigger = () => {
|
||||
if (document.visibilityState !== 'hidden') return;
|
||||
if (!document.pictureInPictureEnabled || video.disablePictureInPicture) return;
|
||||
if (document.pictureInPictureElement) return;
|
||||
if (video.paused || video.ended) return;
|
||||
video.requestPictureInPicture().catch(() => {});
|
||||
};
|
||||
document.addEventListener('visibilitychange', trigger);
|
||||
window.addEventListener('pagehide', trigger);
|
||||
return function destroy() {
|
||||
document.removeEventListener('visibilitychange', trigger);
|
||||
window.removeEventListener('pagehide', trigger);
|
||||
};
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Unified pointer-gesture recognizer for the video surface: a single
|
||||
// pointer stream is classified into exactly one of tap / double-tap /
|
||||
// volume-drag (right column) / dismiss-drag (top strip), so the gestures
|
||||
// never fight each other over the same touch.
|
||||
// -----------------------------------------------------------------
|
||||
App.customPlayer.attachGestures = function(surfaceEl, handlers) {
|
||||
handlers = handlers || {};
|
||||
const TAP_MAX_MOVE = 10;
|
||||
const DOUBLE_TAP_MS = 300;
|
||||
const DISMISS_ZONE_FRACTION = 0.2; // top strip that owns swipe-to-dismiss
|
||||
const VOLUME_ZONE_START = 0.66; // right column that owns volume swipe
|
||||
const SKIP_ZONE_LEFT_END = 0.34;
|
||||
const SKIP_ZONE_RIGHT_START = 0.66;
|
||||
|
||||
let pointerId = null;
|
||||
let startX = 0, startY = 0, lastY = 0;
|
||||
let moved = false;
|
||||
let mode = null; // 'dismiss-candidate' | 'dismiss' | 'volume-candidate' | 'volume' | 'ignore'
|
||||
let volumeStartValue = 0;
|
||||
let lastTapTime = 0;
|
||||
let lastTapSide = null;
|
||||
|
||||
const rectOf = () => surfaceEl.getBoundingClientRect();
|
||||
|
||||
const ignoreSelector = handlers.ignoreSelector || 'button, input, a, .cp-format-menu';
|
||||
|
||||
const onPointerDown = (e) => {
|
||||
if (pointerId != null || e.button != null && e.button !== 0) return;
|
||||
if (e.target && e.target.closest && e.target.closest(ignoreSelector)) return;
|
||||
pointerId = e.pointerId;
|
||||
startX = e.clientX;
|
||||
startY = lastY = e.clientY;
|
||||
moved = false;
|
||||
mode = null;
|
||||
const rect = rectOf();
|
||||
const relX = rect.width ? (e.clientX - rect.left) / rect.width : 0;
|
||||
const relY = rect.height ? (e.clientY - rect.top) / rect.height : 0;
|
||||
if (relY <= DISMISS_ZONE_FRACTION && handlers.onDismissDrag) {
|
||||
mode = 'dismiss-candidate';
|
||||
} else if (relX >= VOLUME_ZONE_START && handlers.onVolumeDrag) {
|
||||
mode = 'volume-candidate';
|
||||
volumeStartValue = handlers.onVolumeStart ? handlers.onVolumeStart() : 0;
|
||||
}
|
||||
try { surfaceEl.setPointerCapture(e.pointerId); } catch (err) { /* ignore */ }
|
||||
};
|
||||
|
||||
const onPointerMove = (e) => {
|
||||
if (e.pointerId !== pointerId) return;
|
||||
const dx = e.clientX - startX;
|
||||
const dy = e.clientY - startY;
|
||||
if (!moved && Math.hypot(dx, dy) > TAP_MAX_MOVE) moved = true;
|
||||
if (moved) {
|
||||
if (mode === 'dismiss-candidate') mode = 'dismiss';
|
||||
else if (mode === 'volume-candidate') mode = 'volume';
|
||||
else if (mode === null) mode = 'ignore';
|
||||
|
||||
if (mode === 'dismiss') {
|
||||
handlers.onDismissDrag(dy, rectOf());
|
||||
} else if (mode === 'volume') {
|
||||
const rect = rectOf();
|
||||
const deltaRatio = rect.height ? (startY - e.clientY) / rect.height : 0;
|
||||
handlers.onVolumeDrag(Math.min(1, Math.max(0, volumeStartValue + deltaRatio)));
|
||||
}
|
||||
}
|
||||
lastY = e.clientY;
|
||||
};
|
||||
|
||||
const endGesture = (e) => {
|
||||
if (e.pointerId !== pointerId) return;
|
||||
try { surfaceEl.releasePointerCapture(e.pointerId); } catch (err) { /* ignore */ }
|
||||
if (moved) {
|
||||
if (mode === 'dismiss' && handlers.onDismissEnd) handlers.onDismissEnd(lastY - startY);
|
||||
else if (mode === 'volume' && handlers.onVolumeEnd) handlers.onVolumeEnd();
|
||||
} else {
|
||||
if (handlers.onSingleTap) handlers.onSingleTap();
|
||||
const rect = rectOf();
|
||||
const relX = rect.width ? (startX - rect.left) / rect.width : 0.5;
|
||||
const side = relX <= SKIP_ZONE_LEFT_END ? 'left' : (relX >= SKIP_ZONE_RIGHT_START ? 'right' : 'center');
|
||||
const now = Date.now();
|
||||
if (side !== 'center' && lastTapSide === side && (now - lastTapTime) <= DOUBLE_TAP_MS) {
|
||||
lastTapTime = 0;
|
||||
lastTapSide = null;
|
||||
if (side === 'left' && handlers.onDoubleTapLeft) handlers.onDoubleTapLeft();
|
||||
if (side === 'right' && handlers.onDoubleTapRight) handlers.onDoubleTapRight();
|
||||
} else {
|
||||
lastTapTime = now;
|
||||
lastTapSide = side;
|
||||
}
|
||||
}
|
||||
pointerId = null;
|
||||
mode = null;
|
||||
};
|
||||
|
||||
surfaceEl.addEventListener('pointerdown', onPointerDown);
|
||||
surfaceEl.addEventListener('pointermove', onPointerMove);
|
||||
surfaceEl.addEventListener('pointerup', endGesture);
|
||||
surfaceEl.addEventListener('pointercancel', endGesture);
|
||||
|
||||
return function destroy() {
|
||||
surfaceEl.removeEventListener('pointerdown', onPointerDown);
|
||||
surfaceEl.removeEventListener('pointermove', onPointerMove);
|
||||
surfaceEl.removeEventListener('pointerup', endGesture);
|
||||
surfaceEl.removeEventListener('pointercancel', endGesture);
|
||||
};
|
||||
};
|
||||
})();
|
||||
@@ -79,7 +79,7 @@ App.enhance = App.enhance || {};
|
||||
const ready = meta && Array.isArray(meta.formats) && meta.formats.length;
|
||||
if (!ready) {
|
||||
// Not resolved yet: kick it off so the *next* hover can preview.
|
||||
if (typeof App.videos.resolveAndProbe === 'function') App.videos.resolveAndProbe(v);
|
||||
if (typeof App.videos.ensureFormats === 'function') App.videos.ensureFormats(v);
|
||||
return;
|
||||
}
|
||||
let url = '';
|
||||
@@ -151,6 +151,26 @@ App.enhance = App.enhance || {};
|
||||
if (App.virtualGrid && App.virtualGrid.relayout) App.virtualGrid.relayout();
|
||||
}});
|
||||
out.push({ label: 'Toggle Reels view', hint: 'Playback', run: () => { if (App.feed) App.feed.toggle(); } });
|
||||
|
||||
// The favorites bar carries these controls, but it can be switched
|
||||
// off in settings -- in which case the palette is the way in.
|
||||
if (App.favoritesView && App.favorites) {
|
||||
const browsing = App.favoritesView.isActive();
|
||||
out.push({
|
||||
label: browsing ? 'Back to videos' : 'Browse favorites',
|
||||
hint: browsing ? 'Leave the favorites grid' : 'All favorites as a grid',
|
||||
run: () => App.favoritesView.toggle()
|
||||
});
|
||||
const currentSort = App.favorites.getSort();
|
||||
App.favorites.SORTS.forEach((sort) => {
|
||||
if (sort.id === currentSort) return;
|
||||
out.push({
|
||||
label: `Sort favorites: ${sort.label}`,
|
||||
hint: 'Favorites',
|
||||
run: () => App.favoritesView.applySort(sort.id)
|
||||
});
|
||||
});
|
||||
}
|
||||
out.push({ label: 'Reload channel', hint: 'Refresh the current feed', run: () => { if (App.videos) App.videos.resetAndReload(); } });
|
||||
out.push({ label: 'Open Menu', hint: 'Source · channel · filters', run: () => { if (App.ui) App.ui.toggleDrawer('menu'); } });
|
||||
out.push({ label: 'Open Settings', hint: 'Preferences', run: () => { if (App.ui) App.ui.toggleDrawer('settings'); } });
|
||||
|
||||
@@ -9,12 +9,83 @@ App.favorites = App.favorites || {};
|
||||
try {
|
||||
const raw = localStorage.getItem(FAVORITES_KEY);
|
||||
const parsed = raw ? JSON.parse(raw) : [];
|
||||
return Array.isArray(parsed) ? parsed : [];
|
||||
if (!Array.isArray(parsed)) return [];
|
||||
// Two things are repaired on the way in, and written back once if
|
||||
// anything changed, so the fix happens exactly one time:
|
||||
//
|
||||
// `meta`, from older versions, is a blob of resolved formats whose
|
||||
// URLs are signed and long expired -- dropped so no code path can
|
||||
// reach for one; everything re-resolves from `url` at play time.
|
||||
//
|
||||
// `favoriteDate` didn't exist before sorting needed it. There's no
|
||||
// way to recover when an old favorite was actually saved, so it
|
||||
// gets now: they sort together, as one batch, at the point the
|
||||
// client learned to keep dates.
|
||||
let repaired = false;
|
||||
const now = new Date().toISOString();
|
||||
const items = parsed.map((item) => {
|
||||
if (!item || typeof item !== 'object') return item;
|
||||
if (!item.meta && item.favoriteDate) return item;
|
||||
const clean = Object.assign({}, item);
|
||||
delete clean.meta;
|
||||
if (!clean.favoriteDate) clean.favoriteDate = now;
|
||||
repaired = true;
|
||||
return clean;
|
||||
});
|
||||
if (repaired) App.favorites.setAll(items);
|
||||
return items;
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
// Sort orders offered for the favorites bar and the favorites grid.
|
||||
// `random` reshuffles on every read by design -- it's for rediscovering a
|
||||
// long list, so landing somewhere different each time is the point.
|
||||
App.favorites.SORTS = [
|
||||
{ id: 'recent', label: 'Recently added' },
|
||||
{ id: 'oldest', label: 'Oldest first' },
|
||||
{ id: 'title', label: 'Title A-Z' },
|
||||
{ id: 'longest', label: 'Longest' },
|
||||
{ id: 'shortest', label: 'Shortest' },
|
||||
{ id: 'random', label: 'Shuffle' }
|
||||
];
|
||||
App.favorites.DEFAULT_SORT = 'recent';
|
||||
|
||||
App.favorites.getSort = function() {
|
||||
const stored = localStorage.getItem(App.constants.FAVORITES_SORT_KEY);
|
||||
return App.favorites.SORTS.some((sort) => sort.id === stored) ? stored : App.favorites.DEFAULT_SORT;
|
||||
};
|
||||
|
||||
App.favorites.setSort = function(sort) {
|
||||
localStorage.setItem(App.constants.FAVORITES_SORT_KEY, sort);
|
||||
};
|
||||
|
||||
const dateValue = function(item) {
|
||||
const parsed = Date.parse((item && item.favoriteDate) || '');
|
||||
return isNaN(parsed) ? 0 : parsed;
|
||||
};
|
||||
|
||||
App.favorites.sorted = function(sort) {
|
||||
const items = App.favorites.getAll();
|
||||
const mode = sort || App.favorites.getSort();
|
||||
if (mode === 'random') {
|
||||
for (let i = items.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[items[i], items[j]] = [items[j], items[i]];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
const comparators = {
|
||||
recent: (a, b) => dateValue(b) - dateValue(a),
|
||||
oldest: (a, b) => dateValue(a) - dateValue(b),
|
||||
title: (a, b) => String(a.title || '').localeCompare(String(b.title || ''), undefined, { sensitivity: 'base' }),
|
||||
longest: (a, b) => (Number(b.duration) || 0) - (Number(a.duration) || 0),
|
||||
shortest: (a, b) => (Number(a.duration) || 0) - (Number(b.duration) || 0)
|
||||
};
|
||||
return items.sort(comparators[mode] || comparators.recent);
|
||||
};
|
||||
|
||||
App.favorites.setAll = function(items) {
|
||||
localStorage.setItem(FAVORITES_KEY, JSON.stringify(items));
|
||||
};
|
||||
@@ -32,21 +103,112 @@ App.favorites = App.favorites || {};
|
||||
return {
|
||||
key,
|
||||
id: video.id || null,
|
||||
url: video.url || '',
|
||||
// The page/source URL (e.g. the YouTube watch URL), not a resolved
|
||||
// CDN media URL -- those expire, so favorites must always re-resolve
|
||||
// via the server at play time instead of caching a stream link.
|
||||
url: video.url || (meta && meta.url) || '',
|
||||
title: video.title || '',
|
||||
thumb: video.thumb || '',
|
||||
channel: video.channel || (meta && meta.channel) || '',
|
||||
uploader: video.uploader || (meta && meta.uploader) || '',
|
||||
duration: video.duration || (meta && meta.duration) || 0,
|
||||
isLive: !!(video.isLive || (meta && meta.isLive)),
|
||||
meta: meta
|
||||
// When it was saved. An import carries the date the other client
|
||||
// recorded; anything saved here is saved now.
|
||||
favoriteDate: video.favoriteDate || new Date().toISOString()
|
||||
// No `meta` field: persisting resolved formats would freeze their
|
||||
// (expiring) CDN URLs into localStorage. Leaving it unset makes a
|
||||
// favorite look like a fresh, unresolved listing item again, so
|
||||
// playback/download/info all re-resolve through the backend from
|
||||
// `url` -- see resolveStreamSources' no-formats fallback, which the
|
||||
// backend resolves live via yt-dlp (main.py stream_video).
|
||||
};
|
||||
};
|
||||
|
||||
// Identity across sources. Favorites added here are keyed by the server's
|
||||
// id; ones imported from a Hot Tub backup can only be keyed by URL (the app
|
||||
// keys videos by a hash of its own). Comparing normalized URLs is what
|
||||
// stops the same video being listed twice under two different keys.
|
||||
App.favorites.urlKey = function(url) {
|
||||
const raw = String(url || '').trim();
|
||||
if (!raw) return '';
|
||||
try {
|
||||
const parsed = new URL(raw, window.location.href);
|
||||
const host = parsed.host.replace(/^www\./i, '').toLowerCase();
|
||||
const path = parsed.pathname.replace(/\/+$/, '');
|
||||
return `${host}${path}${parsed.search}`;
|
||||
} catch (err) {
|
||||
return raw.toLowerCase();
|
||||
}
|
||||
};
|
||||
|
||||
// Adds favorites from an import, skipping any this client already has.
|
||||
// Existing entries are left exactly as they are -- they carry the server id
|
||||
// that makes a listing card's heart light up, which an imported entry has
|
||||
// no way to know -- and new ones are appended after them.
|
||||
App.favorites.mergeImported = function(entries) {
|
||||
const incoming = Array.isArray(entries) ? entries : [];
|
||||
const favorites = App.favorites.getAll();
|
||||
const keys = new Set();
|
||||
const urls = new Set();
|
||||
favorites.forEach((item) => {
|
||||
if (!item) return;
|
||||
if (item.key) keys.add(item.key);
|
||||
const urlKey = App.favorites.urlKey(item.url);
|
||||
if (urlKey) urls.add(urlKey);
|
||||
});
|
||||
|
||||
let added = 0;
|
||||
let skipped = 0;
|
||||
incoming.forEach((entry) => {
|
||||
if (!entry || !entry.key) return;
|
||||
const urlKey = App.favorites.urlKey(entry.url);
|
||||
if (keys.has(entry.key) || (urlKey && urls.has(urlKey))) {
|
||||
skipped++;
|
||||
return;
|
||||
}
|
||||
keys.add(entry.key);
|
||||
if (urlKey) urls.add(urlKey);
|
||||
favorites.push(entry);
|
||||
added++;
|
||||
});
|
||||
|
||||
if (added) {
|
||||
App.favorites.setAll(favorites);
|
||||
App.favorites.renderBar();
|
||||
App.favorites.syncButtons();
|
||||
}
|
||||
return { added, skipped, total: favorites.length };
|
||||
};
|
||||
|
||||
App.favorites.getSet = function() {
|
||||
return new Set(App.favorites.getAll().map((item) => item.key));
|
||||
};
|
||||
|
||||
// Same set, addressed by URL. Imported favorites are keyed by URL rather
|
||||
// than by a server id, so a listing card can only recognise one this way.
|
||||
App.favorites.getUrlSet = function() {
|
||||
const urls = new Set();
|
||||
App.favorites.getAll().forEach((item) => {
|
||||
const urlKey = item && App.favorites.urlKey(item.url);
|
||||
if (urlKey) urls.add(urlKey);
|
||||
});
|
||||
return urls;
|
||||
};
|
||||
|
||||
// Is this video already a favorite, whichever way it got saved? Checked by
|
||||
// key first, then by URL, so a card and an imported entry for the same
|
||||
// video are recognised as one thing.
|
||||
App.favorites.indexOfEntry = function(favorites, video) {
|
||||
const key = App.favorites.getKey(video);
|
||||
const byKey = key ? favorites.findIndex((item) => item && item.key === key) : -1;
|
||||
if (byKey >= 0) return byKey;
|
||||
const meta = (video && video.meta) || video || {};
|
||||
const urlKey = App.favorites.urlKey(video && (video.url || meta.url));
|
||||
if (!urlKey) return -1;
|
||||
return favorites.findIndex((item) => item && App.favorites.urlKey(item.url) === urlKey);
|
||||
};
|
||||
|
||||
App.favorites.isVisible = function() {
|
||||
return localStorage.getItem(FAVORITES_VISIBILITY_KEY) !== 'false';
|
||||
};
|
||||
@@ -65,10 +227,12 @@ App.favorites = App.favorites || {};
|
||||
|
||||
App.favorites.syncButtons = function() {
|
||||
const favoritesSet = App.favorites.getSet();
|
||||
const favoriteUrls = App.favorites.getUrlSet();
|
||||
document.querySelectorAll('.favorite-btn[data-fav-key]').forEach((button) => {
|
||||
const key = button.dataset.favKey;
|
||||
if (!key) return;
|
||||
App.favorites.setButtonState(button, favoritesSet.has(key));
|
||||
const urlKey = App.favorites.urlKey(button.dataset.favUrl);
|
||||
if (!key && !urlKey) return;
|
||||
App.favorites.setButtonState(button, (key && favoritesSet.has(key)) || (urlKey && favoriteUrls.has(urlKey)));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -76,7 +240,9 @@ App.favorites = App.favorites || {};
|
||||
const key = App.favorites.getKey(video);
|
||||
if (!key) return;
|
||||
const favorites = App.favorites.getAll();
|
||||
const existingIndex = favorites.findIndex((item) => item.key === key);
|
||||
// By key or by URL: unfavoriting a card whose video came in from a
|
||||
// backup must remove that entry, not add a second one beside it.
|
||||
const existingIndex = App.favorites.indexOfEntry(favorites, video);
|
||||
const becameFavorite = existingIndex < 0;
|
||||
if (existingIndex >= 0) {
|
||||
favorites.splice(existingIndex, 1);
|
||||
@@ -98,18 +264,117 @@ App.favorites = App.favorites || {};
|
||||
}
|
||||
};
|
||||
|
||||
// The bar is a horizontal strip, and a long favorites list is hundreds of
|
||||
// cards. Only a screenful or so is built up front; the rest arrives as the
|
||||
// strip is scrolled, which keeps opening the app cheap no matter how many
|
||||
// favorites are saved (an import can add hundreds at once).
|
||||
const BAR_PAGE_SIZE = 24;
|
||||
// How close to the right end the strip has to get before the next page is
|
||||
// appended -- roughly a screen's worth of cards ahead of the reader.
|
||||
const BAR_PAGE_AHEAD_PX = 800;
|
||||
const barPage = { items: [], rendered: 0 };
|
||||
|
||||
// Bar titles are one line that scrolls when it doesn't fit, the same as the
|
||||
// grid card's. Which one scrolls follows the grid too: with a real pointer
|
||||
// it's the card under it, on touch the card nearest the middle of the strip.
|
||||
// Animating every overflowing title at once turns the bar into a wall of
|
||||
// moving text.
|
||||
const barTitleEnv = {
|
||||
useHoverFocus: window.matchMedia('(hover: hover) and (pointer: fine)').matches
|
||||
};
|
||||
|
||||
const setBarTitleActive = function(card, active) {
|
||||
const title = card && card.querySelector('.favorite-title');
|
||||
if (!title) return;
|
||||
card.classList.toggle('is-title-active', !!active && title.classList.contains('has-marquee'));
|
||||
};
|
||||
|
||||
// Touch: the card nearest the centre of the visible strip is the one being
|
||||
// read, so it is the one whose title scrolls.
|
||||
const syncBarTitleActive = function(list) {
|
||||
if (!list) return;
|
||||
const listRect = list.getBoundingClientRect();
|
||||
const centre = listRect.left + listRect.width / 2;
|
||||
let best = null;
|
||||
let bestDistance = Infinity;
|
||||
const cards = list.querySelectorAll('.favorite-card');
|
||||
cards.forEach((card) => {
|
||||
const rect = card.getBoundingClientRect();
|
||||
if (rect.right <= listRect.left || rect.left >= listRect.right) return;
|
||||
const distance = Math.abs((rect.left + rect.width / 2) - centre);
|
||||
if (distance < bestDistance) {
|
||||
bestDistance = distance;
|
||||
best = card;
|
||||
}
|
||||
});
|
||||
cards.forEach((card) => setBarTitleActive(card, card === best));
|
||||
};
|
||||
|
||||
// Measures every card in the strip. Cheap enough to redo wholesale: a card's
|
||||
// width is fixed, so this only really runs when cards are added.
|
||||
const measureBarTitles = function(list) {
|
||||
const target = list || document.getElementById('favorites-list');
|
||||
if (!target) return;
|
||||
target.querySelectorAll('.favorite-card').forEach((card) => {
|
||||
App.marquee.measure(card.querySelector('.favorite-title'),
|
||||
card.querySelector('.favorite-title-text'));
|
||||
});
|
||||
if (!barTitleEnv.useHoverFocus) syncBarTitleActive(target);
|
||||
};
|
||||
|
||||
// The display font arrives after the first render, and it changes how wide
|
||||
// every title is -- so whatever was measured against the fallback font has
|
||||
// to be measured again once the real one is in.
|
||||
if (document.fonts && document.fonts.ready) {
|
||||
document.fonts.ready.then(() => measureBarTitles()).catch(() => {});
|
||||
}
|
||||
|
||||
App.favorites.renderBar = function() {
|
||||
const bar = document.getElementById('favorites-bar');
|
||||
const list = document.getElementById('favorites-list');
|
||||
const empty = document.getElementById('favorites-empty');
|
||||
if (!bar || !list) return;
|
||||
|
||||
const favorites = App.favorites.getAll();
|
||||
const visible = App.favorites.isVisible();
|
||||
bar.style.display = visible ? 'block' : 'none';
|
||||
const favorites = App.favorites.sorted();
|
||||
// While the favorites grid is open the bar is kept mounted even if it's
|
||||
// switched off in settings: its header is what leads back out.
|
||||
const browsing = !!(App.favoritesView && App.favoritesView.isActive());
|
||||
bar.style.display = (App.favorites.isVisible() || browsing) ? 'block' : 'none';
|
||||
|
||||
list.innerHTML = "";
|
||||
favorites.forEach((item) => {
|
||||
barPage.items = favorites;
|
||||
barPage.rendered = 0;
|
||||
// While the favorites grid is open the strip is hidden -- the grid is
|
||||
// the same list, larger -- so don't build cards nobody can see. The
|
||||
// header stays, because it carries the way back out.
|
||||
if (!browsing) appendBarPage(list);
|
||||
|
||||
// Assignment rather than addEventListener: renderBar runs on every
|
||||
// favorite change, and this must not stack up handlers.
|
||||
let scrollRaf = null;
|
||||
list.onscroll = () => {
|
||||
// Which card is centred changes as the strip moves, but only once
|
||||
// per frame is worth measuring.
|
||||
if (!barTitleEnv.useHoverFocus && !scrollRaf) {
|
||||
scrollRaf = requestAnimationFrame(() => {
|
||||
scrollRaf = null;
|
||||
syncBarTitleActive(list);
|
||||
});
|
||||
}
|
||||
if (barPage.rendered >= barPage.items.length) return;
|
||||
const remaining = list.scrollWidth - (list.scrollLeft + list.clientWidth);
|
||||
if (remaining <= BAR_PAGE_AHEAD_PX) appendBarPage(list);
|
||||
};
|
||||
|
||||
if (empty) {
|
||||
empty.style.display = favorites.length > 0 ? 'none' : 'block';
|
||||
}
|
||||
};
|
||||
|
||||
function appendBarPage(list) {
|
||||
const slice = barPage.items.slice(barPage.rendered, barPage.rendered + BAR_PAGE_SIZE);
|
||||
barPage.rendered += slice.length;
|
||||
slice.forEach((item) => {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'favorite-card';
|
||||
card.dataset.favKey = item.key;
|
||||
@@ -120,14 +385,14 @@ App.favorites = App.favorites || {};
|
||||
const liveBadge = item.isLive ? '<span class="live-badge">● LIVE</span>' : '';
|
||||
card.innerHTML = `
|
||||
${liveBadge}
|
||||
<button class="favorite-btn is-favorite" type="button" aria-pressed="true" aria-label="Remove from favorites" data-fav-key="${item.key}">♥</button>
|
||||
<button class="favorite-btn is-favorite" type="button" aria-pressed="true" aria-label="Remove from favorites" data-fav-key="${item.key}" data-fav-url="${item.url || ''}">♥</button>
|
||||
<button class="video-menu-btn" type="button" aria-haspopup="true" aria-expanded="false" aria-label="More options">⋯</button>
|
||||
<div class="video-menu" role="menu">
|
||||
<button class="video-menu-item" type="button" data-action="info" role="menuitem">Show info</button>
|
||||
<button class="video-menu-item" type="button" data-action="download" role="menuitem">Download</button>
|
||||
</div>
|
||||
<div class="video-thumb">
|
||||
<img src="${item.thumb}" alt="${item.title}" loading="lazy" decoding="async">
|
||||
<img alt="${item.title}" loading="lazy" decoding="async">
|
||||
<div class="video-loading" aria-hidden="true">
|
||||
<div class="video-loading-spinner"></div>
|
||||
</div>
|
||||
@@ -135,17 +400,20 @@ App.favorites = App.favorites || {};
|
||||
${durationText ? `<span class="video-duration">${durationText}</span>` : ''}
|
||||
</div>
|
||||
<div class="favorite-info">
|
||||
<h4>${item.title}</h4>
|
||||
<h4 class="favorite-title"><span class="favorite-title-text">${item.title}</span></h4>
|
||||
</div>
|
||||
`;
|
||||
const thumb = card.querySelector('img');
|
||||
if (App.videos && typeof App.videos.attachNoReferrerRetry === 'function') {
|
||||
App.videos.attachNoReferrerRetry(thumb);
|
||||
if (App.videos && typeof App.videos.attachThumbnail === 'function') {
|
||||
App.videos.attachThumbnail(thumb, item.thumb);
|
||||
}
|
||||
card.onclick = () => {
|
||||
if (card.classList.contains('is-loading')) return;
|
||||
card.classList.add('is-loading');
|
||||
App.player.open(item.meta || item, { originEl: card });
|
||||
// Ignore any stale `meta` a favorite saved before this fix may
|
||||
// still carry in localStorage -- always re-resolve from `item`
|
||||
// (id/url) so playback never reuses an expired stream URL.
|
||||
App.player.open(item, { originEl: card });
|
||||
};
|
||||
const favoriteBtn = card.querySelector('.favorite-btn');
|
||||
if (favoriteBtn) {
|
||||
@@ -167,15 +435,20 @@ App.favorites = App.favorites || {};
|
||||
if (showInfoBtn) {
|
||||
showInfoBtn.onclick = (event) => {
|
||||
event.stopPropagation();
|
||||
App.ui.showInfo(item.meta || item);
|
||||
App.videos.closeAllMenus();
|
||||
// Favorites deliberately store no resolved metadata; the
|
||||
// panel opens on what the entry holds and resolves the rest
|
||||
// itself.
|
||||
App.ui.openInfo(item);
|
||||
};
|
||||
}
|
||||
if (downloadBtn) {
|
||||
downloadBtn.onclick = (event) => {
|
||||
event.stopPropagation();
|
||||
App.videos.downloadVideo(item.meta || item);
|
||||
App.videos.closeAllMenus();
|
||||
// Same as playback: resolve a real media URL first rather
|
||||
// than pointing the download at the page URL.
|
||||
App.videos.ensureFormats(item).then(() => App.videos.downloadVideo(item));
|
||||
};
|
||||
}
|
||||
const uploaderBtn = card.querySelector('.uploader-link');
|
||||
@@ -186,11 +459,17 @@ App.favorites = App.favorites || {};
|
||||
App.videos.handleSearch(uploader);
|
||||
};
|
||||
}
|
||||
if (barTitleEnv.useHoverFocus) {
|
||||
card.addEventListener('pointerenter', () => setBarTitleActive(card, true));
|
||||
card.addEventListener('pointerleave', () => setBarTitleActive(card, false));
|
||||
}
|
||||
// Keyboard: tabbing to a card's heart should reveal its whole title
|
||||
// too, on touch devices as much as on desktop.
|
||||
card.addEventListener('focusin', () => setBarTitleActive(card, true));
|
||||
card.addEventListener('focusout', () => setBarTitleActive(card, false));
|
||||
list.appendChild(card);
|
||||
});
|
||||
|
||||
if (empty) {
|
||||
empty.style.display = favorites.length > 0 ? 'none' : 'block';
|
||||
// Widths only exist once the cards are laid out.
|
||||
requestAnimationFrame(() => measureBarTitles(list));
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
110
frontend/js/favoritesView.js
Normal file
110
frontend/js/favoritesView.js
Normal file
@@ -0,0 +1,110 @@
|
||||
window.App = window.App || {};
|
||||
App.favoritesView = App.favoritesView || {};
|
||||
|
||||
// Browsing favorites as a full grid, the same way the channel listing is
|
||||
// browsed: same cards, same virtualized masonry, same infinite scroll, same
|
||||
// reels mode. The only difference is where the pages come from -- localStorage
|
||||
// instead of the server -- so App.videos.loadVideos routes here while this view
|
||||
// is active and every page hands its slice to App.videos.renderVideos.
|
||||
(function() {
|
||||
const state = App.state;
|
||||
|
||||
// A page of a local list can be bigger than a page from the server: there's
|
||||
// no request behind it, only the cost of building cards, which the
|
||||
// virtualizer already keeps to what's on screen.
|
||||
const PAGE_SIZE = 24;
|
||||
|
||||
const view = {
|
||||
active: false,
|
||||
queue: [], // the sorted favorites still to be handed to the grid
|
||||
offset: 0
|
||||
};
|
||||
|
||||
// A favorite as the grid expects a video: `id` has to be unique per card
|
||||
// (the virtualizer and renderedVideoIds key on it), and an imported
|
||||
// favorite has no server id -- its key, which is the URL, stands in.
|
||||
const toVideo = function(entry) {
|
||||
return Object.assign({}, entry, { id: entry.key, tags: [] });
|
||||
};
|
||||
|
||||
App.favoritesView.isActive = function() {
|
||||
return view.active;
|
||||
};
|
||||
|
||||
App.favoritesView.loadNext = function() {
|
||||
if (!view.active) return false;
|
||||
const slice = view.queue.slice(view.offset, view.offset + PAGE_SIZE);
|
||||
view.offset += slice.length;
|
||||
state.hasNextPage = view.offset < view.queue.length;
|
||||
if (!slice.length) {
|
||||
App.videos.updateLoadMoreState();
|
||||
return false;
|
||||
}
|
||||
App.videos.renderVideos({ items: slice.map(toVideo) });
|
||||
App.videos.updateLoadMoreState();
|
||||
return true;
|
||||
};
|
||||
|
||||
// Starts (or restarts, after a sort change) the favorites grid.
|
||||
App.favoritesView.open = function(options) {
|
||||
const sort = (options && options.sort) || App.favorites.getSort();
|
||||
const favorites = App.favorites.sorted(sort);
|
||||
if (!favorites.length) {
|
||||
App.ui.showError('No favorites yet. Tap the heart on a video to save one.');
|
||||
return false;
|
||||
}
|
||||
App.videos.resetGrid();
|
||||
view.active = true;
|
||||
view.queue = favorites;
|
||||
view.offset = 0;
|
||||
state.hasNextPage = true;
|
||||
document.body.classList.add('favorites-view-open');
|
||||
// Re-render the bar so it re-decides whether to be mounted: hidden in
|
||||
// settings or not, its header has to be on screen now, since that's
|
||||
// where the way back out lives (the palette can open this view too).
|
||||
App.favorites.renderBar();
|
||||
App.favoritesView.syncControls();
|
||||
App.favoritesView.loadNext();
|
||||
window.scrollTo({ top: 0, behavior: 'auto' });
|
||||
return true;
|
||||
};
|
||||
|
||||
App.favoritesView.close = function(options) {
|
||||
if (!view.active) return;
|
||||
view.active = false;
|
||||
view.queue = [];
|
||||
view.offset = 0;
|
||||
document.body.classList.remove('favorites-view-open');
|
||||
// Back to whatever the settings say, and with its cards built again.
|
||||
App.favorites.renderBar();
|
||||
App.favoritesView.syncControls();
|
||||
// Back to the channel listing, unless the caller is about to load
|
||||
// something itself (a search, a channel switch).
|
||||
if (!(options && options.silent)) App.videos.resetAndReload();
|
||||
};
|
||||
|
||||
App.favoritesView.toggle = function() {
|
||||
if (view.active) App.favoritesView.close();
|
||||
else App.favoritesView.open();
|
||||
};
|
||||
|
||||
// Re-pages the grid under a new order, and re-renders the bar so both show
|
||||
// favorites the same way round.
|
||||
App.favoritesView.applySort = function(sort) {
|
||||
App.favorites.setSort(sort);
|
||||
App.favorites.renderBar();
|
||||
if (view.active) App.favoritesView.open({ sort });
|
||||
};
|
||||
|
||||
App.favoritesView.syncControls = function() {
|
||||
const button = document.getElementById('favorites-browse-btn');
|
||||
if (button) {
|
||||
button.textContent = view.active ? 'Back to videos' : 'Browse all';
|
||||
button.setAttribute('aria-pressed', view.active ? 'true' : 'false');
|
||||
}
|
||||
const select = document.getElementById('favorites-sort');
|
||||
if (select && select.value !== App.favorites.getSort()) {
|
||||
select.value = App.favorites.getSort();
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -52,7 +52,11 @@ App.feed = App.feed || {};
|
||||
if (hudIdleTimer) clearTimeout(hudIdleTimer);
|
||||
hudIdleTimer = setTimeout(() => {
|
||||
hudIdleTimer = null;
|
||||
if (state.feedOpen) document.body.classList.add('feed-hud-idle');
|
||||
if (!state.feedOpen) return;
|
||||
document.body.classList.add('feed-hud-idle');
|
||||
// The quality menu only fades with the rest of the HUD if we close
|
||||
// it: it's an opened popover, not a permanently mounted control.
|
||||
document.querySelectorAll('.feed-format-menu').forEach((menu) => { menu.hidden = true; });
|
||||
}, HUD_IDLE_MS);
|
||||
};
|
||||
|
||||
@@ -155,26 +159,11 @@ App.feed = App.feed || {};
|
||||
slide.classList.remove('is-loaded');
|
||||
};
|
||||
|
||||
// Single-line feed title that scrolls horizontally when it overflows.
|
||||
// Driven off the overflow distance so every title scrolls at the same
|
||||
// gentle speed, matching the grid-card marquee (see App.videos.measureTitle).
|
||||
// Single-line slide title that scrolls when it overflows. Only the active
|
||||
// slide's title is measured, so like the player it always scrolls.
|
||||
const measureFeedTitle = function(slide) {
|
||||
if (!slide) return;
|
||||
const wrap = slide.querySelector('.feed-title');
|
||||
const text = slide.querySelector('.feed-title-text');
|
||||
if (!wrap || !text) return;
|
||||
const overflow = text.scrollWidth - wrap.clientWidth;
|
||||
if (overflow > 4) {
|
||||
const distance = overflow + 16;
|
||||
const MARQUEE_SPEED = 28; // px per second
|
||||
const duration = Math.max(6, distance / MARQUEE_SPEED);
|
||||
text.style.setProperty('--marquee-distance', `${distance}px`);
|
||||
text.style.setProperty('--marquee-duration', `${duration.toFixed(2)}s`);
|
||||
wrap.classList.add('is-marquee');
|
||||
} else {
|
||||
wrap.classList.remove('is-marquee');
|
||||
text.style.removeProperty('--marquee-distance');
|
||||
}
|
||||
App.marquee.measure(slide.querySelector('.feed-title'), slide.querySelector('.feed-title-text'));
|
||||
};
|
||||
|
||||
const setTimelinePosition = function(slide, ratio) {
|
||||
@@ -233,6 +222,94 @@ App.feed = App.feed || {};
|
||||
timeline.addEventListener('pointercancel', stopScrubbing);
|
||||
};
|
||||
|
||||
const flashFeed = function(slide, text) {
|
||||
const flashEl = slide.querySelector('.feed-flash');
|
||||
if (!flashEl) return;
|
||||
flashEl.textContent = text;
|
||||
flashEl.classList.remove('is-visible');
|
||||
void flashEl.offsetWidth;
|
||||
flashEl.classList.add('is-visible');
|
||||
};
|
||||
|
||||
// Wires the controls shared with the standalone fullscreen player (skip
|
||||
// escalation + double-tap zones, format switching, PiP) onto a reels
|
||||
// slide, reusing the same App.customPlayer logic so both surfaces behave
|
||||
// identically. Feed's own timeline/favorite/title and scroll-snap
|
||||
// slide-to-slide navigation are untouched (see bindTimeline above and
|
||||
// setActive/onScroll below).
|
||||
const bindSharedControls = function(slide, video, videoData) {
|
||||
const cleanups = [];
|
||||
const escalator = App.customPlayer.createSkipEscalator();
|
||||
cleanups.push(() => escalator.destroy());
|
||||
|
||||
const doSkip = (direction) => {
|
||||
const amount = App.customPlayer.skip(video, direction, escalator);
|
||||
flashFeed(slide, `${direction === 'forward' ? '+' : '-'}${amount}s`);
|
||||
wakeHud();
|
||||
};
|
||||
|
||||
const pipBtn = slide.querySelector('.feed-pip-btn');
|
||||
if (pipBtn) {
|
||||
pipBtn.hidden = !App.customPlayer.supportsPiP();
|
||||
const onClick = async (event) => {
|
||||
event.stopPropagation();
|
||||
await App.customPlayer.togglePiP(video);
|
||||
};
|
||||
pipBtn.addEventListener('click', onClick);
|
||||
cleanups.push(() => pipBtn.removeEventListener('click', onClick));
|
||||
}
|
||||
cleanups.push(App.customPlayer.bindAutoPiP(video));
|
||||
|
||||
const formatBtn = slide.querySelector('.feed-format-btn');
|
||||
const formatMenu = slide.querySelector('.feed-format-menu');
|
||||
const onFormatPick = (fmt) => {
|
||||
slide._formatOverride = fmt;
|
||||
const t = video.currentTime;
|
||||
if (isFinite(t) && t > 0) resumeTimes.set(videoData.id, t);
|
||||
// Tear down the current source (mirrors destroySlidePlayback's
|
||||
// hls/video reset) before reloading with the new format -- this
|
||||
// is a live in-place reload, not a fresh never-loaded slide, so
|
||||
// the old Hls.js instance must be destroyed or it keeps running
|
||||
// (fetching segments, attached to the same <video>) forever.
|
||||
if (video._hlsPlayer) {
|
||||
video._hlsPlayer.destroy();
|
||||
video._hlsPlayer = null;
|
||||
}
|
||||
video._tearingDown = true;
|
||||
video.pause();
|
||||
video.removeAttribute('src');
|
||||
video.load();
|
||||
slide.classList.remove('is-loaded');
|
||||
loadSlideSource(slide, videoData, true);
|
||||
};
|
||||
const bindFormats = () => App.customPlayer.bindFormatMenu(formatBtn, formatMenu, videoData, onFormatPick,
|
||||
{ getCurrentUrl: () => slide._activeUrl || '', onOpen: wakeHud });
|
||||
let destroyFormatMenu = bindFormats();
|
||||
cleanups.push(() => destroyFormatMenu());
|
||||
// A slide can go active before its formats have been resolved (feed items
|
||||
// carry only a page URL until then), which would leave the quality menu
|
||||
// empty. Playback already runs from that page URL through the proxy, so
|
||||
// resolve in the background and rebuild the menu once the real qualities
|
||||
// land -- same as the standalone player does.
|
||||
if (App.videos && typeof App.videos.ensureFormats === 'function') {
|
||||
App.videos.ensureFormats(videoData).then((meta) => {
|
||||
// Bail if the slide was torn down (or rebound) in the meantime.
|
||||
if (!meta || slide._sharedControlCleanups !== cleanups) return;
|
||||
destroyFormatMenu();
|
||||
destroyFormatMenu = bindFormats();
|
||||
});
|
||||
}
|
||||
|
||||
cleanups.push(App.customPlayer.attachGestures(slide, {
|
||||
onSingleTap: wakeHud,
|
||||
onDoubleTapLeft: () => doSkip('back'),
|
||||
onDoubleTapRight: () => doSkip('forward'),
|
||||
ignoreSelector: 'button, input, a, .cp-format-menu, .feed-timeline'
|
||||
}));
|
||||
|
||||
slide._sharedControlCleanups = cleanups;
|
||||
};
|
||||
|
||||
const loadSlideSource = function(slide, videoData, autoplay) {
|
||||
const video = slide.querySelector('.feed-video');
|
||||
if (!video) return;
|
||||
@@ -244,17 +321,36 @@ App.feed = App.feed || {};
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// A slide whose formats haven't been resolved yet carries only a page
|
||||
// URL, and handing that to /api/stream makes the backend re-run yt-dlp
|
||||
// per request (slow, and a hard failure on some sites). Resolve once,
|
||||
// then load for real -- `_awaitingFormats` keeps a failed resolve from
|
||||
// looping, so we still fall back to the page URL as a last resort.
|
||||
const meta = videoData && (videoData.meta || videoData);
|
||||
const hasFormats = !!(meta && Array.isArray(meta.formats) && meta.formats.length);
|
||||
if (!hasFormats && !slide._awaitingFormats && App.videos && typeof App.videos.ensureFormats === 'function') {
|
||||
slide._awaitingFormats = true;
|
||||
App.videos.ensureFormats(videoData).then(() => {
|
||||
if (slide._videoData === videoData) loadSlideSource(slide, videoData, autoplay);
|
||||
});
|
||||
return;
|
||||
}
|
||||
slide.classList.add('is-loaded');
|
||||
|
||||
const resolved = App.videos.resolveStreamSource(videoData);
|
||||
if (!resolved.url) {
|
||||
const resolved = slide._formatOverride
|
||||
? App.videos.resolveSourceForFormat(videoData, slide._formatOverride)
|
||||
: App.videos.resolveStreamSource(videoData);
|
||||
if (!resolved || !resolved.url) {
|
||||
// No playable source -- treat exactly like a load failure so the
|
||||
// clip is dropped from the queue and the next one takes its place.
|
||||
markSlideFailed(slide);
|
||||
return;
|
||||
}
|
||||
// What's actually on screen, so the quality menu can tick it.
|
||||
slide._activeUrl = resolved.url;
|
||||
const streamUrl = App.videos.buildStreamUrlFromSource(resolved);
|
||||
const isHls = resolved.isLive ? true : /\.m3u8($|\?)/i.test(resolved.url);
|
||||
const isHls = App.videos.classifySource(resolved).isHls;
|
||||
|
||||
video.muted = state.feedMuted;
|
||||
video.preload = 'auto';
|
||||
@@ -328,10 +424,16 @@ App.feed = App.feed || {};
|
||||
const liveBadge = v.isLive ? '<span class="live-badge feed-live-badge">● LIVE</span>' : '';
|
||||
const favKey = App.favorites ? App.favorites.getKey(v) : null;
|
||||
slide.innerHTML = `
|
||||
<img class="feed-poster" src="${v.thumb || ''}" alt="" loading="lazy" decoding="async">
|
||||
<img class="feed-poster" alt="" loading="lazy" decoding="async">
|
||||
<video class="feed-video" muted playsinline webkit-playsinline preload="none"></video>
|
||||
${liveBadge}
|
||||
${favKey ? `<button class="favorite-btn feed-fav-btn" type="button" data-fav-key="${favKey}"></button>` : ''}
|
||||
${favKey ? `<button class="favorite-btn feed-fav-btn" type="button" data-fav-key="${favKey}" data-fav-url="${v.url || ''}"></button>` : ''}
|
||||
<button class="cp-pip-btn feed-pip-btn" type="button" aria-label="Picture in picture" hidden>
|
||||
<img class="icon-svg" src="https://cdn.jsdelivr.net/npm/heroicons@2.0.13/24/outline/arrow-top-right-on-square.svg" alt="">
|
||||
</button>
|
||||
<button class="cp-format-btn feed-format-btn" type="button" aria-label="Quality" hidden>HD</button>
|
||||
<div class="cp-format-menu feed-format-menu" role="menu" hidden></div>
|
||||
<div class="cp-flash feed-flash" aria-hidden="true"></div>
|
||||
<div class="feed-info">
|
||||
<h4 class="feed-title"><span class="feed-title-text">${v.title || ''}</span></h4>
|
||||
${uploaderText ? `<p class="feed-uploader">${uploaderText}</p>` : ''}
|
||||
@@ -344,9 +446,10 @@ App.feed = App.feed || {};
|
||||
</div>
|
||||
`;
|
||||
const poster = slide.querySelector('.feed-poster');
|
||||
App.videos.attachNoReferrerRetry(poster);
|
||||
App.videos.attachThumbnail(poster, v.thumb);
|
||||
const slideVideo = slide.querySelector('.feed-video');
|
||||
bindTimeline(slide, slideVideo);
|
||||
bindSharedControls(slide, slideVideo, v);
|
||||
|
||||
// A media error (bad/expired source, network failure, unsupported codec)
|
||||
// means this clip can't play -- drop it from the queue. Errors fired by
|
||||
@@ -366,7 +469,7 @@ App.feed = App.feed || {};
|
||||
|
||||
const favBtn = slide.querySelector('.feed-fav-btn');
|
||||
if (favBtn && App.favorites) {
|
||||
App.favorites.setButtonState(favBtn, App.favorites.getSet().has(favKey));
|
||||
App.favorites.setButtonState(favBtn, App.favorites.indexOfEntry(App.favorites.getAll(), v) >= 0);
|
||||
favBtn.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
App.favorites.toggle(v);
|
||||
@@ -388,10 +491,23 @@ App.feed = App.feed || {};
|
||||
return slide;
|
||||
};
|
||||
|
||||
// Tears down everything a slide holds -- playback (video/hls) plus the
|
||||
// shared skip/format/PiP/gesture bindings from bindSharedControls -- but
|
||||
// does not remove it from the DOM or from slidesByIndex (callers differ
|
||||
// on that: removeSlide always does, reset() removes the whole tree at
|
||||
// once).
|
||||
const teardownSlide = function(slide) {
|
||||
destroySlidePlayback(slide);
|
||||
if (Array.isArray(slide._sharedControlCleanups)) {
|
||||
slide._sharedControlCleanups.forEach((fn) => { try { fn(); } catch (err) { /* ignore */ } });
|
||||
slide._sharedControlCleanups = null;
|
||||
}
|
||||
};
|
||||
|
||||
const removeSlide = function(index) {
|
||||
const slide = slidesByIndex.get(index);
|
||||
if (!slide) return;
|
||||
destroySlidePlayback(slide);
|
||||
teardownSlide(slide);
|
||||
slide.remove();
|
||||
slidesByIndex.delete(index);
|
||||
};
|
||||
@@ -499,7 +615,9 @@ App.feed = App.feed || {};
|
||||
const bufferAhead = total - 1 - activeIndex;
|
||||
if (bufferAhead < PREFETCH_PAGES * (state.perPage || 12)
|
||||
&& state.hasNextPage && !state.isLoading) {
|
||||
App.videos.loadVideos();
|
||||
// The feed is its own reader: the grid's scroll position says
|
||||
// nothing about whether it needs the next page.
|
||||
App.videos.loadVideos({ force: true });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -628,7 +746,7 @@ App.feed = App.feed || {};
|
||||
|
||||
App.feed.reset = function() {
|
||||
slidesByIndex.forEach((slide) => {
|
||||
destroySlidePlayback(slide);
|
||||
teardownSlide(slide);
|
||||
slide.remove();
|
||||
});
|
||||
slidesByIndex.clear();
|
||||
@@ -653,7 +771,12 @@ App.feed = App.feed || {};
|
||||
state.feedOpen = true;
|
||||
|
||||
if (App.player && typeof App.player.close === 'function') {
|
||||
App.player.close();
|
||||
// fromPopState: true suppresses the player's own history.back()
|
||||
// -- this is an incidental "make sure it's closed" call when
|
||||
// switching to Reels view, not the user pressing the player's
|
||||
// close button, so it must not silently consume a back-button
|
||||
// entry out from under real browser navigation.
|
||||
App.player.close({ fromPopState: true });
|
||||
}
|
||||
|
||||
container.classList.add('open');
|
||||
|
||||
79
frontend/js/hottubBackup.js
Normal file
79
frontend/js/hottubBackup.js
Normal file
@@ -0,0 +1,79 @@
|
||||
window.App = window.App || {};
|
||||
App.hottubBackup = App.hottubBackup || {};
|
||||
|
||||
// Reads a Hot Tub app backup (an exported SQLite database) and turns the videos
|
||||
// it has flagged as favorites into this client's favorites.
|
||||
//
|
||||
// The app and this client don't agree on identity: the app keys a video by a
|
||||
// hash it computes locally, while the server -- and so this client -- keys it by
|
||||
// something like "reddit-1rdudss". So an imported favorite is matched to an
|
||||
// existing one by URL, and carries no id of its own; see App.favorites.mergeImported.
|
||||
(function() {
|
||||
// The app stores a comma-separated set here ("favorite", "recent", ...).
|
||||
// It also keeps a `favoriteDate` on rows it no longer flags -- a leftover
|
||||
// from unfavoriting -- so the flag, not the date, is what counts.
|
||||
const FAVORITE_FLAG = 'favorite';
|
||||
|
||||
// Only what a favorite needs. Skipping the rest matters: `allFormats` alone
|
||||
// is kilobytes of resolved-format JSON per row, and it is exactly the kind
|
||||
// of thing this client must not store -- those URLs are signed and expire
|
||||
// (see App.favorites.normalize).
|
||||
const COLUMNS = ['url', 'title', 'thumb', 'duration', 'uploader', 'flags', 'favoriteDate'];
|
||||
|
||||
// The app writes a local-time stamp with no zone ("2025-04-25T20:26:02.144").
|
||||
// Read it as local time (which is what it was) and keep it as an instant, so
|
||||
// imported favorites sort against ones saved here. Unparseable or missing
|
||||
// dates fall back to now rather than to 1970, which would bury them.
|
||||
const toIsoDate = function(value) {
|
||||
const parsed = Date.parse(value || '');
|
||||
return isNaN(parsed) ? new Date().toISOString() : new Date(parsed).toISOString();
|
||||
};
|
||||
|
||||
const hasFavoriteFlag = function(flags) {
|
||||
if (!flags) return false;
|
||||
return String(flags).split(',').some((flag) => flag.trim().toLowerCase() === FAVORITE_FLAG);
|
||||
};
|
||||
|
||||
// Newest first, matching how favorites are ordered when added by hand.
|
||||
const byNewest = function(a, b) {
|
||||
return String(b.favoriteDate || '').localeCompare(String(a.favoriteDate || ''));
|
||||
};
|
||||
|
||||
App.hottubBackup.readFavorites = function(buffer) {
|
||||
const db = App.sqlite.open(buffer);
|
||||
if (db.tableNames().indexOf('video_details') < 0) {
|
||||
throw new Error('This database has no video_details table -- is it a Hot Tub backup?');
|
||||
}
|
||||
const rows = db.readTable('video_details', { columns: COLUMNS });
|
||||
return rows
|
||||
.filter((row) => row.url && hasFavoriteFlag(row.flags))
|
||||
.sort(byNewest)
|
||||
.map((row) => ({
|
||||
// No id: the app's own is meaningless to this client, and the
|
||||
// URL is what both sides agree on.
|
||||
key: row.url,
|
||||
id: null,
|
||||
url: row.url,
|
||||
title: row.title || '',
|
||||
thumb: row.thumb || '',
|
||||
channel: '',
|
||||
uploader: row.uploader || '',
|
||||
duration: Number(row.duration) || 0,
|
||||
isLive: false,
|
||||
favoriteDate: toIsoDate(row.favoriteDate)
|
||||
}));
|
||||
};
|
||||
|
||||
App.hottubBackup.readFile = function(file) {
|
||||
return file.arrayBuffer().then((buffer) => App.hottubBackup.readFavorites(buffer));
|
||||
};
|
||||
|
||||
// Reads the file and merges what it finds. Resolves to the merge summary
|
||||
// ({found, added, skipped, total}) so the caller can report it.
|
||||
App.hottubBackup.importFile = function(file) {
|
||||
return App.hottubBackup.readFile(file).then((entries) => {
|
||||
const result = App.favorites.mergeImported(entries);
|
||||
return Object.assign({ found: entries.length }, result);
|
||||
});
|
||||
};
|
||||
})();
|
||||
@@ -8,6 +8,9 @@ window.App = window.App || {};
|
||||
App.ui.applyPreferredQuality();
|
||||
App.ui.applyFeedEndBehavior();
|
||||
App.ui.applyDensity();
|
||||
// Set the text-size CSS variable before the first pack so initial card
|
||||
// heights are measured at the user's chosen size.
|
||||
document.documentElement.style.setProperty('--card-font-scale', App.storage.getFontScale());
|
||||
App.ui.renderMenu();
|
||||
App.favorites.renderBar();
|
||||
App.ui.bindGlobalHandlers();
|
||||
@@ -17,7 +20,7 @@ window.App = window.App || {};
|
||||
const loadMoreBtn = document.getElementById('load-more-btn');
|
||||
if (loadMoreBtn) {
|
||||
loadMoreBtn.onclick = () => {
|
||||
App.videos.loadVideos();
|
||||
App.videos.loadVideos({ force: true });
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
51
frontend/js/marquee.js
Normal file
51
frontend/js/marquee.js
Normal file
@@ -0,0 +1,51 @@
|
||||
window.App = window.App || {};
|
||||
App.marquee = App.marquee || {};
|
||||
|
||||
// A title is always one line. When it doesn't fit its box it scrolls sideways
|
||||
// instead of wrapping or being silently cut off.
|
||||
//
|
||||
// Four surfaces show a title that way -- the grid card, the favorites bar card,
|
||||
// the fullscreen player, the reels slide -- and they must scroll at the same
|
||||
// speed to look like one app, so the measurement lives here rather than being
|
||||
// written out again next to each of them. Whether a given title is *currently*
|
||||
// scrolling is the caller's business (see the `is-title-active` handling in
|
||||
// videos.js and favorites.js): a whole grid of marching text is unreadable, so
|
||||
// most callers animate only the title the reader is actually looking at.
|
||||
(function() {
|
||||
// Drive the duration off the distance so every title scrolls at the same
|
||||
// gentle rate rather than a fixed duration, which made longer titles whip
|
||||
// past. The floor keeps short ones from snapping.
|
||||
const SPEED_PX_PER_SEC = 28;
|
||||
const MIN_DURATION_S = 6;
|
||||
// Sub-pixel rounding isn't overflow worth animating.
|
||||
const OVERFLOW_SLACK_PX = 4;
|
||||
// Trailing space so the last word clears the edge before it wraps around.
|
||||
const TAIL_GAP_PX = 12;
|
||||
|
||||
// Measures `text` inside `wrap` and prepares the animation: sets
|
||||
// --marquee-distance / --marquee-duration on `text`, and marks `wrap` with
|
||||
// `has-marquee` so CSS can decide what to do about it. Returns whether the
|
||||
// title overflows -- callers use that to skip the bookkeeping (scroll
|
||||
// observers, hover handlers) that only scrolling titles need.
|
||||
//
|
||||
// Reads layout, so call it when the element is in the document and visible;
|
||||
// a hidden element measures as zero-width and reports no overflow.
|
||||
App.marquee.measure = function(wrap, text) {
|
||||
if (!wrap || !text) return false;
|
||||
|
||||
const overflow = text.scrollWidth - wrap.clientWidth;
|
||||
if (overflow <= OVERFLOW_SLACK_PX) {
|
||||
wrap.classList.remove('has-marquee');
|
||||
text.style.removeProperty('--marquee-distance');
|
||||
text.style.removeProperty('--marquee-duration');
|
||||
return false;
|
||||
}
|
||||
|
||||
const distance = overflow + TAIL_GAP_PX;
|
||||
const duration = Math.max(MIN_DURATION_S, distance / SPEED_PX_PER_SEC);
|
||||
text.style.setProperty('--marquee-distance', `${distance}px`);
|
||||
text.style.setProperty('--marquee-duration', `${duration.toFixed(2)}s`);
|
||||
wrap.classList.add('has-marquee');
|
||||
return true;
|
||||
};
|
||||
})();
|
||||
File diff suppressed because it is too large
Load Diff
BIN
frontend/js/sqlite.js
Normal file
BIN
frontend/js/sqlite.js
Normal file
Binary file not shown.
@@ -10,10 +10,6 @@ App.state = {
|
||||
hlsPlayer: null,
|
||||
currentLoadController: null,
|
||||
errorToastTimer: null,
|
||||
playerMode: 'modal',
|
||||
playerHome: null,
|
||||
onFullscreenChange: null,
|
||||
onWebkitEndFullscreen: null,
|
||||
loadedVideos: [],
|
||||
feedOpen: false,
|
||||
feedMuted: true,
|
||||
@@ -26,6 +22,7 @@ App.state = {
|
||||
App.constants = {
|
||||
FAVORITES_KEY: 'favorites',
|
||||
FAVORITES_VISIBILITY_KEY: 'favoritesVisible',
|
||||
FAVORITES_SORT_KEY: 'favoritesSort',
|
||||
PREFERRED_QUALITY_KEY: 'preferredQuality',
|
||||
FEED_END_BEHAVIOR_KEY: 'feedEndBehavior'
|
||||
};
|
||||
|
||||
@@ -57,6 +57,30 @@ App.session = App.session || {};
|
||||
localStorage.setItem('density', nextDensity === 'compact' ? 'compact' : 'comfortable');
|
||||
};
|
||||
|
||||
// User-tunable card width / text size multipliers (default 1.0). Clamped so a
|
||||
// stale or hand-edited value can never break the layout.
|
||||
const clampScale = function(value, min, max, fallback) {
|
||||
const n = parseFloat(value);
|
||||
if (!isFinite(n)) return fallback;
|
||||
return Math.min(max, Math.max(min, n));
|
||||
};
|
||||
|
||||
App.storage.getCardScale = function() {
|
||||
return clampScale(localStorage.getItem('cardScale'), 0.7, 1.5, 1);
|
||||
};
|
||||
|
||||
App.storage.setCardScale = function(next) {
|
||||
localStorage.setItem('cardScale', clampScale(next, 0.7, 1.5, 1));
|
||||
};
|
||||
|
||||
App.storage.getFontScale = function() {
|
||||
return clampScale(localStorage.getItem('fontScale'), 0.8, 1.4, 1);
|
||||
};
|
||||
|
||||
App.storage.setFontScale = function(next) {
|
||||
localStorage.setItem('fontScale', clampScale(next, 0.8, 1.4, 1));
|
||||
};
|
||||
|
||||
App.storage.getServerEntries = function() {
|
||||
const config = App.storage.getConfig();
|
||||
if (!config.servers || !Array.isArray(config.servers)) return [];
|
||||
|
||||
@@ -28,6 +28,29 @@ App.ui = App.ui || {};
|
||||
if (select) select.value = density;
|
||||
};
|
||||
|
||||
// Card Size: re-packs the virtual grid (column count derives from the scaled
|
||||
// minimum card width in videos.js).
|
||||
App.ui.applyCardScale = function() {
|
||||
const scale = App.storage.getCardScale();
|
||||
const range = document.getElementById('card-size-range');
|
||||
if (range) range.value = scale;
|
||||
if (App.virtualGrid && typeof App.virtualGrid.relayout === 'function') {
|
||||
App.virtualGrid.relayout();
|
||||
}
|
||||
};
|
||||
|
||||
// Text Size: drives the --card-font-scale CSS variable; a re-pack follows so
|
||||
// card heights account for the new text size.
|
||||
App.ui.applyFontScale = function() {
|
||||
const scale = App.storage.getFontScale();
|
||||
document.documentElement.style.setProperty('--card-font-scale', scale);
|
||||
const range = document.getElementById('text-size-range');
|
||||
if (range) range.value = scale;
|
||||
if (App.virtualGrid && typeof App.virtualGrid.relayout === 'function') {
|
||||
App.virtualGrid.relayout();
|
||||
}
|
||||
};
|
||||
|
||||
// Toast helper for playback + network errors.
|
||||
App.ui.showError = function(message) {
|
||||
const toast = document.getElementById('error-toast');
|
||||
@@ -43,25 +66,23 @@ App.ui = App.ui || {};
|
||||
}, 4000);
|
||||
};
|
||||
|
||||
App.ui.showInfo = function(video) {
|
||||
const modal = document.getElementById('info-modal');
|
||||
if (!modal) return;
|
||||
const title = document.getElementById('info-title');
|
||||
const list = document.getElementById('info-list');
|
||||
const empty = document.getElementById('info-empty');
|
||||
// Which video the panel is currently showing, so a slow resolve that lands
|
||||
// after the user moved on doesn't redraw someone else's panel.
|
||||
let infoVideo = null;
|
||||
|
||||
const data = video && video.meta ? video.meta : video;
|
||||
const titleText = data && data.title ? data.title : 'Video Info';
|
||||
if (title) title.textContent = titleText;
|
||||
const appendInfoHeading = function(list, label) {
|
||||
const heading = document.createElement('div');
|
||||
heading.className = 'info-section';
|
||||
heading.textContent = label;
|
||||
list.appendChild(heading);
|
||||
};
|
||||
|
||||
if (list) {
|
||||
list.innerHTML = "";
|
||||
}
|
||||
|
||||
let hasRows = false;
|
||||
if (data && typeof data === 'object') {
|
||||
Object.entries(data).forEach(([key, value]) => {
|
||||
if (!list) return;
|
||||
// One row per field, whatever the field is. Objects and arrays are printed
|
||||
// as JSON rather than summarised: the panel is the place to see exactly what
|
||||
// the server said, so nothing is dropped or abbreviated here.
|
||||
const appendInfoRows = function(list, data) {
|
||||
let count = 0;
|
||||
Object.entries(data || {}).forEach(([key, value]) => {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'info-row';
|
||||
|
||||
@@ -83,21 +104,81 @@ App.ui = App.ui || {};
|
||||
row.appendChild(label);
|
||||
row.appendChild(valueNode);
|
||||
list.appendChild(row);
|
||||
hasRows = true;
|
||||
count++;
|
||||
});
|
||||
return count;
|
||||
};
|
||||
|
||||
// Shows every field the client holds for a video: the listing item's own
|
||||
// (id, title, uploader, duration, tags, ...) and then the extractor's, which
|
||||
// arrive separately. It used to show `video.meta` *instead of* the item once
|
||||
// one had been resolved, which silently hid everything the listing knew the
|
||||
// moment a card had been hovered.
|
||||
// `options.info` is the full extractor payload (App.videos.fetchFullInfo);
|
||||
// `options.pending` notes that it's still on its way.
|
||||
App.ui.showInfo = function(video, options) {
|
||||
const modal = document.getElementById('info-modal');
|
||||
if (!modal) return;
|
||||
const opts = options || {};
|
||||
const title = document.getElementById('info-title');
|
||||
const list = document.getElementById('info-list');
|
||||
const empty = document.getElementById('info-empty');
|
||||
|
||||
const item = (video && typeof video === 'object') ? video : {};
|
||||
// `meta` is the trimmed playback payload; the full extractor info is a
|
||||
// superset of it, so only one of the two is ever shown.
|
||||
const resolved = opts.info || item.meta || null;
|
||||
|
||||
if (title) title.textContent = item.title || (resolved && resolved.title) || 'Video Info';
|
||||
|
||||
let rows = 0;
|
||||
if (list) {
|
||||
list.innerHTML = "";
|
||||
// `meta` gets its own section below rather than a row of JSON.
|
||||
const own = Object.assign({}, item);
|
||||
delete own.meta;
|
||||
rows += appendInfoRows(list, own);
|
||||
|
||||
if (resolved && typeof resolved === 'object') {
|
||||
appendInfoHeading(list, opts.info ? 'Extractor' : 'Resolved');
|
||||
rows += appendInfoRows(list, resolved);
|
||||
}
|
||||
|
||||
if (opts.pending) {
|
||||
const pending = document.createElement('div');
|
||||
pending.className = 'info-pending';
|
||||
pending.textContent = 'Resolving full metadata…';
|
||||
list.appendChild(pending);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty) {
|
||||
empty.style.display = hasRows ? 'none' : 'block';
|
||||
empty.style.display = rows ? 'none' : 'block';
|
||||
}
|
||||
|
||||
modal.classList.add('open');
|
||||
modal.setAttribute('aria-hidden', 'false');
|
||||
};
|
||||
|
||||
// Opens the panel on what the client already has, then redraws it with the
|
||||
// extractor's full payload once that lands. Resolution runs yt-dlp against
|
||||
// the source site and can take seconds; there's no reason to stare at
|
||||
// nothing (or at a spinner) while it does.
|
||||
App.ui.openInfo = function(video) {
|
||||
infoVideo = video;
|
||||
const canResolve = !!(App.videos && typeof App.videos.fetchFullInfo === 'function');
|
||||
App.ui.showInfo(video, { pending: canResolve });
|
||||
if (!canResolve) return;
|
||||
App.videos.fetchFullInfo(video).then((info) => {
|
||||
if (infoVideo !== video) return; // the panel moved on, or closed
|
||||
App.ui.showInfo(video, { info: info });
|
||||
});
|
||||
};
|
||||
|
||||
App.ui.closeInfo = function() {
|
||||
const modal = document.getElementById('info-modal');
|
||||
if (!modal) return;
|
||||
infoVideo = null;
|
||||
modal.classList.remove('open');
|
||||
modal.setAttribute('aria-hidden', 'true');
|
||||
};
|
||||
@@ -305,6 +386,24 @@ App.ui = App.ui || {};
|
||||
};
|
||||
}
|
||||
|
||||
const cardSizeRange = document.getElementById('card-size-range');
|
||||
if (cardSizeRange) {
|
||||
cardSizeRange.value = App.storage.getCardScale();
|
||||
cardSizeRange.oninput = () => {
|
||||
App.storage.setCardScale(cardSizeRange.value);
|
||||
App.ui.applyCardScale();
|
||||
};
|
||||
}
|
||||
|
||||
const textSizeRange = document.getElementById('text-size-range');
|
||||
if (textSizeRange) {
|
||||
textSizeRange.value = App.storage.getFontScale();
|
||||
textSizeRange.oninput = () => {
|
||||
App.storage.setFontScale(textSizeRange.value);
|
||||
App.ui.applyFontScale();
|
||||
};
|
||||
}
|
||||
|
||||
const feedEndSelect = document.getElementById('feed-end-select');
|
||||
if (feedEndSelect) {
|
||||
feedEndSelect.value = App.storage.getFeedEndBehavior();
|
||||
@@ -420,6 +519,13 @@ App.ui = App.ui || {};
|
||||
|
||||
if (reloadChannelBtn) {
|
||||
reloadChannelBtn.onclick = () => {
|
||||
// Refresh means "give me the current everything": the videos
|
||||
// below, and the app itself. The version check runs in the
|
||||
// background and only acts if the deployed assets actually
|
||||
// differ from what this tab is running.
|
||||
if (App.version && typeof App.version.checkNow === 'function') {
|
||||
App.version.checkNow();
|
||||
}
|
||||
App.videos.resetAndReload();
|
||||
};
|
||||
}
|
||||
@@ -568,10 +674,77 @@ App.ui = App.ui || {};
|
||||
};
|
||||
|
||||
// Expose inline handlers + keyboard shortcuts.
|
||||
// Settings -> Hot Tub Backup: pick an exported database and merge the
|
||||
// favorites out of it. Bound once (unlike the controls in renderMenu, which
|
||||
// are re-assigned on every render) because a file input mid-read must not
|
||||
// have its handler swapped underneath it.
|
||||
App.ui.bindBackupImport = function() {
|
||||
const button = document.getElementById('import-favorites-btn');
|
||||
const input = document.getElementById('import-favorites-file');
|
||||
const status = document.getElementById('import-favorites-status');
|
||||
if (!button || !input) return;
|
||||
|
||||
const say = (message) => { if (status) status.textContent = message; };
|
||||
|
||||
button.addEventListener('click', () => {
|
||||
// Cleared first so picking the same file twice still fires change.
|
||||
input.value = '';
|
||||
input.click();
|
||||
});
|
||||
|
||||
input.addEventListener('change', () => {
|
||||
const file = input.files && input.files[0];
|
||||
if (!file) return;
|
||||
button.disabled = true;
|
||||
say('Reading backup…');
|
||||
App.hottubBackup.importFile(file).then((result) => {
|
||||
if (!result.found) {
|
||||
say('No favorites found in that backup.');
|
||||
} else if (!result.added) {
|
||||
say(`Nothing new: all ${result.found} favorites in that backup are already saved.`);
|
||||
} else {
|
||||
const plural = result.added === 1 ? 'favorite' : 'favorites';
|
||||
const already = result.skipped ? ` ${result.skipped} were already saved.` : '';
|
||||
say(`Imported ${result.added} ${plural}.${already}`);
|
||||
}
|
||||
}).catch((err) => {
|
||||
say('Could not read that file.');
|
||||
App.ui.showError((err && err.message) || 'Could not read that backup.');
|
||||
}).then(() => {
|
||||
button.disabled = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Favorites bar header: the sort order (which applies to the bar and the
|
||||
// favorites grid alike) and the toggle into that grid.
|
||||
App.ui.bindFavoritesControls = function() {
|
||||
const select = document.getElementById('favorites-sort');
|
||||
const button = document.getElementById('favorites-browse-btn');
|
||||
|
||||
if (select && !select.options.length) {
|
||||
App.favorites.SORTS.forEach((sort) => {
|
||||
const option = document.createElement('option');
|
||||
option.value = sort.id;
|
||||
option.textContent = sort.label;
|
||||
select.appendChild(option);
|
||||
});
|
||||
select.value = App.favorites.getSort();
|
||||
select.addEventListener('change', () => App.favoritesView.applySort(select.value));
|
||||
}
|
||||
|
||||
if (button) {
|
||||
button.addEventListener('click', () => App.favoritesView.toggle());
|
||||
}
|
||||
App.favoritesView.syncControls();
|
||||
};
|
||||
|
||||
App.ui.bindGlobalHandlers = function() {
|
||||
App.ui.bindBackupImport();
|
||||
App.ui.bindFavoritesControls();
|
||||
|
||||
window.toggleDrawer = App.ui.toggleDrawer;
|
||||
window.closeDrawers = App.ui.closeDrawers;
|
||||
window.closePlayer = App.player.close;
|
||||
window.handleSearch = App.videos.handleSearch;
|
||||
|
||||
const modeToggleBtn = document.getElementById('mode-toggle-btn');
|
||||
|
||||
@@ -49,15 +49,16 @@ App.version = App.version || {};
|
||||
return changed;
|
||||
}
|
||||
|
||||
// A reload is "safe" when the user isn't mid-playback: no open video modal,
|
||||
// no active reels feed, and no playing <video>. App state survives a reload
|
||||
// because it is restored from localStorage on boot.
|
||||
// A reload is "safe" when the user isn't mid-playback: no open custom
|
||||
// player, no active reels feed, and no playing <video>. App state survives
|
||||
// a reload because it is restored from localStorage on boot.
|
||||
function isSafeToReload() {
|
||||
if (App.state && App.state.feedOpen) return false;
|
||||
const modal = document.getElementById('video-modal');
|
||||
if (modal && modal.style.display && modal.style.display !== 'none') return false;
|
||||
const player = document.getElementById('player');
|
||||
if (player && !player.paused && !player.ended) return false;
|
||||
const player = document.getElementById('custom-player');
|
||||
if (player && player.classList.contains('open')) {
|
||||
const video = player.querySelector('.cp-video');
|
||||
if (video && !video.paused && !video.ended) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -113,6 +114,21 @@ App.version = App.version || {};
|
||||
}
|
||||
}
|
||||
|
||||
// Same check the poller runs, on demand: the top-bar refresh button asks for
|
||||
// it so a tab left open across a deploy picks the new build up right then,
|
||||
// rather than up to POLL_INTERVAL_MS later. Changed CSS hot-swaps; changed
|
||||
// JS/HTML reloads as soon as that won't interrupt playback.
|
||||
App.version.checkNow = function() {
|
||||
if (!baseline) {
|
||||
// start() never got a manifest (endpoint down, or it hasn't run
|
||||
// yet). Adopt whatever the server reports now so there's something
|
||||
// to diff against next time -- there's no baseline to compare this
|
||||
// one against, so nothing can be concluded from it today.
|
||||
return fetchVersion().then((latest) => { baseline = latest; }).catch(() => {});
|
||||
}
|
||||
return check();
|
||||
};
|
||||
|
||||
App.version.start = async function() {
|
||||
try {
|
||||
baseline = await fetchVersion();
|
||||
@@ -128,11 +144,12 @@ App.version = App.version || {};
|
||||
check();
|
||||
}
|
||||
});
|
||||
// Re-attempt a deferred reload whenever a video finishes/pauses.
|
||||
const player = document.getElementById('player');
|
||||
if (player) {
|
||||
player.addEventListener('pause', tryReloadWhenSafe);
|
||||
player.addEventListener('ended', tryReloadWhenSafe);
|
||||
}
|
||||
// Re-attempt a deferred reload whenever a video finishes/pauses. The
|
||||
// custom player's <video> is torn down and rebuilt on every open(), so
|
||||
// bind on the capture phase at the document level instead of to a
|
||||
// specific element (media events don't bubble, but capture still sees
|
||||
// them on ancestors).
|
||||
document.addEventListener('pause', tryReloadWhenSafe, true);
|
||||
document.addEventListener('ended', tryReloadWhenSafe, true);
|
||||
};
|
||||
})();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1
media_srv2.log
Normal file
1
media_srv2.log
Normal file
@@ -0,0 +1 @@
|
||||
/bin/bash: line 1: cd: too many arguments
|
||||
Reference in New Issue
Block a user