~cnx/comp

comp/README.rst -rw-r--r-- 7.5 KiB
e860f152 — Nguyễn Gia Phong Remove Travis CI 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
===============================
comp - Curses Omni Media Player
===============================

**comp** is a `mpv <https://mpv.io/>`_ 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 <https://rg3.github.io/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.

As ``setuptools`` will `install in an egg and cause breakage
<https://github.com/McSinyx/comp/issues/5>`_, using ``pip`` (Python 3 version) 
is a must.  After `installing it <https://pip.pypa.io/en/latest/installing/>`_,
run ``pip3 install comp`` (you might want to add ``--user`` flag to use the
`User Scheme <https://pip.pypa.io/en/stable/user_guide/#user-installs>`_).

For developers, clone the `Github repo <https://github.com/McSinyx/comp>`_ then
simply run the ``comp`` executable to test the program. If you insist on
installing it, still use ``pip3``: ``pip3 install .``. Note that **comp** is
distibuted in a ``wheel`` created via ``./setup.py bdist_wheel``.

Command line options
--------------------

::

   usage: comp [-h] [-v] [-e {json,mpv,youtube-dl}] [-c CONFIG] [--vid VID]
               [--vo DRIVER] [-f YTDL_FORMAT]
               playlist

   Curses Omni Media Player

   positional arguments:
     playlist              path or URL to the playlist

   optional arguments:
     -h, --help            show this help message and exit
     -v, --version         show program's version number and exit
     -e {json,mpv,youtube-dl}, --extractor {json,mpv,youtube-dl}
                           playlist extractor, default is youtube-dl
     -c CONFIG, --config CONFIG
                           path to the configuration file
     --vid VID             initial video channel. auto selects the default, no
                           disables video
     --vo DRIVER           specify the video output backend to be used. See
                           VIDEO OUTPUT DRIVERS in mpv(1) for details and
                           descriptions of available drivers
     -f YTDL_FORMAT, --format YTDL_FORMAT
                           video format/quality to be passed to youtube-dl

Examples
^^^^^^^^

Open a JSON playlist::

   comp -e json test/playlist.json

Open a Youtube playlist with video height lower than 720::

   comp -f '[height<720]' https://www.youtube.com/watch?list=PLnk14Iku8QM7R3ARnrj1TwYSZleF-i7jT

Keyboard control
----------------

Bindings inherited from mpv
^^^^^^^^^^^^^^^^^^^^^^^^^^^

For convenience purpose, I try to mimic **mpv** default keybindings, but many
are slightly different from **mpv** exact behaviour (mainly because of the lack
of keys which are unsupported by ``curses``). So I will list all of them here
for you to `compare <https://github.com/mpv-player/mpv/blob/master/DOCS/man/mpv.rst#keyboard-control>`_:

Left and Right
   Seek backward/forward 5 seconds. Shifted arrow does a 1 second seek.

Up and Down
   Seek backward/forward 1 minute.

``[`` and ``]``
   Decrease/increase current playback speed by 10%.

``{`` and ``}``
   Halve/double current playback speed.

Backspace
   Reset playback speed to normal.

``<`` and ``>``
   Go backward/forward in the playlist.

Return
   Start playing.

Space / ``p``
   Pause (pressing again unpauses).

``.``
   Step forward. Pressing once will pause, every consecutive press will play
   one frame and then go into pause mode again.

``,``
   Step backward. Pressing once will pause, every consecutive press will play
   one frame in reverse and then go into pause mode again.

``q``
   Stop playing and quit.

``/`` / ``9`` and ``*`` / ``0``
   Decrease/increase volume.

``m``
   Mute sound.

``_``
   Cycle through the available video tracks.

``#``
   Cycle through the available audio tracks.

``f``
   Toggle fullscreen.

``T``
   Toggle stay-on-top.

``w`` and ``e``
   Decrease/increase pan-and-scan range.

``o`` / ``P``
   Show progression bar, elapsed time and total duration on the OSD.

``O``
   Toggle OSD states between normal and playback time/duration.

``v``
   Toggle subtitle visibility.

``j`` and ``J``
   Cycle through the available subtitles.

``x`` and ``z``
   Adjust subtitle delay by +/- 0.1 seconds.

``l``
   Set/clear A-B loop points.

``L``
   Toggle infinite looping.

Ctrl-``+`` and Ctrl-``-``
   Adjust audio delay (A/V sync) by +/- 0.1 seconds.

``u``
   Switch between applying no style overrides to SSA/ASS subtitles, and
   overriding them almost completely with the normal subtitle style.

``V``
   Toggle subtitle VSFilter aspect compatibility mode.

``r`` and ``t``
   Move subtitles up/down.

``s``
   Take a screenshot.

``S``
   Take a screenshot, without subtitles.

Alt-``s``
   Take a screenshot each frame.

Page Up and Page Down
   Seek to the beginning of the previous/next chapter.

``d``
   Activate/deactivate deinterlacer.

``A``
   Cycle aspect ratio override.

``1`` and ``2``
   Adjust contrast.

``3`` and ``4``
   Adjust brightness.

``5`` and ``6``
   Adjust gamma.

``7`` and ``8``
   Adjust saturation.

Alt-``0``
   Resize video window to half its original size.

Alt-``1``
   Resize video window to its original size.

Alt-``2``
   Resize video window to double its original size.

``E``
   Cycle through editions.

Movements and selections
^^^^^^^^^^^^^^^^^^^^^^^^

The following keybindings are Emacs-like since most characters are taken by
**mpv**.

Ctrl-``p`` and Ctrl-``n``
   Move a single line up/down.

Alt-``v`` and Ctrl-``v``
   Move a single page up/down.

Home / Ctrl-``<`` and End / Ctrl-``>``
   Move to the beginning/end of the playlist.

Ctrl-Space
   Deselect/reselect the current entry and move down a line.

Playlist manipulation
^^^^^^^^^^^^^^^^^^^^^

Ctrl-``o``
   Open playlist.

Ctrl-``i``
   Insert playlist.

Ctrl-``f`` and Alt-``f``
   Search forward/backward for a pattern.

Alt-``m``
   Cycle through playing modes.

Delete
   Delete the current entry.

``W``
   Save the current playlist under JSON format.

F5
   Redraw the screen content.

``:``
   Execute a **mpv** command.

Configuration files
-------------------

If not specified by the ``--config``, (user-specific) configuration file is
``~/.config/comp/settings.ini``. Default configurations
are listed below::

   [comp]
   # Initial playing mode, which can be one of these 8 modes: play-current,
   # play-all, play-selected, repeat-current, repeat-all, repeat-selected,
   # shuffle-all and shuffle-selected.
   play-mode = play-current

   [mpv]
   # Options to be parsed to mpv. See OPTIONS section on mpv(1) man pages for
   # its complete list of available options.
   # For example:
   #vo = xv
   #ontop = yes
   #border = no
   #force-window = yes
   #autofit = 500x280
   #geometry = -15-50

   [youtube-dl]
   # Video format/quality to be passed to youtube-dl. See FORMAT SELECTION in
   # youtube-dl(1) man page for more details and descriptions.
   format = bestvideo+bestaudio


Bugs
----

Media durations are not extracted from online playlists as
``youtube-dl.YoutubeDL`` option ``extract_flat`` is set to ``'in_playlist'``.
This is rather a feature to save up bandwidth than a bug because a track's
duration is updated when it's played.