Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Conversation

@tfiedlerdejanze
Copy link
Collaborator

Some ugly string manipulation to name and rename playlists with Paracusia. It misses a commit for reading the card id (that obviously does not change when renaming the playlist). I'll add that as well as some styling for this 😬

With some extra key value storage we could probably just add a name to the playlist, without changing the id of the .m3u file and therefore not breaking the cards. If you have some thoughts on that, let me know :)

end
end

defp extract_playlist_name(name) do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something like this where you can extract the name and ID in one go? Then we don't need any temporary indicators like # in strings. We can just extract the ID and name, then generate the new names straight away with "#{id} - #{name}"

re = ~r/\A(?<id>\d+)(?:\W+(?<name>.+))?\z/

iex> Regex.named_captures(re, "123456 - dope tunes")
%{"id" => "123456", "name" => "dope tunes"}

iex> Regex.named_captures(re, "1234")
%{"id" => "1234", "name" => ""}

iex> Regex.named_captures(re, "derp")
nil

|> Regex.named_captures(playlist)
|> case do
%{"tag_id" => tag_id} -> tag_id
case Musicbox.Player.playlist_information(playlist) do
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably time for the extra Playlist module. But it works as is

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants