Giter Site home page Giter Site logo

issadarkthing / gomu Goto Github PK

View Code? Open in Web Editor NEW
152.0 5.0 15.0 941 KB

golang TUI music player

License: GNU General Public License v2.0

Go 99.36% Makefile 0.51% Shell 0.13%
golang golang-app terminal terminal-application terminal-app linux go music-player ncurses-tui tview

gomu's Introduction

Gomu (Go Music Player)

Go Report Card Build Status Buy Me A Coffee

Gomu is intuitive, powerful CLI music player. It has embedded scripting language and event hook to enable user to customize their config extensively.

gomu

Features

  • lightweight
  • simple
  • fast
  • show audio files as tree
  • queue cache
  • vim keybindings
  • youtube-dl integration
  • audio file management
  • customizable
  • find music from youtube
  • scriptable config
  • download lyric
  • id3v2 tag editor

Dependencies

If you are using ubuntu, you need to install alsa and required dependencies

$ sudo apt install libasound2-dev go

Optional dependencies can be installed by this command

$ sudo apt install youtube-dl

Installation

$ go get -u github.com/issadarkthing/gomu

For arch users, you can install from the AUR

using yay:

$ yay -S gomu

using aura:

$ sudo aura -A gomu

Configuration

By default, gomu will look for audio files in ~/music directory. If you wish to change to your desired location, edit ~/.config/gomu/config file and change music_dir = path/to/your/musicDir.

Keybindings

Each panel has it's own additional keybinding. To view the available keybinding for the specific panel use ?

Key (General) Description
tab change panel
space toggle play/pause
esc close popup
n skip
q quit
+ volume up
- volume down
f/F forward 10/60 seconds
b/B rewind 10/60 seconds
? toggle help
m open repl
T switch lyrics
c show colors
Key (Playlist) Description
j down
k up
h close node in playlist
a create playlist
l (lowercase L) add song to queue
L add playlist to queue
d delete file from filesystemd
D delete playlist from filesystem
Y download audio
r refresh
R rename
y/p yank/paste file
/ find in playlist
s search audio from youtube
t edit mp3 tags
1/2 find lyric if available
Key (Queue) Description
j down
k up
l (lowercase L) play selected song
d remove from queue
D delete playlist
z toggle loop
s shuffle
/ find in queue
t lyric delay increase 0.5 second
r lyric delay decrease 0.5 second

Scripting

Gomu uses anko as its scripting language. You can read more about scripting at our wiki

Keybinds.def_g("ctrl_x", func() {
    out, err = shell(`echo "hello world"`)
    if err != nil {
        debug_popup("an error occured")
    }
    info_popup(out)
})

Project Background

I just wanted to implement my own music player with a programming language i'm currently learning (Go). Gomu might not be stable as it in constant development. For now, it can fulfill basic music player functions such as:

  • add and delete songs from queue
  • create playlists
  • skip
  • play
  • pause
  • forward and rewind

Similar Projects

  • termusic (Written in rust and well maintained)

Album Photo

For songs downloaded by Gomu, the thumbnail will be embeded as Album cover. If you're not satisfied with the cover, you can edit it with kid3 and attach an image as album cover. Jpeg is tested, but other formats should work as well.

Donation

Hi! If you guys think the project is cool, you can buy me a coffee ;)

Buy Me A Coffee

Seeking and more advanced stuff has not yet been implemented; feel free to contribute.

gomu's People

Contributors

dependabot[bot] avatar issadarkthing avatar kristerj avatar mjholub avatar tramhao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gomu's Issues

Accidentally delete whole directory

I deleted my mp3 directory completely, by accident, but several times.
What I want to do is to clear the queue, but I didn't notice that the focus is not in queue. And right after I confirm the operation(it's too fast by keyboard), I know it's wrong.
Fortunately I have complete backup for 30 days, but I think it's a possible problem.
What's the better logic to solve it?

Focus control

I added a new PR for tag editing and lyric previewing. This is a flex contains a bunch of other controls. I met a problem:
When I use popup message boxes to show the messages, the focus can fallback to flex, but will always focus on the first control in the flex. It's not intuitive. How to avoid focus switching? As the message boxes don't need focus.
Thanks in advance.

Event hook

Event hook will be used to execute user defined function on subscribed events. One of the use cases for this will be to execute notify-send when a song finishes.

Bug after downloading

Recently I found a reproducible bug. The steps to reproduce it:
1.Pause the play
2. Download a song
3. Add the newly downloaded song to playlist.

Now the playbar progress runs twice speed but the music seems normal. After the progress bar finish, the music will stop and cannot play new songs.

i18n support

Do you think it's good to have i18n support? I checked pkg.go.dev and found several packages with similar popularity. Cannot figure out the good one to choose.

More publicity

As it's been working quite well now, how about post to awesome-go and tview repo so that more people can use it?

Problem regarding cpu usage

I met a problem for both beep and mpd:
When open the app, the cup usage for gomu in gotop for mpd is about 2%, and beep is about 20%. After pressing N for like 10 seconds or more (skip), the cup usage for mpd is 40% and beep is 50%, and they don't drop back.

I think it's probably related to the go routine for play. I mean, the player.Run is in go routing, and it never returns, but it will spawn another go routine for next song.

What do you think?

Installation errors

Hi there! This app looks very interesting, but I cannot install it (Pop!_OS 20.04) getting these errors:

$ go get -u github.com/issadarkthing/gomu
# github.com/rivo/tview
go/src/github.com/rivo/tview/box.go:343:63: cannot convert b.borderAttributes (type tcell.AttrMask) to type tcell.Style
go/src/github.com/rivo/tview/table.go:331:108: cannot convert attributes (type tcell.AttrMask) to type tcell.Style
go/src/github.com/rivo/tview/table.go:888:150: cannot convert cell.Attributes (type tcell.AttrMask) to type tcell.Style
go/src/github.com/rivo/tview/table.go:957:63: cannot convert a (type tcell.AttrMask) to type tcell.Style
go/src/github.com/rivo/tview/table.go:1020:24: invalid operation: t.selectedStyle != 0 (mismatched types tcell.Style and int)

Purging big files

I will be deleting all unnecessary files from the repository that makes it bloated, This means all local repository should be deleted and clone a new one instead. If there are commits in your local repo, you can make patches out of it and apply to a new cloned repo.

Unable to use it

After install from AUR using paru

$ paru -Qi gomu
Name            : gomu
Version         : 2.1.1-1
Description     : Terminal User Interface (TUI) Music Player
Architecture    : x86_64
URL             : https://github.com/issadarkthing/gomu
Licenses        : GPL
Groups          : None
Provides        : None
Depends On      : alsa-lib  youtube-dl
Optional Deps   : fzf [installed]
Required By     : None
Optional For    : None
Conflicts With  : gomu-git  gomu-bin
Replaces        : None
Installed Size  : 12.13 MiB
Packager        : Unknown Packager
Build Date      : Tue 19 Apr 2022 04:58:22 PM CST
Install Date    : Tue 19 Apr 2022 04:58:34 PM CST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : None

$ gomu
open /home/chz/.config/gomu/config: no such file or directory

After I create /home/chz/.config/gomu/config and add

$ cat ~/.config/gomu/config
music_dir = ~/Music
$ gomu -version
Gomu
$ gomu
syntax error: unexpected $unk

Data Race happened

When I build with go build -race, and run ./gomu, I get many data races like below:

WARNING: DATA RACE
Write at 0x00c0002207f8 by main goroutine:
  github.com/issadarkthing/gomu/player.(*Player).Run()
      /home/tramhao/.local/src/gomu/player/player.go:137 +0x671
  main.(*Queue).enqueue()
      /home/tramhao/.local/src/gomu/queue.go:162 +0x673
  main.(*Queue).loadQueue()
      /home/tramhao/.local/src/gomu/queue.go:271 +0x16f
  main.start()
      /home/tramhao/.local/src/gomu/start.go:421 +0x19ce
  main.main()
      /home/tramhao/.local/src/gomu/main.go:21 +0x232

Previous read at 0x00c0002207f8 by goroutine 15:
  github.com/issadarkthing/gomu/player.(*Player).IsPaused()
      /home/tramhao/.local/src/gomu/player/player.go:241 +0x124
  main.(*PlayingBar).run()
      /home/tramhao/.local/src/gomu/playingbar.go:69 +0xc9
  main.start.func1.1()
      /home/tramhao/.local/src/gomu/start.go:377 +0x6b

Goroutine 15 (running) created at:
  main.start.func1()
      /home/tramhao/.local/src/gomu/start.go:376 +0x25e
  github.com/issadarkthing/gomu/player.(*Player).execSongStart()
      /home/tramhao/.local/src/gomu/player/player.go:75 +0xbf6
  github.com/issadarkthing/gomu/player.(*Player).Run()
      /home/tramhao/.local/src/gomu/player/player.go:90 +0x68
  main.(*Queue).enqueue()
      /home/tramhao/.local/src/gomu/queue.go:162 +0x673
  main.(*Queue).loadQueue()
      /home/tramhao/.local/src/gomu/queue.go:271 +0x16f
  main.start()
      /home/tramhao/.local/src/gomu/start.go:421 +0x19ce
  main.main()
      /home/tramhao/.local/src/gomu/main.go:21 +0x232
==================
Found 5 data race(s)

lang written doesn't not comply to standard

Currently lang for uslt and sylt are both eng, not actually the language of lyrics.
We could write the actual language easily when fetch lyrics, but for lyrics from youtube, I didn't find any specification for the language extension.
What do you think?

High cpu usage

Today I checked the top of gomu, and found 50% cpu usage, which is normally below 20%.
Seems something wrong.

pic-full-210310-1250-27

Support more sorting type

As of recent merged pr #41 where I mention we cannot directly access the creation time of file #41 (comment). I am still indecisive on we should use ctime or mtime as both have different behavior.

mtime changes if tag is changed but does not change if renamed
ctime changes if audio file is renamed but does not change if tag is changed

This leads me to add more sorting option to leave the decision up to the user. Few sort options I would like to implement are ctime, name and audio length.

Let me know which sorting options are redundant and irrelevant to the app itself. More sorting options suggestion are welcomed!

Supported Audio Formats

Hi, I tried GOMU it looks promising. But unfortunately, I could not play m4a files, says

mp3: free bitrate format is not supported. Header word is 0xffff0000 at position 83679

Although I could play mp3 files, most of my files are m4a. It would be nice if you could list out the supported formats upfront. I hope in the future gomu supports lossless codecs.

Occasional pause

I notice after some time, song randomly paused for like 1 seconds. This only happen when it has played a few songs. Currently, I'm not able to reproduce the bug.

Can't change default music dir

From the README:
By default, gomu will look for audio files in ~/music directory.

This doesn't seem to be true; it looks in the ~/Music directory.

I tried changing it to ~/music in the config but it had no effect.

bug: current song is missing after skip

To repeat it, set the loop option to true, then start gomu, skip by n, quit.
Then reopen gomu, the queue lose 1 song.

As I'm not familiar with new player implementation yet, cannot figure it out.

Refactor

Code refactoring should be discussed here.

Add a scripting language

I want to embed a scripting language for this application. The language will be used to set options, configure keybindings #13 , set event listeners or to run shell command. This will greatly add more flexibility to the configuration.

I found a package that is suitable for this https://github.com/mattn/anko. The language is very simple and integrates well with golang types. It also allows us to define arbitrary golang value into the language. For example, it allows function defined in golang into anko.

Lastly, I just think it will be cool to embed a scripting language. Let me know what you guys think.

YTDL finished popup sometimes doesn't show

It's kind of annoying. Sometimes it shows, but about more than half of all chances it just doesn't show. The files were added to playlist just fine. I looked through the code but there is just normal. I don't know the popups and would you please take a look at this problem? Thanks.

Possible bug song played slow

Haven't found a way to reproduce it, but sometimes the song is played slower than normal, means that the tone is lower. I checked player.go, and found speaker.init was called once, with the samplerate of current song. If another song is with different samplerate, it'll be a problem right?
That being said, I've never met a song was played with higher tone.

Lyric support and mp3tag

There are some videos on youtube that have subtitles of different languages, and it could be downloaded with youtube-dl as well. I think we could write it as lyric into mp3 and show it in playingBar(if the timestamp is syncronized) or a different panel(if no timestamp). Several options should be added, for example which language is preferred.

getLength took too long time

When I save a queue with more than 30 songs, reload the queue will take noticeable time to load. When the song is very long, the time is longer as well.
I checked the id3v2 tag, and there is a length tag. Can we use it to speed up the progress?

Build failed

build failed

make                                                                                   ❯❯❯ (master)-[gomu]
=== BUILDING ===
go build -ldflags "-X main.VERSION=v1.5.5" -v -o /home/tramhao/sources/gomu/bin/gomu
github.com/gomu
# github.com/gomu
./gomu.go:53:22: cannot use g.playlist (type *Playlist) as type Panel in slice literal:
        *Playlist does not implement Panel (wrong type for SetBorderColor method)
                have SetBorderColor("github.com/gdamore/tcell/v2".Color) *tview.Box
                want SetBorderColor("github.com/gdamore/tcell".Color) *tview.Box
./gomu.go:53:34: cannot use g.queue (type *Queue) as type Panel in slice literal:
        *Queue does not implement Panel (wrong type for SetBorderColor method)
                have SetBorderColor("github.com/gdamore/tcell/v2".Color) *tview.Box
                want SetBorderColor("github.com/gdamore/tcell".Color) *tview.Box
./gomu.go:53:43: cannot use g.playingBar (type *PlayingBar) as type Panel in slice literal:
        *PlayingBar does not implement Panel (wrong type for SetBorderColor method)
                have SetBorderColor("github.com/gdamore/tcell/v2".Color) *tview.Box
                want SetBorderColor("github.com/gdamore/tcell".Color) *tview.Box
./playingbar.go:120:11: cannot use titleColor (type "github.com/gdamore/tcell".Color) as type "github.com/gdamore/tcell/v2".Color in argument to p.Frame.AddText
./playlist.go:84:23: cannot use gomu.colors.accent (type "github.com/gdamore/tcell".Color) as type "github.com/gdamore/tcell/v2".Color in argument to tview.NewTreeNode(rootTextView).SetColor
./playlist.go:128:27: cannot use func literal (type func(*"github.com/gdamore/tcell".EventKey) *"github.com/gdamore/tcell".EventKey) as type func(*"github.com/gdamore/tcell/v2".EventKey) *"github.com/gdamore/tcell/v2".EventKey in argument to playlist.TreeView.Box.SetInputCapture
./playlist.go:388:34: cannot use gomu.colors.foreground (type "github.com/gdamore/tcell".Color) as type "github.com/gdamore/tcell/v2".Color in
argument to p.prevNode.SetColor
./playlist.go:390:31: cannot use gomu.colors.accent (type "github.com/gdamore/tcell".Color) as type "github.com/gdamore/tcell/v2".Color in argument to currNode.SetColor
./playlist.go:726:30: cannot use gomu.colors.accent (type "github.com/gdamore/tcell".Color) as type "github.com/gdamore/tcell/v2".Color in argument to child.SetColor
./popup.go:88:33: cannot use gomu.colors.popup (type "github.com/gdamore/tcell".Color) as type "github.com/gdamore/tcell/v2".Color in argument
to tview.NewModal().SetText(text).SetBackgroundColor
./popup.go:88:33: too many errors
make: *** [Makefile:34: build] Error 2

I believe this is related to the tview and tcell updates but don't know how to fix... Thanks.

Support up and down arrows in Queue

👋 Just as a quality of life thing; I note that the up & down arrows work fine in Popups (eg when searching) and the Playlist, but not in the Queue, forcing me to switch back and forth between up/down and j/k. (I've used vim for years, but I've never got on board with using h/j/k/l for navigation 😆).

I'd add the extra bindings myself but on a quick peek through the code I didn't see where KeyUp & KeyDown are bound for the Queue. Happy to add it myself if you point out where.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.