~cadence/tube-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH NewLeaf] Fix recommended videos extraction on IDs starting with - and _

~lomanic
Details
Message ID
<163573025206.19050.14563581369331099556-0@git.sr.ht>
DKIM signature
missing
Download raw message
Patch: +4 -12
From: Lomanic <lomanic@hotmail.fr>

Let's just leverage yt_dlp instead of rolling our own algorithms and fix
this kind of issue (not finding yt_dlp dump file for a given video) once
and for all

Example videos:
* https://www.youtube.com/watch?v=-q78QXpSL2M
* https://www.youtube.com/watch?v=_4SKG5uUEqs
---
 tools/files.py | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/tools/files.py b/tools/files.py
index 027a486..896531b 100644
--- a/tools/files.py
+++ b/tools/files.py
@@ -1,22 +1,14 @@
import os
import re
import yt_dlp.utils

def get_created_files(id):
	# youtube-dl transforms filenames when saving, for example changing - to _ at the start to presumbly not trigger switches in shell, but also in other strange ways too
	patterns = [
		"__+", "_",
		"^_*(-_)?", "",
		"^-", "_"
	]
	trim_id = id
	for find, replace in zip(patterns[::-2], patterns[1::-2]): # for each 2 items in the list
		trim_id = re.sub(find, replace, trim_id)

	sanitized_id = yt_dlp.utils.sanitize_filename(id)
	# all file names then have an underscore before the converted URL
	id += "_"
	trim_id += "_"
	sanitized_id += "_"

	return (f for f in os.listdir() if f.startswith(id) or f.startswith(trim_id))
	return (f for f in os.listdir() if f.startswith(id) or f.startswith(sanitized_id))

def clean_up_temp_files(id):
	created_files = get_created_files(id)
-- 
2.32.0
Details
Message ID
<20211103225222.22311ca5f5e8ba9f06217108@disroot.org>
In-Reply-To
<163573025206.19050.14563581369331099556-0@git.sr.ht> (view parent)
DKIM signature
pass
Download raw message
I had no idea know they exposed this function

patch applied, thank you.
Reply to thread Export thread (mbox)