add duration field cuz the probing shit is an unfixable mess

pull/216/head
Aevann 2023-10-13 17:53:41 +03:00
parent 10461fa27e
commit 059204bb24
2 changed files with 15 additions and 11 deletions

View File

@ -1950,6 +1950,7 @@ def schedule_orgy(v):
link = request.values.get("link", "").strip()
title = request.values.get("title", "").strip()
start_utc = request.values.get("start_utc", "").strip()
duration = request.values.get("duration", "").strip()
if not link:
abort(400, "A link is required!")
@ -1967,8 +1968,6 @@ def schedule_orgy(v):
else:
start_utc = int(time.time())
end_utc = None
if bare_youtube_regex.match(normalized_link):
orgy_type = 'youtube'
data, _ = get_youtube_id_and_t(normalized_link)
@ -1981,18 +1980,15 @@ def schedule_orgy(v):
elif any((normalized_link.lower().endswith(f'.{x}') for x in VIDEO_FORMATS)):
orgy_type = 'file'
data = normalized_link
#not deduped, cuz cron checks local file, it can't check the url cuz of referrer restriction
try:
video_info = ffmpeg.probe(data)
except:
pass
else:
seconds = float(video_info['streams'][0]['duration'])
if seconds == 2.0: raise
end_utc = int(start_utc + seconds)
else:
abort(400)
if duration:
duration = int(duration)
end_utc = int(start_utc + duration)
else:
end_utc = None
orgy = Orgy(
title=title,
type=orgy_type,

View File

@ -38,6 +38,14 @@
<input autocomplete="off" type="number" step="any" name="start_utc" max="2147483647" class="form-control" placeholder="Leave blank to start orgy now">
</div>
</div>
<div class="d-lg-flex border-bottom mt-3">
<div class="title w-lg-25">
<label for="link">Duration (in seconds)</label>
</div>
<div class="body w-lg-100">
<input autocomplete="off" type="number" step="any" name="duration" max="2147483647" class="form-control" placeholder="Optional">
</div>
</div>
<input hidden name="formkey" value="{{v|formkey}}">
<div class="d-flex mt-3">
<input id="start-orgy" autocomplete="off" class="btn btn-primary ml-auto" type="submit" value="Schedule Orgy">