From 6306840d45c2c6b97939ba8e02b0e2520f0bd081 Mon Sep 17 00:00:00 2001 From: girst Date: Wed, 24 Jan 2024 22:09:27 +0000 Subject: [PATCH] implement /feeds/videos.xml endpoint navigating to youtube.com/feeds/videos.xml with an invidious redirection addon enabled previously caused us to show a 404, making debugging very inconvenient. --- app/youtube/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/youtube/__init__.py b/app/youtube/__init__.py index 306d74f..1a50c14 100644 --- a/app/youtube/__init__.py +++ b/app/youtube/__init__.py @@ -6,7 +6,7 @@ from urllib.parse import urlparse #from flask_login import current_user, login_required from flask_login import LoginManager, UserMixin, current_user, login_user, logout_user, login_required from flask import Blueprint, render_template, request, redirect, flash, url_for, jsonify, g, current_app -from werkzeug.exceptions import NotFound, BadGateway +from werkzeug.exceptions import BadRequest, NotFound, BadGateway from ..common.common import * from ..common.anticaptcha import submit_captcha @@ -311,6 +311,15 @@ def timedtext(): retval = '\n'.join([line for line, prev in zip(lines, ['']+lines) if not " --> " in prev]) return retval, {'Content-Type': r.headers.get("Content-Type")} +@frontend.route('/feeds/videos.xml') +def xml_feed(): + valid = ("channel_id", "playlist_id", "user") + key = next(iter(request.args), None) + if key not in valid: raise BadRequest + data = fetch_xml(key, request.args[key]) + if not data: raise NotFound + return data, {'content-type': 'text/xml; charset=UTF-8'} + @frontend.route('/manage/subscriptions') # disabled for guest user: @login_required def subscription_manager(): -- 2.39.3