Skip to content

Commit

Permalink
Add a button to remove playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
Mageas committed Sep 9, 2021
1 parent aa216f7 commit 3875f71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions youtube/local_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ def path_edit_playlist(playlist_name):
number_of_videos_remaining = remove_from_playlist(playlist_name, videos_to_remove)
redirect_page_number = min(int(request.values.get('page', 1)), math.ceil(number_of_videos_remaining/50))
return flask.redirect(util.URL_ORIGIN + request.path + '?page=' + str(redirect_page_number))
if request.values['action'] == 'remove_playlist':
try:
os.remove(os.path.join(playlists_directory, playlist_name + ".txt"))
except OSError:
pass
return flask.redirect(util.URL_ORIGIN + '/playlists')
elif request.values['action'] == 'export':
videos = read_playlist(playlist_name)
fmt = request.values['export_format']
Expand Down
4 changes: 3 additions & 1 deletion youtube/templates/local_playlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#video-remove-container{
display: flex;
justify-content: end;
justify-content: space-between;
margin: 0px auto 15px auto;
}
#playlist-remove-button{
Expand Down Expand Up @@ -56,7 +56,9 @@ <h2 class="playlist-title">{{ playlist_name }}</h2>
</form>
</div>
</div>
<form id="playlist-remove" action="/youtube.com/edit_playlist" method="post" target="_self"></form>
<div id="video-remove-container">
<button type="submit" name="action" value="remove_playlist" form="playlist-remove" formaction="" onclick="return confirm('You are about to permanently delete {{ playlist_name }}\n\nOnce a playlist is permanently deleted, it cannot be recovered.');">Remove playlist</button>
<input type="hidden" name="playlist_page" value="{{ playlist_name }}" form="playlist-edit">
<button type="submit" id="playlist-remove-button" name="action" value="remove" form="playlist-edit" formaction="">Remove from playlist</button>
</div>
Expand Down

0 comments on commit 3875f71

Please sign in to comment.