-
-
Notifications
You must be signed in to change notification settings - Fork 52
Add support for loading/saving m3u playlists #813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
teamcons
wants to merge
56
commits into
elementary:main
Choose a base branch
from
teamcons:m3u-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+165
−2
Open
Changes from 5 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
84c0ea8
Add support for loading/saving m3u playlists
teamcons b8c1fc9
clean up a little
teamcons 2bf6d5d
forgot m3u8
teamcons 9a870e5
Update Application.vala
teamcons 9e63326
Remove unrelated change
teamcons 1043e81
Merge branch 'main' into m3u-support
zeebok 3a9d0b2
Update SPDX header
teamcons 8c068d4
Add action
teamcons 6fc1350
Remove mess
teamcons 94f4673
Proper debug line
teamcons 5031481
Separate frontend and backend
ryonakano 52266f4
Fix indentation
ryonakano eeaf754
Use regex to check file suffix
ryonakano bdd5ce7
Do not return incomplete File array if error
ryonakano b328361
Do not use print for debug/warning logs
ryonakano 63316af
Remove unnecessary else and newlines
ryonakano 1ac76dc
Handle error when saving playlist
ryonakano 5e4f494
Distinguish log message
ryonakano d0b99dc
Remove unnecessary cast
ryonakano 0b8637d
Update POTFILES
ryonakano 3bdf7d9
Remove unnecessary semicolon and newlines
ryonakano 8cd61dc
Merge pull request #1 from ryonakano/m3u-support-suggestion
teamcons 837e010
Merge branch 'main' into m3u-support
ryonakano b049444
Add accel for open
teamcons d5a9b66
cleaner fixme
teamcons f9b2f16
Add filters for saving
teamcons b575832
Move saving dialog with opening dialog so we dont jump code to keep a…
teamcons 9db1d46
Make suffix untranslatable
teamcons 42ad97d
Reformulate comment
teamcons f684cc9
rework skip URL
teamcons 463142e
Do not debug() m3u lines
teamcons ba807b3
Stay with a local variable for playback_manager
teamcons 8146856
Leave open accel for a separate PR
teamcons 0202edb
make a private unowned playback manager
teamcons c64b855
Merge branch 'main' into m3u-support
teamcons 7fb3cdb
Merge branch 'main' into m3u-support
teamcons bca0b45
Merge branch 'main' into m3u-support
teamcons 3a702c8
Move savem3u action elsewhere
teamcons 96f3798
Merge branch 'main' into m3u-support
teamcons 9b11698
Move actions
teamcons b5dfbda
themedIcon name
teamcons d415f57
no trycatch for dostream
teamcons fb304ea
Merge branch 'main' into m3u-support
zeebok 07fdbc7
Merge branch 'main' into m3u-support
teamcons 31c6d12
Merge branch 'main' into m3u-support
teamcons f2836a1
Merge branch 'main' into m3u-support
teamcons 9b9b766
Have the Application handle errors instead of leaving it to the parser
teamcons d2f73ae
Introduce M3U.is_playlist() method
teamcons a1a2599
Allow filtering specifically for playlists
teamcons b2c2fa4
Merge branch 'main' into m3u-support
teamcons 676015c
Merge branch 'main' into m3u-support
teamcons 4f05230
Merge branch 'main' into m3u-support
zeebok 7d4b719
Update src/Application.vala
teamcons fdb1137
move code out of trycatch block
teamcons 8e8bec9
Fix invisible local variable
ryonakano c0936d8
Merge branch 'main' into m3u-support
teamcons File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,5 @@ | |
| .flatpak-builder | ||
| .flatpak | ||
| build | ||
| .vscode/settings.json | ||
| .gitignore | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * SPDX-License-Identifier: LGPL-3.0-or-later | ||
| * SPDX-FileCopyrightText: 2021 elementary, Inc. (https://elementary.io) | ||
teamcons marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
|
|
||
| namespace Music.M3U { | ||
|
|
||
| // Standard specification here: https://en.wikipedia.org/wiki/M3U | ||
| public File[] parse_playlist (File playlist) { | ||
| debug ("Parsing playlist: " + playlist.get_basename () + "\n"); | ||
teamcons marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| File[] list = {}; | ||
|
|
||
| try { | ||
| FileInputStream @is = playlist.read (); | ||
| DataInputStream dis = new DataInputStream (@is); | ||
| string line; | ||
|
|
||
| while ((line = dis.read_line ()) != null) { | ||
| print ("%s\n", line); | ||
|
|
||
| // Skip extended | ||
| if (line.has_prefix ("#EXT")) { | ||
| print ("Skipping EXTM3U: " + line + "\n"); | ||
|
|
||
| } else { | ||
| File target; | ||
|
|
||
| if (line.ascii_down ().has_prefix ("file:///")) { | ||
| target = File.new_for_uri (line); | ||
|
|
||
| //FIXME: URL get skipped. | ||
| //} else if (line.ascii_down ().has_prefix ("http")) { | ||
| // print ("URL are currently unsupported:" + line + "\n"); | ||
|
|
||
| } else { | ||
| target = File.new_for_path (line); | ||
|
|
||
| }; | ||
|
|
||
| // We do not need to test yet whether files exist | ||
| list += target; | ||
| } | ||
| } | ||
|
|
||
| } catch (Error e) { | ||
teamcons marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| print ("Error: %s\n", e.message); | ||
| } | ||
|
|
||
| return list; | ||
|
|
||
| } | ||
|
|
||
| public void save_playlist (MainWindow parent, ListStore queue_liststore) { | ||
| debug ("Saving queue as playlist" + "\n"); | ||
| string content = ""; | ||
|
|
||
| for (var i = 0; i < queue_liststore.n_items; i++) { | ||
| var item = (Music.AudioObject)queue_liststore.get_item (i); | ||
| content = content + item.uri + "\n"; | ||
| } | ||
ryonakano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| var save_dialog = new Gtk.FileDialog () { | ||
| initial_name = _("New playlist.m3u") | ||
| }; | ||
|
|
||
| save_dialog.save.begin (parent, null, (obj, res) => { | ||
| try { | ||
| var file = save_dialog.save.end (res); | ||
| var dostream = new DataOutputStream ( | ||
| file.replace ( | ||
| null, | ||
| false, | ||
| GLib.FileCreateFlags.REPLACE_DESTINATION | ||
| ) | ||
| ); | ||
ryonakano marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| dostream.put_string (content); | ||
|
|
||
| } catch (Error err) { | ||
| warning ("Failed to save file: %s", err.message); | ||
ryonakano marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| }); | ||
|
|
||
|
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.