cleanup, fix lint

This commit is contained in:
simon 2022-12-23 20:43:36 +07:00
parent 6ed2308f99
commit 0b60377e19
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 278 additions and 97 deletions

348
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,6 @@ from home.src.download.subscriptions import (
ChannelSubscription,
PlaylistSubscription,
)
from home.src.frontend.watched import WatchState
from home.src.index.playlist import YoutubePlaylist
from home.src.ta.helper import UrlListParser
from home.src.ta.ta_redis import RedisArchivist, RedisQueue
@ -47,8 +46,6 @@ class PostData:
def exec_map(self):
"""map dict key and return function to execute"""
exec_map = {
"watched": self._watched,
"un_watched": self._un_watched,
"change_view": self._change_view,
"change_grid": self._change_grid,
"rescan_pending": self._rescan_pending,
@ -72,16 +69,6 @@ class PostData:
return exec_map[self.to_exec]
def _watched(self):
"""mark as watched"""
WatchState(self.exec_val, is_watched=True).change()
return {"success": True}
def _un_watched(self):
"""mark as unwatched"""
WatchState(self.exec_val, is_watched=False).change()
return {"success": True}
def _change_view(self):
"""process view changes in home, channel, and downloads"""
origin, new_view = self.exec_val.split(":")

View File

@ -23,14 +23,14 @@ function updateVideoWatchStatus(input1, videoCurrentWatchStatus) {
postVideoProgress(videoId, 0); // Reset video progress on watched/unwatched;
removeProgressBar(videoId);
let watchStatusIndicator, payload;
let apiEndpoint = '/api/watched/'
let watchStatusIndicator;
let apiEndpoint = '/api/watched/';
if (videoCurrentWatchStatus === 'watched') {
watchStatusIndicator = createWatchStatusIndicator(videoId, 'unwatched');
apiRequest(apiEndpoint, 'POST', {id: videoId, "is_watched": false})
apiRequest(apiEndpoint, 'POST', { id: videoId, is_watched: false });
} else if (videoCurrentWatchStatus === 'unwatched') {
watchStatusIndicator = createWatchStatusIndicator(videoId, 'watched');
apiRequest(apiEndpoint, 'POST', {id: videoId, "is_watched": true})
apiRequest(apiEndpoint, 'POST', { id: videoId, is_watched: true });
}
let watchButtons = document.getElementsByClassName('watch-button');
@ -76,7 +76,7 @@ function removeProgressBar(videoId) {
function isWatchedButton(button) {
let youtube_id = button.getAttribute('data-id');
let apiEndpoint = '/api/watched/';
let data = {id: youtube_id, is_watched: true}
let data = { id: youtube_id, is_watched: true };
button.remove();
apiRequest(apiEndpoint, 'POST', data);
setTimeout(function () {
@ -187,7 +187,7 @@ function dlPending() {
function toIgnore(button) {
let youtube_id = button.getAttribute('data-id');
let apiEndpoint = '/api/download/' + youtube_id + '/';
apiRequest(apiEndpoint, 'POST', {status: 'ignore'});
apiRequest(apiEndpoint, 'POST', { status: 'ignore' });
document.getElementById('dl-' + youtube_id).remove();
}
@ -211,7 +211,7 @@ function forgetIgnore(button) {
function addSingle(button) {
let youtube_id = button.getAttribute('data-id');
let apiEndpoint = '/api/download/' + youtube_id + '/';
apiRequest(apiEndpoint, 'POST', {status: 'pending'})
apiRequest(apiEndpoint, 'POST', { status: 'pending' });
document.getElementById('dl-' + youtube_id).remove();
setTimeout(function () {
checkMessages();