GithubHelp home page GithubHelp logo

pauloo27 / tuner Goto Github PK

View Code? Open in Web Editor NEW
121.0 4.0 3.0 717 KB

🎡 Search and Play songs from YouTube inside your terminal

License: GNU General Public License v2.0

Go 98.16% Makefile 0.43% Shell 1.41%
golang terminal mpv player lyrics song youtube mpv-mpris album-art playlist

tuner's Introduction

TUNER

Tuner searches and plays songs from YouTube and SoundCloud inside your terminal.

CI status

If you want a GUI application with more features, take a look at Neptune.

Screenshot

Table of Contents

Features

  • Playlists
  • Lyrics
  • Discord Rich Presence
  • No "search rate limits" (Tuner doesn't use the youtube API)
  • Show album art (experimental)
  • SoundCloud search support
  • "I'm Feeling Lucky" (play the first result when ! is used as a prefix for the search query)

Usage

Using Tuner is simple. Just install it and then run tuner inside your terminal. That will launch a interactive player. If that's not what you want, here are some alternative modes:

  • tuner play <search term> (or tuner p): plays the first result found for the search term (a terminal is required).
  • tuner simple-play <search term> (or tuner sp): plays the first result found for the search term but without the interactive player (does not require a terminal).

Quick play with dmenu

You can create a script in /usr/bin/play (or any other folder in your path) with the following content:

#!/bin/bash

search_query="$@"

# when the search query is not defined
if [ -z "$1" ]; then
  search_query=$(echo "stop" | dmenu -p "Play: ")
fi

# when the search query is stop
if [ "$search_query" = "stop" ]; then
  killall tuner -w 
  exit 0
fi

# when the search query is ok to be played
tuner sp "$search_query"

With that, you can use dmenu to quickly play songs, by:

  • Creating a bind to play (that will open a dmenu prompt asking for the search query).
  • Running play <song name> (where song name is not required) in dmenu_run (usually super+d).

Installing

Arch Linux

Install from the AUR (yay -S go-tuner-git).

Debian (also Ubuntu, Linux Mint and PopOS)

Use this install script:

$ wget -O - https://raw.githubusercontent.com/Pauloo27/tuner/master/install-debian.sh | bash

Compile

Tuner is a written in Go, so you will need to install the GoLang compiler. On Arch Linux, you should install the go package.

Dependencies

Before running Tuner you need to install MPV and youtube-dl.

On Arch Linux, the dependencies packages are mpv youtube-dl

On Debian based (Ubuntu, PopOs, Linux Mint, etc), install libmpv-dev via APT and youtube-dl via PIP (sudo -H pip3 install --upgrade youtube-dl).

Font Awesome 5 is also required to display the icons. You can also customize the icons in the icons/icons.go file.

Build

Clone the repository:

$ git clone https://github.com/Pauloo27/tuner.git && cd tuner

Install:

$ make install

Screenshots

Tuner + pfetch:

Screenshot with MOTD

Tuner search menu:

Screenshot search

Tuner + Discord:

Screenshot of Discord Rich Presence

Tuner + cava:

Screenshot playing with CAVA

Tuner + lolcat:

Screenshot playing with CAVA

Album Art (experimental)

The option to show the song Album Art is disabled by default, here's how to enable it:

First install Überzug (on Arch Linux, install the ueberzug package)...

Then open Tuner and type /a in the search bar and restart your Terminal and Tuner.

MPRIS

To enable MPRIS, first install mpv-mpris (it needs to be placed at ~/.config/mpv/scripts/mpris.so or /etc/mpv/scripts/mpris.so).

if you are using Arch Linux and installed Tuner using the go-tuner-git AUR package, it's already installed.

After that, use /mpris command and restart tuner.

Discord

To enable or disable the integration with Discord, type /discord in the search bar.

Keybinds

If keybinds aren't working, try running Tuner with TERM="xterm" tuner. If it doesn't work, restart you terminal and open a issue on GitHub with the output of echo $TERM. If it does work, you can also open the issue or set a alias.

TIP: You can see the keybinds inside Tuner by pressing ?.

  • Arrow Left: Seek 5 seconds back.
  • Arrow Right: Seek 5 seconds.
  • Ctrl C: Stop the player.
  • Space: Play/Pause song.
  • Arrow Down: Decrease the volume.
  • Arrow Up: Increase the volume.
  • ?: Toggle keybind list.
  • L: Toggle loop.
  • P: Toggle lyric.
  • W: Scroll lyric up.
  • S: Scroll lyric down.
  • U: Show video URL.
  • B: Save song to playlist and edit current playlist.
  • R: Shuffle playlist.
  • >: Next song in playlist.
  • <: Previous song in playlist.

Commands

There are a few commands you can type in the search bar:

  • /discord or /dc: Toggle option to show Tuner in Discord.
  • /cache or /c: Toggle option to keep cache (default is false).
  • /album or /a: Toggle option to show album art (default is false).
  • /mpris or /m: Toggle option to load mpv-mpris (default is false).
  • /help or /h: List all commands.

Storage

Tuner data (cache and config) is stored at ~/.cache/tuner. Tuner doesn't keep the songs downloaded, the only cached data is the album art (if the feature is enabled) and the info of playlist entries.

License

GPL Logo

This project is licensed under GNU General Public License v2.0.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

tuner's People

Contributors

dependabot[bot] avatar marssaljr avatar pauloo27 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

tuner's Issues

Improve Debian installation script

Hi!

I just tried tuner and it works well, nice project!

I noticed that there are two problems with the installation script for Debian.

1) golang version

In Debian 10 golang is in version 1.11, and in Debian 11 golang is version 1.15.
https://packages.debian.org/buster/golang-go
https://packages.debian.org/bullseye/golang-go

The installation will fail with this error message:

...

github.com/Pauloo27/tuner/command
github.com/ananagame/rich-go/client
golang.org/x/text/internal/colltab
golang.org/x/text/cases
golang.org/x/text/collate
github.com/dop251/goja
github.com/kkdai/youtube/v2
# github.com/kkdai/youtube/v2
../go/pkg/mod/github.com/kkdai/youtube/[email protected]/client.go:372:9: undefined: io.ReadAll
../go/pkg/mod/github.com/kkdai/youtube/[email protected]/client.go:407:9: undefined: io.ReadAll
note: module requires Go 1.17

So currently in Debian, the golang should be installed from the Go official website, for example:
https://www.linuxcapable.com/how-to-install-go-golang-compiler-on-debian-11/

2) pip3

In Debian, pip3 is not installed with python3 package. Pip3 is installed with python3-pip package.

So after fixing both golang and pip3 issues, the updated installation script would look something like below. The updated script is tested successfully in fresh Debian 11 installation. It should also work in Debian 10.

#!/bin/bash

C_DEEPSKYBLUE3="\033[38;5;32m"
NO_FORMAT="\033[0m"

echo -e "Debian-based install script for
$C_DEEPSKYBLUE3
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— 
β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
   β–ˆβ–ˆβ•‘   β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘
   β•šβ•β•    β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•
$NO_FORMAT
"

echo "Your system info:"
cat /etc/os-release

echo "Installing libmpv-dev, wget, python, git, make, and the Icon Font"
sudo apt-get install fonts-font-awesome libmpv-dev wget git make python3 python3-pip --no-install-recommends

echo "Installing GoLang"
wget https://golang.org/dl/go1.17.linux-amd64.tar.gz
sudo tar -zxvf go1.17.linux-amd64.tar.gz -C /usr/local/
echo "export PATH=/usr/local/go/bin:${PATH}" | sudo tee /etc/profile.d/go.sh
source /etc/profile.d/go.sh

echo "Installing youtube-dl"
sudo -H pip3 install --upgrade youtube-dl

echo "Cloning Tuner..."
git clone https://github.com/Pauloo27/tuner.git

echo "Installing Tuner"
cd tuner
make install

echo "Deleting Tuner local folder"
cd ..
rm -rf tuner

unable to make install - file not found error

When I run make install, below is what I got.

❯ make install
go build -v
golang.org/x/sys/internal/unsafeheader
golang.org/x/net/html/atom
golang.org/x/text/encoding/internal/identifier
golang.org/x/text/internal/utf8internal
github.com/Pauloo27/tuner/icons
golang.org/x/text/internal/tag
golang.org/x/text/transform
golang.org/x/sys/unix
golang.org/x/net/html
golang.org/x/text/language
github.com/Pauloo27/tuner/player/mpv
github.com/buger/jsonparser
github.com/grafov/m3u8
golang.org/x/text/encoding
golang.org/x/text/runes
github.com/pkg/errors
golang.org/x/text/encoding/internal
golang.org/x/text/encoding/charmap
golang.org/x/text/encoding/japanese
golang.org/x/text/encoding/korean
# github.com/Pauloo27/tuner/player/mpv
player/mpv/consts.go:3:10: fatal error: 'mpv/client.h' file not found
#include <mpv/client.h>
         ^~~~~~~~~~~~~~
1 error generated.
golang.org/x/text/encoding/simplifiedchinese
golang.org/x/text/encoding/traditionalchinese
golang.org/x/text/encoding/unicode
github.com/zackradisic/soundcloud-api
golang.org/x/term
github.com/Pauloo27/keyboard
github.com/Pauloo27/tuner/utils
github.com/Pauloo27/tuner/command
github.com/Pauloo27/tuner/search
golang.org/x/text/encoding/htmlindex
github.com/Pauloo27/tuner/storage
golang.org/x/net/html/charset
github.com/anaskhan96/soup
github.com/Pauloo27/tuner/lyric
make: *** [build] Error 2

Features

  • Player controller
    • Play pause
    • Volume
  • Force low resolution when playing audio-only
  • Loop
  • Lyric
  • Playlist
  • Progress bar
  • Album Art

for window ?

please πŸ₯Ί make it also for window . at powershell .

plea please πŸ™

Possibility of chaning the default location of playlists.

Hey!

I've been enjoying your project for a while now. It's great and works like a charm. But there is one thing that has been bothering me.

Having playlists in .cache and lyrics in $HOME feels a bit odd. Could there be any ways of changing the default directory to something else like .config or .cache? I would highly appreciate if this was possible. :)

Cannot start ueberzug

Playlists:
Use #<id> to start a playlist

 Β» Search: 2020/12/15 23:15:51 Cannot start ueberzug
exit status 1

The above error is thrown when I tried to run Tuner after activating ueberzug with /a. I am not a Go developer so I don't understand the cause. Ueberzug is working fine on its own without any issues.

Any tips on how to disable this?. Thanks in advance for this wonderful tool. Also I think a README regarding how to use it properly would be appreciated by the community much more.

Request Feature : Polybar module

i really like this and use it daily, it would be nice to have control over it from polybar (also it would look pretty :3)
thx

Album Image preview not working

I know this feature is experimental, but it doesn't seem to work.
I installed ueberzurg and "show album set to true" and there are no errors, but it is not working
i tried several songs but nothing shows up i even tried the songs that was in the screenshots, the same.

note : I used termite and kitty to test this.

Playing songs

First off, really nice program! Thanks for this cool tool.
That said, the recent upgrade broke playing songs for me.

OS: ArchLinux
package: go-tuner-git (AUR)
version: r305-2126dbc (0.0.4-dev)
Symptoms:

  • searching (which sometimes fails), and subsequently playing a selection 'acts' like it plays for a second, but subsequently fails
  • playing a playlist seems to 'start' each song in the playlist, but subsequently just jump to the next playlist item

build failed

I cloned the repository, installed the dependencies. then I build:

make install

go build -v
album/track_info.go:4:2: found packages md5 (example_test.go) and main (gen.go) in /home/cyberwolf/go/src/crypto/md5
../../../go/src/reflect/abi.go:9:2: import "internal/goarch" is a program, not an importable package
storage/data.go:6:2: found packages rand (example_test.go) and main (gen_cooked.go) in /home/cyberwolf/go/src/math/rand
../../../go/bin/pkg/mod/github.com/anaskhan96/[email protected]/soup.go:13:2: found packages http (alpn_test.go) and main (triv.go) in /home/cyberwolf/go/src/net/http
img/ueberzug.go:6:2: found packages exec (bench_test.go) and main (read3.go) in /home/cyberwolf/go/src/os/exec
../../../go/src/internal/reflectlite/value.go:10:2: found packages runtime (abi_test.go) and main (mkduff.go) in /home/cyberwolf/go/src/runtime
../../../go/src/internal/syscall/unix/at.go:10:2: found packages syscall (asan.go) and main (mkasm.go) in /home/cyberwolf/go/src/syscall
../../../go/src/internal/poll/fd_poll_runtime.go:13:2: found packages time (embed.go) and main (genzabbrs.go) in /home/cyberwolf/go/src/time
../../../go/src/net/interface_bsd.go:12:2: build constraints exclude all Go files in /home/cyberwolf/go/src/vendor/golang.org/x/net/route
make: *** [Makefile:4: build] Error 1

New issue with tuner possibly?

I've really loved using tuner for several months now (tuner really sips on cpu but plays things very nicely), but just today, I noticed one of my songs no longer loads and plays... I'm wondering if possibly new encodings have been introduced or something else is preventing things from playing.

I hope it is just a temporary thing... I don't think rebooting will solve the issue.

I did notice that libmpv seems stuck on 0.32 on my system and there is a 0.35 available. Could that be the cause?

Go get fails to install/get tuner

Hey,

I wanted to try out tuner but go get fails, I think some test ist broken?

β–Έ go get github.com/Pauloo27/tuner
# github.com/Pauloo27/tuner/player/mpv
.go/src/github.com/Pauloo27/tuner/player/mpv/consts.go:3:10: fatal error: mpv/client.h: No such file or directory
    3 | //#include <mpv/client.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
# github.com/Pauloo27/tuner/search
.go/src/github.com/Pauloo27/tuner/search/soundcloud.go:21:30: too many arguments in call to soundcloudapi.New
	have (string, *http.Client)
	want (soundcloudapi.APIOptions)
# github.com/Pauloo27/tuner/player/mpv
../../.go/src/github.com/Pauloo27/tuner/player/mpv/procaddr.go:45:11: fatal error: GL/glx.h: No such file or directory
   45 |  #include <GL/glx.h>
      |           ^~~~~~~~~~
compilation terminated.

Use libmpv instead of a mpris

Using libmpv would make the communication better, faster and compatible with all operating systems.

WIP in branch libmpv. TODO:

  • fix playlist
  • fix display
  • fix progress bar
  • fix album
  • fix keybinds
  • fix fetch lyrics

YouTube playlists?

Can it play YouTube playlists? I tried entering a playlist id and it says "Invalid Playlist".

Trying to make a Dockerfile but it kinda crashes

when playing a song it crashes, havent tested sound out of the container maybe docker run --device /dev/snd -it --rm tuner

FROM golang:latest as builder
RUN apt-get update && apt-get install -y --no-install-recommends git libmpv-dev
WORKDIR /app 
RUN git clone https://github.com/Pauloo27/tuner .
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags='-w -s'  .


FROM python:3-buster

RUN DEBIAN_FRONTEND=noninteractive && \
    apt-get update && \
    apt-get install -y mpv libmpv-dev fonts-font-awesome && \
    rm -rf /var/lib/apt/lists/* && \
    apt-get clean && apt-get purge

RUN pip install youtube-dl

WORKDIR /app

COPY --from=builder /app/tuner /usr/bin/

ENTRYPOINT ["tuner"]

Features

0.0.3

0.0.2

  • soundcloud support (#6)
  • playlist edit (delete, remove song from it)
  • playlist shuffle

Unable to make install

I have followed the instruction from the README but unable to install it. Below are the output after make install :

go build -v
make: go: No such file or directory
make: *** [Makefile:2: build] Error 127

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.