mps_youtube.util module¶
-
mps_youtube.util.
F
(key, nb=0, na=0, textlib=None)¶ Format text.
Parameters: - nb (int) – newline before
- na (int) – newline after
- textlib (dict) – the dictionary to use (defaults to g.text if not given)
Returns: A string, potentially containing one or more %s
Return type: str
-
class
mps_youtube.util.
IterSlicer
(iterable, length=None)¶ Bases:
object
Class that takes an iterable and allows slicing, loading from the iterable as needed.
-
class
mps_youtube.util.
XYTuple
(width, height, max_results)¶ Bases:
tuple
-
height
¶ Alias for field number 1
-
max_results
¶ Alias for field number 2
-
width
¶ Alias for field number 0
-
-
mps_youtube.util.
dbg
(*args)¶ Emit a debug message.
-
mps_youtube.util.
fmt_time
(seconds)¶ Format number of seconds to %H:%M:%S.
-
mps_youtube.util.
get_near_name
(begin, items)¶ Return the closest matching playlist name that starts with begin.
-
mps_youtube.util.
get_pafy
(item, force=False, callback=None)¶ Get pafy object for an item.
Parameters: - item (
mps_youtube.playlist.Video
) – video to retrieve - force (bool) – ignore cache and retrieve anyway
- callback (func) – callpack to pass to pafy
Return type: Pafy
- item (
-
mps_youtube.util.
has_exefile
(filename)¶ Check whether file exists in path and is executable.
Parameters: filename (str) – name of executable Returns: Path to file or False if not found Return type: str or False
-
mps_youtube.util.
is_known_player
(player)¶ Return true if the set player is known.
-
mps_youtube.util.
list_update
(item, lst, remove=False)¶ Add or remove item from list, checking first to avoid exceptions.
-
mps_youtube.util.
load_player_info
(player)¶
-
mps_youtube.util.
mswinfn
(filename)¶ Fix filename for Windows.
-
mps_youtube.util.
parse_multi
(choice, end=None)¶ Handle ranges like 5-9, 9-5, 5- and -5. Return list of ints.
-
mps_youtube.util.
real_len
(u, alt=False)¶ Try to determine width of strings displayed with monospace font.
-
mps_youtube.util.
set_window_title
(title)¶ Set terminal window title.
-
mps_youtube.util.
uea_pad
(num, t, direction='<', notrunc=False)¶ Right pad with spaces taking into account East Asian width chars.
-
mps_youtube.util.
utf8_replace
(txt)¶ Replace unsupported characters in unicode string.
Parameters: txt (str) – text to filter Returns: Unicode text without any characters unsupported by locale Return type: str
-
mps_youtube.util.
xenc
(stuff)¶ Replace unsupported characters.
-
mps_youtube.util.
xprint
(stuff, end=None)¶ Compatible print.
-
mps_youtube.util.
yt_datetime
(yt_date_time)¶ Return a time object and locale formated date string.