Compare commits

...

2 Commits

Author SHA1 Message Date
Ventilaar
46e5d8bb02 fuck
All checks were successful
Update worker server / build-and-publish (release) Successful in 19s
Generate docker image / build-and-publish (release) Successful in 20s
2025-01-29 22:23:41 +01:00
Ventilaar
89ce9b1c0a Add error reporting and fix channel add
All checks were successful
Update worker server / build-and-publish (release) Successful in 33s
Generate docker image / build-and-publish (release) Successful in 1m4s
2025-01-29 19:36:06 +01:00
4 changed files with 19 additions and 7 deletions

View File

@@ -32,7 +32,7 @@ def channels():
if request.method == 'POST':
task = request.form.get('task', None)
if task == 'subscribe-websub':
if task == 'add_channel':
channelId = request.form.get('channel_id', None)
originalName = request.form.get('original_name', None)
addedDate = request.form.get('added_date', None)
@@ -163,6 +163,10 @@ def reports():
get_nosql().close_report(value)
flash(f'Report closed {value}')
return redirect(url_for('admin.reports'))
elif task == 'clean-closed':
get_nosql().report_clean()
flash(f'Cleaned closed reports older than 30 days')
return redirect(url_for('admin.reports'))
reports = get_nosql().list_reports()

View File

@@ -248,6 +248,10 @@ class Mango:
_id = ObjectId(_id)
return self.reports.update_one({'_id': _id}, {'$set': {'status': 'closed', 'closing_time': current_time(object=True)}})
def report_clean(self, keep=30):
days = self.datetime.utcnow() - self.timedelta(days=keep)
self.reports.delete_many({'status': 'closed', 'closing_time': {'$lt': days}})
##########################################
# RUNLOG FUNCTIONS #
##########################################
@@ -437,8 +441,8 @@ class Mango:
def queue_emptyQueue(self):
return self.download_queue.delete_many({})
def queue_setFailed(self, videoId):
return self.download_queue.update_one({'id': videoId}, {'$set': {'status': 'failed'}})
def queue_setFailed(self, videoId, reason=None):
return self.download_queue.update_one({'id': videoId}, {'$set': {'status': 'failed', 'fail_reason': reason}})
def queue_getNext(self):
""" Returns a LIST of queue parameters. Function first checks if ID exists, if so deletes and then checks the next queued until queue is empty (None) or queued id does not exist yet."""

View File

@@ -21,8 +21,8 @@ def video_download(videoId):
process = subprocess.run(['/usr/local/bin/yt-dlp', '--config-location', '/var/www/archive.ventilaar.net/goodstuff/config_video.conf', '--', f'https://www.youtube.com/watch?v={videoId}'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
if process.returncode != 0:
return False
return True
return (False, process.stdout)
return (True, None)
@shared_task()
def video_queue():
@@ -38,11 +38,13 @@ def video_queue():
else:
return None
if video_download(videoId):
status, reason = video_download(videoId)
if status:
get_nosql().queue_deleteQueue(videoId)
return True
else:
get_nosql().queue_setFailed(videoId)
get_nosql().queue_setFailed(videoId, reason)
return False
@shared_task()

View File

@@ -144,6 +144,7 @@
<th>endpoint</th>
<th>status</th>
<th>created_time</th>
<th>fail_reason</th>
</tr>
</thead>
<tbody>
@@ -164,6 +165,7 @@
<td>{{ id.get('endpoint') }}</td>
<td>{{ id.get('status') }}</td>
<td>{{ id.get('created_time') }}</td>
<td><textarea class="info">{{ id.get('fail_reason') }}</textarea></td>
</tr>
{% endfor %}
</tbody>