Skip to content

Commit a35e47f

Browse files
committed
util: fix instagram fiename pattern
1 parent 29bcf13 commit a35e47f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

util.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
TWITTER_FILENAME_RE = re.compile(r'^(?P<screen_name>\w+)-(?P<id>\d+)-(?P<date>\d{8})_(?P<time>\d{6})-(?P<type>[^-.]+?)(?P<index>\d*)(?P<dupe> *\(\d+\))?(?P<suffix>\.(?:mp4|zip|jpg|png))$')
2828
TWITTER_FILENAME_RELEXED_RE = re.compile(r'^(?:(?P<prefix>.+?)(?: +?|[-]??))??(?P<screen_name>\w+)-(?P<id>\d+)-(?P<date>\d{8})_(?P<time>\d{6})-(?P<type>[^-.]+?)(?P<index>\d*)(?P<extra>[ _-].+?)??(?P<dupe> *\(\d+\))?(?P<suffix>\.(?:mp4|zip|jpg|png))$')
2929

30+
# 240521_osk_airi_C7OgZYqPbyI.jpg
31+
# 241101_o_rikachi_o_DBz6UC3TZCL_5.jpg
32+
# 241101_o_rikachi_o_STORY_3491384076140533984.jpg
33+
INSTAGRAM_FILENAME_RE = re.compile(r'^(?P<date>\d{6})_(?P<user_id>.+?)_(?:STORY_(?P<story_id>\d+)|(?P<post_id>[\-_A-Za-z0-9]{11})(?:_(?P<index>\d+))?)(?P<suffix>\.[^.]+)$')
3034

3135
# ==================== data structure manipulation & misc. ====================
3236
def to_list(a):
@@ -285,6 +289,17 @@ def array_to_range_text(a, sep=', ', dash='-'):
285289
return s
286290

287291
def compare_obj(value_old, value, print_prefix='ROOT', mute=False):
292+
'''
293+
Compare two objects and print the differences.
294+
value_old: the old object
295+
value: the new object
296+
print_prefix: the prefix to print before the key
297+
mute: whether to print the differences or not
298+
299+
Returns:
300+
bool: whether the two objects are equal or not
301+
'''
302+
288303
# pip install rich
289304
from rich import print as rprint
290305

0 commit comments

Comments
 (0)