Giter Club home page Giter Club logo

ytermplayer's Introduction

ytTerm player (BETA)

Play youtube playlists as audio on linux terminal

Build Status PyPI version PyPI pyversions PyPI license Downloads

About

ytTerm player is a terminal youtube music player. It's completely written in python.

UI: Made using a wrapper for curses called urwid

Player: Handled using python-mpv

Stream fetch: Audio streams from youtube are fetched using pafy

Features:

  • Import and play youtube playlists on terminal
  • Save playlists in library
  • Use several playback modes such as repeat one, repeat list, random
  • Download complete list (coming soon)

Installation

Set up a virtual environment and install the dependencies:

$ pip install -r requirements.txt

python3 pip :-

$ pip install ytermplayer
$ yterm

or Git clone :-

$ git clone https://github.com/TimeTraveller-San/yTermPlayer
$ cd yTermPlayer/yTermPlayer/
$ python __main__.py

Dependencies

Python 3

ytTerm player uses a number of open source projects to work properly:

ytTerm player itself is open source. Feel free to modify and distribute the code

KeyBindings

Key Function
s save current list
enter select option/play song at selection
n play next song
p play previous song
h play first song
e play last song
space pause/play song
u volume up
d volume down
q quit
1 playback mode: Repeat one
2 playback mode: Repeat list
3 playback mode: None
r playback mode: Random
more features coming soon

Screenshots

Start screen :

Start Screem

The UI will automatically use your terminal colors.

Blue Yellow

FAQ

  • How to fix out of range/url not found errors?

YouTube keeps changing its structure so it's important you have installed the latest version of youtube-dl as follows: pip install --upgrade youtube_dl

  • Where are my playlists stored and how to delete playlists?

Playlists are saved in $HOME/.yTermPlayer/playlists as plain text. You may delete or add new playlists directly here.

  • How to contact me?

Email: [email protected] Twitter: https://twitter.com/timetravellertt

Known Bugs

  • Buggy / unexpected playback behavior It was caused because of race conditions and absence of critical section among the threads. Fixed it using semaphores

  • If some VLC error starts showing up on the screen, just resize the terminal and it will be gone Completely removed VLC and replaced it with much more minimal and faster mpv player. Thank to python-mpv by jaseg

ytermplayer's People

Contributors

4shadoww avatar jaleksi avatar kevcui avatar saltlakeryan avatar samsamhuns avatar vaibkumr avatar vitominheere 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

ytermplayer's Issues

Crash when starting second song from list

I'm using yTermPlayer on macOS Mojave, Python 3.7.3. I've got this crash when the app was about to play the second item on a list

Traceback (most recent call last):
  File "/usr/local/bin/yterm", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/yTermPlayer/__main__.py", line 28, in main
    loop.run()
  File "/usr/local/lib/python3.7/site-packages/urwid/main_loop.py", line 286, in run
    self._run()
  File "/usr/local/lib/python3.7/site-packages/urwid/main_loop.py", line 384, in _run
    self.event_loop.run()
  File "/usr/local/lib/python3.7/site-packages/urwid/main_loop.py", line 788, in run
    self._loop()
  File "/usr/local/lib/python3.7/site-packages/urwid/main_loop.py", line 821, in _loop
    alarm_callback()
  File "/usr/local/lib/python3.7/site-packages/urwid/main_loop.py", line 172, in cb
    callback(self, user_data)
  File "/usr/local/lib/python3.7/site-packages/yTermPlayer/ui.py", line 71, in update_name
    temp = self.player_object.get_time_details()
  File "/usr/local/lib/python3.7/site-packages/yTermPlayer/music_api.py", line 249, in get_time_details
    total_seconds = round(self.player.duration)
TypeError: type NoneType doesn't define __round__ method

Error on startup

  File "c:\Users\phoen\OneDrive\Desktop\yTermPlayer\yTermPlayer\yterm-player.py", line 11, in <module>
    from .music_api import YoutubePlayer
ImportError: attempted relative import with no known parent package```

not working on ubuntu 18.04

Hi after installing the requirements because I only have python 2.7. yterm command is not working on my end. I got this error.

$ yterm
Traceback (most recent call last):
  File "/home/mark/.local/bin/yterm", line 6, in <module>
    from yTermPlayer.__main__ import main
  File "/home/mark/.local/lib/python3.6/site-packages/yTermPlayer/__main__.py", line 11, in <module>
    from .music_api import YoutubePlayer
  File "/home/mark/.local/lib/python3.6/site-packages/yTermPlayer/music_api.py", line 11, in <module>
    import mpv
  File "/home/mark/.local/lib/python3.6/site-packages/mpv.py", line 42, in <module>
    raise OSError("Cannot find libmpv in the usual places. Depending on your distro, you may try installing an "
OSError: Cannot find libmpv in the usual places. Depending on your distro, you may try installing an mpv-devel or mpv-libs package. If you have libmpv around but this script can't find it, maybe consult the documentation for ctypes.util.find_library which this script uses to look up the library filename.

Video in list opens image of video when played

Multiple songs in my playlist open an image of the video when played.

Playlist

Song titles with this issue:
Hydro & War - Jam [Horizons]
Nucleus & Paradox - No Spaced Place

pic-full-190903-2140-51
The image pops up in the current workspace(i3) and cannot be closed unless yterm is also closed. The image closes when the next track is selected.

Cannot load whole playlist (over 200 items)

Playlists with over 200 items cannot be loaded fully and that's because pafy's get_playlist() doesn't support more as it uses old version of the api. Pafy does have another way to get playlists get_playlist2() which could be used to solve the problem.

No module named 'mpv'

Hi there,

I'm fairly new to Python so this could be a user error. After setting up a venv and installing the necessary dependencies for your application for Python3 via pip, I get this error when running the 'yterm' command:

Traceback (most recent call last):
  File "c:\users\jamcmich\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\jamcmich\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\jamcmich\AppData\Local\Programs\Python\Python38-32\Scripts\yterm.exe\__main__.py", line 5, in <module>
  File "c:\users\jamcmich\appdata\local\programs\python\python38-32\lib\site-packages\yTermPlayer\__main__.py", line 11, in <module>
    from .music_api import YoutubePlayer
  File "c:\users\jamcmich\appdata\local\programs\python\python38-32\lib\site-packages\yTermPlayer\music_api.py", line 11, in <module>
    import mpv
ModuleNotFoundError: No module named 'mpv'

How can I resolve this?

Hello, i having an issues

duck@duck:~/Downloads/yTermPlayer/yTermPlayer$ python main.py
Traceback (most recent call last):
File "main.py", line 11, in
from .music_api import YoutubePlayer
ValueError: Attempted relative import in non-package

Could you help me to solve it?

ModuleNotFoundError: No module named 'vlc'

Traceback (most recent call last):
File "/home/timetraveller/miniconda3/bin/yterm", line 7, in
from yTermPlayer.main import main
File "/home/timetraveller/miniconda3/lib/python3.6/site-packages/yTermPlayer/init.py", line 2, in
import vlc
ModuleNotFoundError: No module named 'vlc'

Can't run it

Trying pip method:

C:\Users\Blacklight>yterm
Traceback (most recent call last):
  File "c:\program files (x86)\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files (x86)\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Blacklight\AppData\Roaming\Python\Python37\Scripts\yterm.exe\__main__.py", line 5, in <module>
  File "C:\Users\Blacklight\AppData\Roaming\Python\Python37\site-packages\yTermPlayer\__main__.py", line 11, in <module>
    from .music_api import YoutubePlayer
  File "C:\Users\Blacklight\AppData\Roaming\Python\Python37\site-packages\yTermPlayer\music_api.py", line 11, in <module>
    import mpv
  File "C:\Users\Blacklight\AppData\Roaming\Python\Python37\site-packages\mpv.py", line 31, in <module>
    backend = CDLL('mpv-1.dll')
  File "c:\program files (x86)\python37-32\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

Trying clone method:

D:\Projects\yTermPlayer\yTermPlayer>python __main__.py
Traceback (most recent call last):
  File "__main__.py", line 11, in <module>
    from .music_api import YoutubePlayer
ModuleNotFoundError: No module named '__main__.music_api'; '__main__' is not a package

Can't play live stream video

Traceback (most recent call last):
File "/usr/bin/yterm", line 8, in
details = self.get_url_and_name(index)
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 159, in get_url_and_name
self.playlist['items'][int(index)]['pafy'].getbestaudio().url,
sys.exit(main())
ValueError: cannot convert float NaN to integer

During handling of the above exception, another exception occurred:

File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/main.py", line 28, in main
Traceback (most recent call last):
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 225, in play_at_index
loop.run()
File "/home/frog/.local/lib/python3.9/site-packages/urwid/main_loop.py", line 286, in run
details = self.get_url_and_name(index)
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 159, in get_url_and_name
self.playlist['items'][int(index)]['pafy'].getbestaudio().url,
self._run()
ValueError: cannot convert float NaN to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/frog/.local/lib/python3.9/site-packages/urwid/main_loop.py", line 384, in _run
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 225, in play_at_index
details = self.get_url_and_name(index)
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 159, in get_url_and_name
self.event_loop.run()
File "/home/frog/.local/lib/python3.9/site-packages/urwid/main_loop.py", line 788, in run
self.playlist['items'][int(index)]['pafy'].getbestaudio().url,
ValueError: cannot convert float NaN to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 225, in play_at_index
self._loop()
File "/home/frog/.local/lib/python3.9/site-packages/urwid/main_loop.py", line 821, in _loop
details = self.get_url_and_name(index)
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 159, in get_url_and_name
alarm_callback()
File "/home/frog/.local/lib/python3.9/site-packages/urwid/main_loop.py", line 172, in cb
self.playlist['items'][int(index)]['pafy'].getbestaudio().url,
ValueError: cannot convert float NaN to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 225, in play_at_index
callback(self, user_data)
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/ui.py", line 87, in update_name
details = self.get_url_and_name(index)
File "/home/frog/.local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 159, in get_url_and_name
self.list[int(self.player_object.get_index())].set_attr_map({
ValueError: cannot convert float NaN to integer

Unable to extract Initial JS player signature function name

File "/home/timetraveller/.local/lib/python3.7/site-packages/pafy/backend_youtube_dl.py", line 41, in _fetch_basic
raise IOError(str(e).replace('YouTube said', 'Youtube says'))
OSError: ERROR: Signature extraction failed: Traceback (most recent call last):
File "/home/timetraveller/.local/lib/python3.7/site-packages/youtube_dl/extractor/youtube.py", line 1210, in _decrypt_signature
video_id, player_url, s
File "/home/timetraveller/.local/lib/python3.7/site-packages/youtube_dl/extractor/youtube.py", line 1121, in _extract_signature_function
res = self._parse_sig_js(code)
File "/home/timetraveller/.local/lib/python3.7/site-packages/youtube_dl/extractor/youtube.py", line 1182, in _parse_sig_js
jscode, 'Initial JS player signature function name', group='sig')
File "/home/timetraveller/.local/lib/python3.7/site-packages/youtube_dl/extractor/common.py", line 972, in _search_regex
raise RegexNotFoundError('Unable to extract %s' % _name)

raise RegexNotFoundError('Unable to extract %s' % _name) youtube_dl.utils.RegexNotFoundError: Unable to extract Initial JS player signature function name; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output. (caused by RegexNotFoundError('Unable to extract \x1b[0;34mInitial JS player signature function name\x1b[0m; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.')); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output. [timetraveller@timemachine

total_seconds sometimes still crashes program

I see that in #14 total_seconds = 0 was added ti music_api.py line 250

However i still get the error

  File "/usr/lib/python3.7/site-packages/yTermPlayer/ui.py", line 71, in update_name
    temp = self.player_object.get_time_details()
  File "/usr/lib/python3.7/site-packages/yTermPlayer/music_api.py", line 258, in get_time_details
    minutes = int(total_seconds / 60)
UnboundLocalError: local variable 'total_seconds' referenced before assignment

I confirmed that i am on version 1.2.2

$ pip list | grep yTerm
yTermPlayer        1.2.2

I will add in some debug statements so i will know more about the state when it happens

error on startup

> yterm Traceback (most recent call last): File "/usr/local/bin/yterm", line 33, in sys.exit(load_entry_point('yTermPlayer==1.2.1', 'console_scripts', 'yterm')()) File "/usr/local/bin/yterm", line 25, in importlib_load_entry_point return next(matches).load() File "/usr/local/Cellar/[email protected]/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/metadata.py", line 77, in load module = import_module(match.group('module')) File "/usr/local/Cellar/[email protected]/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in _call_with_frames_removed File "/usr/local/lib/python3.9/site-packages/yTermPlayer/__main__.py", line 11, in from .music_api import YoutubePlayer File "/usr/local/lib/python3.9/site-packages/yTermPlayer/music_api.py", line 11, in import mpv File "/usr/local/lib/python3.9/site-packages/mpv.py", line 42, in raise OSError("Cannot find libmpv in the usual places. Depending on your distro, you may try installing an " OSError: Cannot find libmpv in the usual places. Depending on your distro, you may try installing an mpv-devel or mpv-libs package. If you have libmpv around but this script can't find it, maybe consult the documentation for ctypes.util.find_library which this script uses to look up the library filename.

I tried to reinstall mpv

ytem Command not found

I used the option "pip3 install" and I can't get the app to work (Ubuntu 20 server)

error: ssh: Command not found: yterm

Error on startup.

Using python 3.10 in a fresh virtualenv. However, I have installed it without a virtualenv in with python 3.8 and received roughly the same error I'm not sure if this is a problem with the version of mpv/libmpv I have installed on my system or if it's an issue with python-mpv. OR if it's just a minor bug in ytermplayer.

Linux distro/version

No LSB modules are available.
Distributor ID: Linuxmint
Description: Linux Mint 20.3
Release: 20.3
Codename: una

Software Versions

mpv: 0.32.0
libmpv: 0.32.0
python-mpv: 1.0.1
python: 3.8 | 3.10
venv | no venv

The traceback

Traceback (most recent call last): File "/home/splaq/.config/venv/py310testing/bin/yterm", line 5, in <module> from yTermPlayer.__main__ import main File "/home/splaq/.config/venv/py310testing/lib/python3.10/site-packages/yTermPlayer/__main__.py", line 11, in <module> from .music_api import YoutubePlayer File "/home/splaq/.config/venv/py310testing/lib/python3.10/site-packages/yTermPlayer/music_api.py", line 11, in <module> import mpv File "/home/splaq/.config/venv/py310testing/lib/python3.10/site-packages/mpv.py", line 579, in <module> _handle_func('mpv_event_to_node', [POINTER(MpvNode), POINTER(MpvEvent)], c_int, ec_errcheck, ctx=None) File "/home/splaq/.config/venv/py310testing/lib/python3.10/site-packages/mpv.py", line 502, in _handle_func func = getattr(backend, name) File "/usr/lib/python3.10/ctypes/__init__.py", line 387, in __getattr__ func = self.__getitem__(name) File "/usr/lib/python3.10/ctypes/__init__.py", line 392, in __getitem__ func = self._FuncPtr((name_or_ordinal, self)) AttributeError: /lib/x86_64-linux-gnu/libmpv.so.1: undefined symbol: mpv_event_to_node. Did you mean: 'mpv_event_name'?
'

libmpv image not found when trying to run on a mac.

Hey -- very excited to use this! Unfortunately have not gotten it to run yet.

I installed via pip and attempted to run but I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/yterm", line 6, in <module>
    from yTermPlayer.__main__ import main
  File "/usr/local/lib/python3.7/site-packages/yTermPlayer/__main__.py", line 11, in <module>
    from .music_api import YoutubePlayer
  File "/usr/local/lib/python3.7/site-packages/yTermPlayer/music_api.py", line 11, in <module>
    import mpv
  File "/usr/local/lib/python3.7/site-packages/mpv.py", line 11, in <module>
    backend = CDLL('libmpv.so')
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libmpv.so, 6): image not found

I have tried:

  1. Re-installing all dependencies one by one. Every time I am met with a Requirement already satisfied message.
  2. Reinstalling ffmpeg on my machine via sudo brew reinstall ffmpeg
  3. Reinstalling mpv on my machine via sudo brew reinstall mpv

Any idea what could be the problem? Thanks so much!

Player crashes once I copy the URL and press OK with the error "IndexError: tuple index out of range"

Please help me load playlists into the player. Currently it just outputs the following message in the terminal:
`During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ishmam/.local/bin/yterm", line 8, in
sys.exit(main())
File "/home/ishmam/.local/lib/python3.8/site-packages/yTermPlayer/main.py", line 28, in main
loop.run()
File "/home/ishmam/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 287, in run
self._run()
File "/home/ishmam/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 385, in _run
self.event_loop.run()
File "/home/ishmam/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 792, in run
if e.args[0] != 4:
IndexError: tuple index out of range
`

I am a newbie at python and cannot to figure out the problem. Please help.

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.