mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-24 05:56:37 +00:00
Add multiple key sorting
This commit is contained in:
parent
40e48c9317
commit
4b60073ef0
@ -1,6 +1,7 @@
|
||||
import os
|
||||
import re
|
||||
import math
|
||||
from operator import itemgetter
|
||||
from pathlib import Path
|
||||
import requests
|
||||
from PIL import Image
|
||||
@ -134,6 +135,15 @@ def seconds_to_timestr(seconds):
|
||||
return '{:02d}:{:02d}:{:02d}'.format(hour, minutes, seconds)
|
||||
|
||||
|
||||
def multi_key_sort(sort_dict, specs, use_reversed=False):
|
||||
result = list(sort_dict)
|
||||
for key, reverse in reversed(specs):
|
||||
result = sorted(result, key=itemgetter(key), reverse=reverse)
|
||||
if use_reversed:
|
||||
return list(reversed(result))
|
||||
return result
|
||||
|
||||
|
||||
def parse_media_format(format_dict):
|
||||
'''
|
||||
This parser primarily adapts the format dict returned by youtube-dl into a
|
||||
|
Loading…
Reference in New Issue
Block a user