|
|
@ -9,19 +9,9 @@ from home.src.download.subscriptions import (
|
|
|
|
PlaylistSubscription,
|
|
|
|
PlaylistSubscription,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
from home.src.index.playlist import YoutubePlaylist
|
|
|
|
from home.src.index.playlist import YoutubePlaylist
|
|
|
|
from home.src.ta.ta_redis import RedisArchivist, RedisQueue
|
|
|
|
from home.src.ta.ta_redis import RedisArchivist
|
|
|
|
from home.src.ta.urlparser import Parser
|
|
|
|
from home.src.ta.urlparser import Parser
|
|
|
|
from home.tasks import (
|
|
|
|
from home.tasks import run_restore_backup, subscribe_to
|
|
|
|
download_pending,
|
|
|
|
|
|
|
|
kill_dl,
|
|
|
|
|
|
|
|
re_sync_thumbs,
|
|
|
|
|
|
|
|
rescan_filesystem,
|
|
|
|
|
|
|
|
run_backup,
|
|
|
|
|
|
|
|
run_manual_import,
|
|
|
|
|
|
|
|
run_restore_backup,
|
|
|
|
|
|
|
|
subscribe_to,
|
|
|
|
|
|
|
|
update_subscribed,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PostData:
|
|
|
|
class PostData:
|
|
|
@ -46,20 +36,13 @@ class PostData:
|
|
|
|
exec_map = {
|
|
|
|
exec_map = {
|
|
|
|
"change_view": self._change_view,
|
|
|
|
"change_view": self._change_view,
|
|
|
|
"change_grid": self._change_grid,
|
|
|
|
"change_grid": self._change_grid,
|
|
|
|
"rescan_pending": self._rescan_pending,
|
|
|
|
|
|
|
|
"dl_pending": self._dl_pending,
|
|
|
|
|
|
|
|
"queue": self._queue_handler,
|
|
|
|
|
|
|
|
"unsubscribe": self._unsubscribe,
|
|
|
|
"unsubscribe": self._unsubscribe,
|
|
|
|
"subscribe": self._subscribe,
|
|
|
|
"subscribe": self._subscribe,
|
|
|
|
"sort_order": self._sort_order,
|
|
|
|
"sort_order": self._sort_order,
|
|
|
|
"hide_watched": self._hide_watched,
|
|
|
|
"hide_watched": self._hide_watched,
|
|
|
|
"show_subed_only": self._show_subed_only,
|
|
|
|
"show_subed_only": self._show_subed_only,
|
|
|
|
"show_ignored_only": self._show_ignored_only,
|
|
|
|
"show_ignored_only": self._show_ignored_only,
|
|
|
|
"manual-import": self._manual_import,
|
|
|
|
|
|
|
|
"re-embed": self._re_embed,
|
|
|
|
|
|
|
|
"db-backup": self._db_backup,
|
|
|
|
|
|
|
|
"db-restore": self._db_restore,
|
|
|
|
"db-restore": self._db_restore,
|
|
|
|
"fs-rescan": self._fs_rescan,
|
|
|
|
|
|
|
|
"delete-playlist": self._delete_playlist,
|
|
|
|
"delete-playlist": self._delete_playlist,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -84,39 +67,6 @@ class PostData:
|
|
|
|
RedisArchivist().set_message(key, {"status": grid_items})
|
|
|
|
RedisArchivist().set_message(key, {"status": grid_items})
|
|
|
|
return {"success": True}
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
|
|
def _rescan_pending():
|
|
|
|
|
|
|
|
"""look for new items in subscribed channels"""
|
|
|
|
|
|
|
|
print("rescan subscribed channels")
|
|
|
|
|
|
|
|
update_subscribed.delay()
|
|
|
|
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
|
|
def _dl_pending():
|
|
|
|
|
|
|
|
"""start the download queue"""
|
|
|
|
|
|
|
|
print("download pending")
|
|
|
|
|
|
|
|
running = download_pending.delay()
|
|
|
|
|
|
|
|
task_id = running.id
|
|
|
|
|
|
|
|
print(f"{task_id}: set task id")
|
|
|
|
|
|
|
|
RedisArchivist().set_message("dl_queue_id", task_id)
|
|
|
|
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _queue_handler(self):
|
|
|
|
|
|
|
|
"""queue controls from frontend"""
|
|
|
|
|
|
|
|
to_execute = self.exec_val
|
|
|
|
|
|
|
|
if to_execute == "stop":
|
|
|
|
|
|
|
|
print("stopping download queue")
|
|
|
|
|
|
|
|
RedisQueue(queue_name="dl_queue").clear()
|
|
|
|
|
|
|
|
elif to_execute == "kill":
|
|
|
|
|
|
|
|
task_id = RedisArchivist().get_message("dl_queue_id")
|
|
|
|
|
|
|
|
if not isinstance(task_id, str):
|
|
|
|
|
|
|
|
task_id = False
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("brutally killing " + task_id)
|
|
|
|
|
|
|
|
kill_dl(task_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _unsubscribe(self):
|
|
|
|
def _unsubscribe(self):
|
|
|
|
"""unsubscribe from channels or playlists"""
|
|
|
|
"""unsubscribe from channels or playlists"""
|
|
|
|
id_unsub = self.exec_val
|
|
|
|
id_unsub = self.exec_val
|
|
|
@ -183,27 +133,6 @@ class PostData:
|
|
|
|
RedisArchivist().set_message(key, value)
|
|
|
|
RedisArchivist().set_message(key, value)
|
|
|
|
return {"success": True}
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
|
|
def _manual_import():
|
|
|
|
|
|
|
|
"""run manual import from settings page"""
|
|
|
|
|
|
|
|
print("starting manual import")
|
|
|
|
|
|
|
|
run_manual_import.delay()
|
|
|
|
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
|
|
def _re_embed():
|
|
|
|
|
|
|
|
"""rewrite thumbnails into media files"""
|
|
|
|
|
|
|
|
print("start video thumbnail embed process")
|
|
|
|
|
|
|
|
re_sync_thumbs.delay()
|
|
|
|
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
|
|
def _db_backup():
|
|
|
|
|
|
|
|
"""backup es to zip from settings page"""
|
|
|
|
|
|
|
|
print("backing up database")
|
|
|
|
|
|
|
|
run_backup.delay("manual")
|
|
|
|
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _db_restore(self):
|
|
|
|
def _db_restore(self):
|
|
|
|
"""restore es zip from settings page"""
|
|
|
|
"""restore es zip from settings page"""
|
|
|
|
print("restoring index from backup zip")
|
|
|
|
print("restoring index from backup zip")
|
|
|
@ -211,13 +140,6 @@ class PostData:
|
|
|
|
run_restore_backup.delay(filename)
|
|
|
|
run_restore_backup.delay(filename)
|
|
|
|
return {"success": True}
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
|
|
def _fs_rescan():
|
|
|
|
|
|
|
|
"""start file system rescan task"""
|
|
|
|
|
|
|
|
print("start filesystem scan")
|
|
|
|
|
|
|
|
rescan_filesystem.delay()
|
|
|
|
|
|
|
|
return {"success": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _delete_playlist(self):
|
|
|
|
def _delete_playlist(self):
|
|
|
|
"""delete playlist, only metadata or incl all videos"""
|
|
|
|
"""delete playlist, only metadata or incl all videos"""
|
|
|
|
playlist_dict = self.exec_val
|
|
|
|
playlist_dict = self.exec_val
|
|
|
|