Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/cleanurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,14 @@ def __canonical_youtube(
if len(path_parts) >= 3 and path_parts[-1] != "":
video_id = path_parts[-1]

if video_id and not respect_semantics:
video_id = video_id.lower()

if video_id:
return "youtu.be", "/" + video_id.lower(), [], None
return "youtu.be", "/" + video_id, [], None

if host_remap and host == "dev.tube" and path.startswith("/video/"):
return "youtu.be", path[len("/video") :].lower(), [], None
if host_remap and host == "dev.tube" and path.startswith("/video/"):
return "youtu.be", path[len("/video") :], [], None


def __canonical_medium(
Expand Down
6 changes: 6 additions & 0 deletions src/test_cleanurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ def test_semantics(self):
"groups.google.com/g/golang-nuts",
"https://www.typescriptlang.org/play#code/JYOwLgpgTgZghgYwgAjMg3gWAFDL8uAIwQC4MBzMgZzClHIF8BuHfZAEwhjPXbJACuAW0LRmOBjhwIA9iBrJuyAApwoYYHAA2AHjAA+ZAF4MrfEVIUyAcgAW1hgBozeTkt5kA7JOzjs0uQU4Y2RrC2sCKmQAawgATxkYVBZ-bFl5NCgQmABtOABdFNyCkKgmIA",
"www.typescriptlang.org/play?code=JYOwLgpgTgZghgYwgAjMg3gWAFDL8uAIwQC4MBzMgZzClHIF8BuHfZAEwhjPXbJACuAW0LRmOBjhwIA9iBrJuyAApwoYYHAA2AHjAA%2BZAF4MrfEVIUyAcgAW1hgBozeTkt5kA7JOzjs0uQU4Y2RrC2sCKmQAawgATxkYVBZ-bFl5NCgQmABtOABdFNyCkKgmIA",
"https://www.youtube.com/watch?v=71SsVUmT1ys&ignore=query",
"youtu.be/71SsVUmT1ys",
"https://dev.tube/video/EZ05e7EMOLM",
"youtu.be/EZ05e7EMOLM",
"https://www.youtube.com/embed/71SsVUmT1ys?ignore=query",
"youtu.be/71SsVUmT1ys",
]

for u, r in zip(urls[0::2], urls[1::2]):
Expand Down