Fix youtube-dl stderr garbage printing and edit installation installation instruction

This commit is contained in:
Nguyễn Gia Phong 2017-06-25 20:33:08 +07:00 committed by Nguyễn Gia Phong
parent 6d0aa7fe51
commit 2972111b59
5 changed files with 29 additions and 35 deletions

View File

@ -2,41 +2,28 @@
comp - Curses Omni Media Player
===============================
comp is a mpv front-end using curses. It has basic media player functions and
can to extract playlists from multiple sources such as media sites supported by
youtube-dl, local and direct URL to video/audio and its own JSON playlist
format.
**comp** is a mpv front-end using curses. It has basic media player functions
and can to extract playlists from multiple sources such as media sites
supported by youtube-dl, local and direct URL to video/audio and its own JSON
playlist format.
.. image:: https://github.com/McSinyx/comp/raw/master/doc/screenshot.png
Installation
------------
comp requires Python 3.5+ with ``curses`` module (only available on Unix-like
OSes such as GNU/Linux and the BSDs) and ``libmpv`` (available as ``libmpv1``
in Debian/Ubuntu, openSUSE; and as ``mpv`` in Arch Linux, Gentoo, macOS
Homebrew repository). It also depends on ``python-mpv`` and ``youtube-dl`` but
the setup program will automatically install them if they are missing.
**comp** requires Python 3.5+ with ``curses`` module (only available on
Unix-like OSes such as GNU/Linux and the BSDs) and ``libmpv`` (available as
``libmpv1`` in Debian/Ubuntu, openSUSE; and as ``mpv`` in Arch Linux, Gentoo,
macOS Homebrew repository). It also depends on ``python-mpv`` and
``youtube-dl`` but the setup program will automatically install them if they
are missing.
Using pip
^^^^^^^^^
Python 2 is still the default on most distributions so the command would be
``pip3 install comp``. You can use the ``--user`` flag to avoid system-wide
installation.
Using setup.py
^^^^^^^^^^^^^^
To install the latest version or test development branches, you'll need to do
it manually::
git clone https://github.com/McSinyx/comp.git
cd comp
./setup.py install
Note that ``setup.py`` uses ``setuptools`` which is a third-party module and
can be install using ``pip3``.
As ``setuptools`` will `install in an egg and cause breakage
<https://github.com/McSinyx/comp/issues/5>`_, using ``pip`` is a must. After
`installing it <https://pip.pypa.io/en/latest/installing/>`_, run ``pip install
comp`` (depends on your operating system, Python 3 pip executable might be
either ``pip`` or ``pip3``).
Command line options
--------------------
@ -76,7 +63,7 @@ Open a JSON playlist::
Open a Youtube playlist with video height lower than 720::
comp -f [height<720] https://www.youtube.com/watch?v=pqkHrdYXaTk&list=PLnk14Iku8QM7R3ARnrj1TwYSZleF-i7jT
comp -f '[height<720]' https://www.youtube.com/list=PLnk14Iku8QM7R3ARnrj1TwYSZleF-i7jT
Keyboard control
----------------

2
comp
View File

@ -344,7 +344,7 @@ parser.add_argument('-f', '--format', required=False, metavar='YTDL_FORMAT',
args = parser.parse_args()
entries = extract_info(args.playlist, args.extractor)
if entries is None:
print(_("'{}': Can't extract playlist").format(args.file))
print(_("'{}': Can't extract playlist").format(args.playlist))
exit()
json_file = args.playlist if args.extractor == 'json' else ''
config = ConfigParser()

View File

@ -129,7 +129,7 @@ Open a JSON playlist:
.ft R
Open a Youtube playlist with video height lower than 720:
.ft B
comp -f [height<720] https://www.youtube.com/list=PLnk14Iku8QM7R3ARnrj1TwYSZleF-i7jT
comp -f '[height<720]' https://www.youtube.com/list=PLnk14Iku8QM7R3ARnrj1TwYSZleF-i7jT
.SH BUGS
.PP
Media durations are not extracted from online playlists as youtube-dl

View File

@ -24,10 +24,15 @@ from urllib.request import urlretrieve
from youtube_dl import YoutubeDL
from mpv import MPV
DEFAULT_ENTRY = {'filename': '', 'title': '', 'duration': '00:00:00',
'error': False, 'playing': False, 'selected': False}
YTDL_OPTS = {'quiet': True, 'default_search': 'ytsearch',
'extract_flat': 'in_playlist'}
class YoutubeDLLogger:
def debug(self, msg): pass
def warning(self, msg): pass
def error(self, msg): pass
def json_extract_info(filename):
@ -69,7 +74,9 @@ def ytdl_extract_info(filename):
"""Return list of entries extracted from a path or URL using
youtube-dl. If an error occur during the extraction, return None.
"""
with YoutubeDL(YTDL_OPTS) as ytdl:
ytdl_opts = {'logger': YoutubeDLLogger, 'default_search': 'ytsearch',
'extract_flat': 'in_playlist'}
with YoutubeDL(ytdl_opts) as ytdl:
try:
raw_info = ytdl.extract_info(filename, download=False)
except:

View File

@ -7,7 +7,7 @@ with open('README.rst') as f:
setup(
name='comp',
version='0.3.6',
version='0.3.7',
description=('Curses Omni Media Player'),
long_description=long_description,
url='https://github.com/McSinyx/comp',