From bae0b5a38cf03573e6c4141d618221153f510b2c Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 16 Sep 2023 13:18:13 -0400 Subject: [PATCH] revert back to numbered playlist items --- bin/update-playlist | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/update-playlist b/bin/update-playlist index 01cbe134..0e48084d 100755 --- a/bin/update-playlist +++ b/bin/update-playlist @@ -2,8 +2,10 @@ from __future__ import annotations import argparse +import re import json +REMOVE_NUMBERS = re.compile('(?: --)? #[0-9]+$') ESCAPE = {ord('\\'): r'\\', ord('_'): r'\_', ord('['): r'\[', ord(']'): r'\]'} @@ -16,7 +18,8 @@ def _escape(s: str) -> str: def _video_link(video: dict[str, str]) -> str: - return f'[{_escape(video["title"])}]({video["url"]})' + title = _escape(REMOVE_NUMBERS.sub('', video['title'])) + return f'[{title}]({video["url"]})' def main() -> int: @@ -48,8 +51,9 @@ def main() -> int: f.write(f'[playlist]: {playlist_link}\n') f.write('\n') - for video in playlist['videos']: - f.write(f'- {_video_link(video)}\n') + f.write(f'0. {_video_link(playlist["videos"][0])}\n') + for video in playlist['videos'][1:]: + f.write(f'1. {_video_link(video)}\n') return 0