Created
November 5, 2018 06:51
-
-
Save carlosplanchon/128f6bd1908736a41683e4774db9e21a to your computer and use it in GitHub Desktop.
Plays a song from YouTube.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import mps_youtube | |
def play_song_from_youtube(song_title, extra="lyrics HQ"): | |
"""It plays a song from YouTube.""" | |
# It search the song based on title. | |
mps_youtube.commands.search.search(f"{song_title} {extra}") | |
# Setting encoder to OGG 256K | |
mps_youtube.commands.config.setconfig("encoder", "5") | |
# Setting video off. | |
mps_youtube.commands.config.setconfig("show_video", "0") | |
try: | |
mps_youtube.commands.play.play("1", "1") | |
except Exception: | |
print("Song couldn't be played") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment