Compare commits

..

2 commits

Author SHA1 Message Date
j
c69ca372ee sort annotations 2024-10-13 17:06:15 +01:00
j
9e00dd09e3 allow adding global yt-dlp flags 2024-10-09 17:49:21 +01:00
4 changed files with 40 additions and 3 deletions

View file

@ -40,8 +40,12 @@ info_key_map = {
'display_id': 'id', 'display_id': 'id',
} }
YT_DLP = ['yt-dlp']
if settings.YT_DLP_EXTRA:
YT_DLP += settings.YT_DLP_EXTRA
def get_info(url, referer=None): def get_info(url, referer=None):
cmd = ['yt-dlp', '-j', '--all-subs', url] cmd = YT_DLP + ['-j', '--all-subs', url]
if referer: if referer:
cmd += ['--referer', referer] cmd += ['--referer', referer]
p = subprocess.Popen(cmd, p = subprocess.Popen(cmd,
@ -93,7 +97,7 @@ def add_subtitles(item, media, tmp):
sub.save() sub.save()
def load_formats(url): def load_formats(url):
cmd = ['yt-dlp', '-q', url, '-j', '-F'] cmd = YT_DLP + ['-q', url, '-j', '-F']
p = subprocess.Popen(cmd, p = subprocess.Popen(cmd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True) stderr=subprocess.PIPE, close_fds=True)
@ -112,7 +116,7 @@ def download(item_id, url, referer=None):
if isinstance(tmp, bytes): if isinstance(tmp, bytes):
tmp = tmp.decode('utf-8') tmp = tmp.decode('utf-8')
os.chdir(tmp) os.chdir(tmp)
cmd = ['yt-dlp', '-q', media['url']] cmd = YT_DLP + ['-q', media['url']]
if referer: if referer:
cmd += ['--referer', referer] cmd += ['--referer', referer]
elif 'referer' in media: elif 'referer' in media:

View file

@ -291,6 +291,8 @@ DATA_UPLOAD_MAX_MEMORY_SIZE = 32 * 1024 * 1024
EMPTY_CLIPS = True EMPTY_CLIPS = True
YT_DLP_EXTRA = []
#you can ignore things below this line #you can ignore things below this line
#========================================================================= #=========================================================================
LOCAL_APPS = [] LOCAL_APPS = []

View file

@ -129,6 +129,7 @@ async function loadData(id, args) {
<span class="icon">${icon.down}</span> <span class="icon">${icon.down}</span>
${layerData.title} ${layerData.title}
</h3>`) </h3>`)
data.layers[layer] = sortBy(data.layers[layer], ["+in", "+created"])
data.layers[layer].forEach(annotation => { data.layers[layer].forEach(annotation => {
if (pandora.url) { if (pandora.url) {
annotation.value = annotation.value.replace( annotation.value = annotation.value.replace(

View file

@ -161,3 +161,33 @@ const getVideoURL = function(id, resolution, part, track, streamId) {
return prefix + '/' + getVideoURLName(id, resolution, part, track, streamId); return prefix + '/' + getVideoURLName(id, resolution, part, track, streamId);
}; };
function getSortValue(value) {
var getSortValue = Ox.cache(function getSortValue(value) {
var sortValue = value;
return sortValue;
}
function sortBy(array, by, map) {
return array.sort(function(a, b) {
var aValue, bValue, index = 0, key, ret = 0;
while (ret == 0 && index < by.length) {
key = by[index].key;
aValue = getSortValue(
map[key] ? map[key](a[key], a) : a[key]
);
bValue = getSortValue(
map[key] ? map[key](b[key], b) : b[key]
);
if ((aValue === null) != (bValue === null)) {
ret = aValue === null ? 1 : -1;
} else if (aValue < bValue) {
ret = by[index].operator == '+' ? -1 : 1;
} else if (aValue > bValue) {
ret = by[index].operator == '+' ? 1 : -1;
} else {
index++;
}
}
return ret;
});
}