From e51d0cdbdd9104b53ecdacb6888e50794d5f6d17 Mon Sep 17 00:00:00 2001 From: girst Date: Tue, 20 Oct 2020 19:20:33 +0200 Subject: [PATCH] further improve detector --- app/youtube/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/youtube/__init__.py b/app/youtube/__init__.py index 899c35c..b325af7 100644 --- a/app/youtube/__init__.py +++ b/app/youtube/__init__.py @@ -156,7 +156,10 @@ def plain_user_or_video(something): # short-urls. so we check if it's a channel by querying the RSS feed (this # shoudn't be rate-limited); if that fails, check if it looks like a video # id; or finally give up. - if channel_exists(something): + if '.' not in feed_id and channel_exists(something): + # periods are not valid in usernames, vanity urls or ucids, but common + # in urls that get crawled by bots (e.g. index.php). failing early + # reduces the amount of invalid channel names getting looked up. return redirect(url_for('.channel', channel_id=something)) elif re.match(r"^[-_0-9A-Za-z]{11}$", something): # looks like a video id return redirect(url_for('.watch', v=something, t=request.args.get('t'))) -- 2.39.3