use same page size for playlist rescan

This commit is contained in:
simon 2021-11-18 16:58:39 +07:00
parent bb889f7f67
commit a1167bac4e
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 12 additions and 9 deletions

View File

@ -358,10 +358,7 @@ class PlaylistSubscription:
"""manage the playlist download functionality"""
def __init__(self):
config = AppConfig().config
self.es_url = config["application"]["es_url"]
self.es_auth = config["application"]["es_auth"]
self.channel_size = config["subscriptions"]["channel_size"]
self.config = AppConfig().config
@staticmethod
def get_playlists(subscribed_only=True):
@ -380,6 +377,8 @@ class PlaylistSubscription:
def change_subscribe(self, playlist_id, subscribe_status):
"""change the subscribe status of a playlist"""
es_url = self.config["application"]["es_url"]
es_auth = self.config["application"]["es_auth"]
playlist_handler = YoutubePlaylist(playlist_id)
playlist_handler.get_playlist_dict()
subed_now = playlist_handler.playlist_dict["playlist_subscribed"]
@ -391,12 +390,12 @@ class PlaylistSubscription:
# update subscribed status
print(f"changing status of {playlist_id} to {subscribe_status}")
headers = {"Content-type": "application/json"}
url = f"{self.es_url}/ta_playlist/_update/{playlist_id}"
url = f"{es_url}/ta_playlist/_update/{playlist_id}"
payload = json.dumps(
{"doc": {"playlist_subscribed": subscribe_status}}
)
response = requests.post(
url, data=payload, headers=headers, auth=self.es_auth
url, data=payload, headers=headers, auth=es_auth
)
if not response.ok:
print(response.text)
@ -415,6 +414,10 @@ class PlaylistSubscription:
missing_videos = []
counter = 1
for playlist in all_playlists:
size_limit = self.config["subscriptions"]["channel_size"]
if size_limit:
playlist_entries = playlist["playlist_entries"][:size_limit]
else:
playlist_entries = playlist["playlist_entries"]
all_missing = [i for i in playlist_entries if not i["downloaded"]]

View File

@ -31,8 +31,8 @@
<div class="settings-group">
<h2 id="subscriptions">Subscriptions</h2>
<div class="settings-item">
<p>Current channel page size: <span class="settings-current">{{ config.subscriptions.channel_size }}</span></p>
<i>Recent videos to check on check pending, max recommended 50.</i><br>
<p>Current page size: <span class="settings-current">{{ config.subscriptions.channel_size }}</span></p>
<i>Recent videos for channels and playlist to check when running <b>Rescan subscriptions</b>, max recommended 50.</i><br>
{{ app_form.subscriptions_channel_size }}
</div>
<div class="settings-item">