Git Product home page Git Product logo

ytermusic's Introduction

YTerMusic

YTeRMUSiC

YTerMusic is a TUI based Youtube Music Player that aims to be as fast and simple as possible.

Screenshots

Choose a playlist Playlist RGB

Features and upcoming features

  • Play your Youtube Music Playlist and Supermix.
  • Memory efficient (Around 20MB of RAM while fully loaded)
  • Cache all downloads and store them
  • Work even without connection (If musics were already downloaded)
  • Automatic background download manager

    Check List

    • Playlist selector
    • Error message display in the TUI
    • Enable connection less music playing
    • Cache limit to not exceed some given disk space
    • A download limit to stop downloading after the queue is full
    • Mouse support
    • Search
    • Custom theming (You can use hex! #05313d = 05313d )

Install

Tip

3rd party AUR packages are available here.

  • Download the latest version from releases.

    Linux

    Install the following libraries:
     sudo apt install alsa-tools libasound2-dev libdbus-1-dev pkg-config
  • Use cargo to install the latest version
     cargo install ytermusic --git https://github.com/ccgauche/ytermusic

Setup

Important

If you're using Firefox enable the "Raw" switch so the cookie isn't mangled. Firefox Raw Switch

  • Give ytermusic authentication to your account, by copying out the headers
    1. Open the https://music.youtube.com website in your browser
    2. Open the developer tools (F12 or Fn + F12)
    3. Go to the Network tab
    4. Find the request to the music.youtube.com document / page
    5. Copy the Cookie header from the associated response request
    6. Create a headers.txt file in one of the checked paths.
    7. Create an entry like this :
     Cookie: <cookie>
     User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
    
  • Then you can start ytermusic

Building from source

  • Clone the repository
  • Install rust https://rustup.rs nightly
  • Run cargo build --release
  • The executable is in target/release/ytermusic.exe or target/release/ytermusic

Usage

  • Use your mouse to click in lists if your terminal has mouse support
  • Press Space to play/pause
  • Press Enter to select a playlist or a music
  • Press f to search
  • Press s to shuffle
  • Press Arrow Right or > to skip 5 seconds
  • Press Arrow Left or < to go back 5 seconds
  • Press CTRL + Arrow Right or CTRL + > to go to the next song
  • Press CTRL + Arrow Left or CTRL + < to go to the previous song
  • Press + for volume up
  • Press - for volume down
  • Press Arrow down to scroll down
  • Press Arrow up to scroll up
  • Press ESC to exit the current menu
  • Press CTRL + C or CTRL + D to exit

Changelog

Beta b0.1.1
 - Added `hide_channels_on_homepage` with a default value of `true` to the config file
 - Added `hide_albums_on_homepage` with a default value of `false` to the config file
 - Fixed default style to support transparency
 - Added more color configuration options

Beta b0.1.0
 - Fixed keyboard handling on windows
 - Improved error handling
 - Fixed youtube downloads
 - Made volume bar optional in config
 - Improved performance and updated dependencies

Alpha a0.0.11

- Added scrollable music view
- Added shuffle functionality
- Fixed some crashes while resizing the app
- Added error messages for invalid headers or cookies
- Added error messages for expired cookies

Alpha a0.0.10

- Speed up the download process
- Fix the download limit
- Fix music artists getting smashed together
- Fix the download manager not downloading all musics
- Improved stability
- Improved logs and added timings to better debug

Alpha a0.0.9:

- Progress info for downloads
- Mouse support on time bar
- Vertical volume bar
- Vertical volume bar supports mouse click
- Scroll to change volume and skip in timeline
- Improved the scrolling action
- Fixed the bug where the time bar would not update
- Debouncing the search input
- Changed the location of the cache folder to follow the XDG Base Directory Specification (By @FerrahWolfeh #20)
- More configuration options (By @ccgauche and @FerrahWolfeh)

Alpha a0.0.8

- Fixed scrolling
- Fixed audio-glitches
- Removed nightly flag use

Alpha a0.0.7

- Major changes in the API
- Fixed log file bloat issue

Alpha a0.0.6

- Fix: Fix a bug where the app would crash when trying to play a song that was not downloaded
- Fix: Improve the logger to not print the same error twice
- Improved startup time
- Fixed linux build
- Changed how task are distributed to the thread pool

Alpha a0.0.5

- Added local database cache to improve IO accesses
- Added searching for musics in the local library
- Greatly improved render performance and RAM usage
- Error management and error display in specific screen

Alpha a0.0.4

- Added menu navigation
- Added searching for musics
- Added new terminal backend

Alpha a0.0.3

- Mouse support to select playlist and music
- Download limiter
- Connection less music playing

Alpha a0.0.2

- Playlist selector
- Improved error management
- Improved TUI
- Performance upgrade
- Switch to Rustls instead of openSSL

ytermusic's People

Contributors

0xflotus avatar alisonjenkins avatar alphare avatar burntranch avatar ccgauche avatar ferrahwolfeh avatar jaxon-teboekhorst avatar konstcode avatar mikebirdgeneau avatar ndom91 avatar rhevin avatar rustmilian avatar sergious234 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  avatar

ytermusic's Issues

Add ability to directly give a playlist URL

Hi,

I've been using ytermusic a lot and it's been great. I still have a few quality of life improvements I'm thinking about discussing, but this one is definitely the biggest issue, since it actually prevents me from listening to certain music.

The Youtube Music search being what it is, sometimes the right album or song does not show up in the results. In the official website/mobile app, you have to - for example - navigate manually to the artist to get to the album and start playing it.

Making the search better seems like a lot to ask, so here's my idea: a mode where you paste something like https://music.youtube.com/playlist?list=<playlist_id> (or just the playlist ID), then ytermusic shows you the songs in that playlist like in the search view, and you can then decide to play it, just like from the search view.

How does that sound?

Wierd compression artifacts on some downloads

I'm not 100% sure how to reproduce this, but when trying out the basic functionality, I got at least one song with weird compression artifacts for a couple of seconds (sounds like it's underwater in one ear).

A workaround would be to allow resetting the cache for a given song/album (when album support is available), which I think is always a good option to have. :)

First time use is confusing

I've updated to the latest version (which changed where my caches are, which I'm not complaining about, this was a good change), and now I can't really figure out what the intended way of getting music to play is.

After a random amount of clicking and spacebar action it stars playing, but there is no clear indication of why.

No content displayed on TUI

Hi, awesome project! I was really looking for a proper yt music api with offline caching program, so, thanks!

Unfortunately, when I run the program (built from source) nothing is populated in the TUI.
I looked at the log file and found only a single line (which is this song):

InvalidJsonCantFind("navigationEndpoint", "{\"text\":\"In Heat (feat. Hentai Xander)\"}")

Search doesn't seem to work

I set up the headers according to the instructions, ran ytermusic, pressed f, entered a search term, pressed enter. Nothing happened, no error message printed. Am I supposed to press something else?

[Feature Request] Config to disable volume widget.

While it's useful for Windows, it isn't on Linux as PipeWire already allows for per-application volume control (see below image). The volume slider tui just makes managing audio harder as it's independent from the native audio controller.
Screenshot_20231205_182258

Not starting under WSL

I assume this is an issue with sound under WSL.

After following the steps I get:

michael@Michaels-PC:~/ytermusic$ sudo ./ytermusic
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
ALSA lib confmisc.c:165:(snd_config_get_card) Cannot get card index for 0
panicked at 'called `Option::unwrap()` on a `None` value', src/systems/player.rs:78:29

Search should be debounced

Currently, searching triggers an API call for (almost?) each keystroke, which pollutes the (google account) search history on top of being wasteful of resources. The local results maybe could still be matched on each keystroke given that there is no search history nor real performance issues.

A debounce of 150-200ms is usually a good bet?

(I'm writing this issue as I come across it, I will take time to answer the other issue I've opened. :) )

Cookie-related issue

So I just discovered this project and it seems really cool. Unfortunately, I can't seem to get it working.

When starting up the program, I cannot search for playlists or anything, and the log file has an InvalidHTMLFile error at the bottom, followed by a large amount of text.

Regarding the cookie, the readme says "Find the request to the music.youtube.com...", but there are so many requests that I am a bit confused about which one I should use. I have tried POST, GET, and HEAD requests, and I am only looking at OK responses. I have copied the cookie to the headers file and added a user agent. I am certain the issue is from the cookie and not the user agent.

I am using the 'alpha-0.0.10' release as the most recent doesn't have an exe so I couldn't get it running.

I have looked at issues to see if anyone else is having/has had a similar issue, and none of the suggested fixes are working.

Any help would be appreciated!

API seems to not work anymore?

I've just come back from a work trip so this might be ~a week old, but the online features of ytermusic do not seem to work anymore. The only playlists showing up are the "last playlist" and "local musics" (sic), and the search is only looking for local songs.

I've updated my Cookie header, but it doesn't work either. Was there a change in the API?

Issue while reading playlists

This will most likely not end up being relevant but I'll include it anyway:
OS: Arch Linux x86_64
Install method: cloned from repo, built using rustup 1.26.0-3

Actual issue and question:
I'm able to launch ytermusic without any errors being thrown but my personal playlists aren't showing up at all.
Instead I get generic suggestions for people in my region, this makes me feel like I'm not actually logged in but I have no idea if its possible to check.

Am I supposed to copy the cookie from a specific request on music.youtube.com? Currently I have copied the string from the first music.youtube.com request that pops up after refreshing the page. Aka the cookie: field under Request Headers.

My account is using security key 2fa, my assumption is that this doesn't matter since it should pass if the cookie is valid. My browser is Brave.
Obviously I won't post my cookie string, but I assume that user agent is fine. This is the general spec of my headers.txt
Cookie: VERYLONGCOOKIESTRING
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Each field is on a separate line.

Building for macOS Souvlaki Error

When I make a build for MacOS with cargo +nightly build --release I get the following error:

error[E0277]: `souvlaki::Error` doesn't implement `std::fmt::Display`
  --> src/systems/player.rs:26:9
   |
23 |       handle_error_option(
   |       ------------------- required by a bound introduced by this call
...
26 | /         MediaControls::new(PlatformConfig {
27 | |             dbus_name: "ytermusic",
28 | |             display_name: "YTerMusic",
29 | |             hwnd: None,
30 | |         }),
   | |__________^ `souvlaki::Error` cannot be formatted with the default formatter
   |
   = help: the trait `std::fmt::Display` is not implemented for `souvlaki::Error`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
note: required by a bound in `handle_error_option`
  --> src/errors.rs:14:8
   |
8  | pub fn handle_error_option<T, E>(
   |        ------------------- required by a bound in this
...
14 |     T: std::fmt::Display,

Allow scrolling in playlist view

Whenever the playlist fills up (which I'm not too sure how, or with what limits?), clicking on a given track will move around all tracks with no clear way of simply looking at the current playlist to pick a song.

Separate scrolling in music player view from the currently playing song

Thanks for implementing scrolling. :)

Scrolling in music player view still triggers SoundAction::Previous(1).apply_sound_action(self); or SoundAction::Next(1).apply_sound_action(self);, making it impossible to scroll through the playlist without changing the current song, something I personally do a lot.

A separate counter should be kept for the "currently selected" and "currently playing", offering a similar interface to the playlist view.

File runs from cwd not from the executables directory

If I have the file in /home/user/.ytermusic, then I add that folder to the PATH, and run it, I get the " The 'headers.txt' file is not present" message, even though the headers.txt file is in the .ytermusic folder and configured properly.

Downloads do not work anymore

It's been a few days at least.

The logs say Error downloading -YXG0fHEFmY: YouTube returned an unexpected response: watch html did not contain a PlayabilityStatus [src/tasks/download.rs] upon failure.

I accidentally removed my .cache folder (I'm sad) and now I can't listen to any music. I haven't looked into the change yet.

Add repeat mechanisms

I frequently listen to new albums on repeat to get a better feel for them, and sometimes individual songs that I really enjoy. Having a way of setting "repeat album" and "repeat song" would be very nice.

The issue I can see with "repeat album" would be that it could confuse the user intent of whether they're asking to replay the whole media player history (if other things were played before), or just the current album/playlist. Not sure if you simply want a third repeat mode. :)

What do you think?

Add a way of manually retrying failed downloads

Sometimes, a song will fail to download and will appear red. I would like to be able to retry this (because it works most of the time if I retry the entire album it's from) without disturbing the current playlist.

20230708_15h06m17s_grim

Suggestion: Upload to crates.io

It is really convenient to install packages with cargo install package_name. It would be really appreciated if we could install ytermusic this way too.

Downloads are very slow

The current behavior when the user opens a playlist is to start 4 parallel jobs to download 4 (arbitrary?) songs from the playlist to local cache, then start playing as soon as one is available.

Since streaming is not yet an option, I see two things that would greatly improve the user experience:

  • ensuring that the user has at least one song to play as fast as possible
  • allowing the user to override the current preferred song to download

The second one should be its own issue because it opens other questions of UI (do we have a way of showing all songs in the playlist and giving control etc.), I only mention it here to be thorough.

When I look at my drive activity, I see that ytermusic is only writing at ~120kb/s when downloading the videos, which is much, much slower than either my gigabit ethernet or my PCIE-4 NVME SSD are capable of handling. This results in having to wait more than 1 minute to start playing a song (and I say a song because I can't really choose which one is being downloaded yet), while 3 others are at 80% completion.

Is there a hard reason why we can't download faster from Youtube? If so, investigating streaming might be the path forwards. On the other hand, if we're limited by the implementation somehow, is the async download pool slow because it's trying to be too clever and not prioritize enough, etc?

can't load playlists from music.youtube.com anymore

I've been using ytermusic for some time. Today I've added (using browser) some new songs to one of my playlists. When I restarted ytermusic (in order to refresh the content of my playlist), it now shows only two items

  1. last played playlist which contains old data and
  2. local music

There used to be along with those two items several others playlists and albums, but now they are all gone.

Maybe Google has changed something in their data format.

Improved Headers File Location: move `headers.txt` file to `XDG_CACHE_HOME` or equivalent

Currently, the program stores the headers.txt header file containing Youtube Music cookie and User Agent in the same directory where the program is executed. I propose moving this header file to a fixed and more appropriate location, such as XDG_CACHE_HOME or $HOME/.cache.

This change would enhance program's cleanliness and facilitate packaging for various Linux distributions. While it's not recommended to scatter files needed by programs in random locations (like /usr/bin or similar prefixes if using an application launcher) cache directories are designed to cater to such use cases.

Your thoughts on this improvement are welcome.

Save the song to the likes playlist

Since you already have the functionality to listen to the playlist of liked songs, could you add the function to save the songs in this playlist?
With a new command, such as CTRL+S (save).

Going back to a playing playlist shouldn't change the play state

Currently if you start a playlist, then go back to the playlist list view, then back inside the playlist, the first song is started again from the start. IMO it shouldn't do anything.

I guess this ties into the (maybe configurable) idea of not auto-playing when going into a playlist, which would allow for browsing, helping #26 be even more useful.

Performance issue on KDE Plasma

ytermusic is a great software and I enjoy using it. However, both my laptop and my desktop run on Linux (Arch Linux and NixOS) and I notice some performance issue.

More specifically, on my laptop, it seems that running the app makes the rest of the DE (KDE Plasma) really slow when I change volume and/or tracks. For instance, the way the volume slider interacts is very unreactive (it takes likes 1 or 2 seconds to actually de/increase the volume by 5%, a thing that you can "spam" usually).

Also, on desktop, this time running the app seems to make more laggy the switch between windows.

I know this bug report is really lacking details, and I hope maybe adding more info, but for now, these are the only info I can give. Nonetheless, if I had to make an educated guess, I would say it is related to the way you use the DBUS API, and would suggest a very high number of calls to the DBUS API, such important it starts to make lag the DE (the Audio apps, or more).

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.