Skip to content

Commit

Permalink
Added count of already downloaded tracks in playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
Tutislav committed May 29, 2024
1 parent fc0b3d5 commit d38f50a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion neodeemer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ def playlist_load(self, youtube=False):
self.settings_save(False)
if len(tracks) > 0:
label_playlist_info = self.screen_cur.ids.label_playlist_info
label_playlist_info.text = "[b]" + tracks[0]["playlist_name"] + "[/b] - [b]" + str(len(tracks)) + "[/b]" + self.loc.get_r(" songs")
playlist_downloaded_count = tracks[len(tracks) - 1]["playlist_downloaded_count"]
label_playlist_info.text = "[b]" + tracks[0]["playlist_name"] + "[/b] - " + str(playlist_downloaded_count) + "/[b]" + str(len(tracks)) + "[/b]" + self.loc.get_r(" songs")
label_playlist_info.text = font(label_playlist_info.text)
return True
else:
Expand Down
12 changes: 10 additions & 2 deletions neodeemer/songinfoloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,16 @@ def playlist_tracks(self, playlist_id):
tracks.extend(tracks2["items"])
next = tracks2["next"]
position = 0
playlist_downloaded_count = 0
for track in tracks:
track2 = track["track"]
track_dict = self.track_to_dict(track2)
if track_dict["state"] == TrackStates.COMPLETED:
playlist_downloaded_count += 1
track_dict.update({
"playlist_name": playlist_name,
"playlist_file_path": playlist_file_path
"playlist_file_path": playlist_file_path,
"playlist_downloaded_count": playlist_downloaded_count
})
list.append(track_dict)
position += 1
Expand Down Expand Up @@ -529,11 +533,15 @@ def playlist_tracks(self, playlist_url):
playlist_file_path = os.path.join(self.music_folder_path, norm(playlist_name, True, True) + ".m3u")
tracks = tracks2.videos
position = 0
playlist_downloaded_count = 0
for track in tracks:
track_dict = self.track_to_dict(track, True)
if track_dict["state"] == TrackStates.COMPLETED:
playlist_downloaded_count += 1
track_dict.update({
"playlist_name": playlist_name,
"playlist_file_path": playlist_file_path
"playlist_file_path": playlist_file_path,
"playlist_downloaded_count": playlist_downloaded_count
})
list.append(track_dict)
position += 1
Expand Down

0 comments on commit d38f50a

Please sign in to comment.