Skip to content
Permalink
Browse files
Update play.py
  • Loading branch information
carreira committed Nov 29, 2018
1 parent d601b9b commit 1177d00cb12658e77a5ba9917749006c45c11510
Showing 1 changed file with 4 additions and 3 deletions.
@@ -1,9 +1,9 @@
import webbrowser #
import webbrowser #allows to open websites -> font:https://stackoverflow.com/questions/31715119/how-can-i-open-a-website-in-my-web-browser-using-python
import glob #allows to have a list
import os #provides a portable way of using operating system functionalities
import random #allows to choose randomly an index of a list


"""allows user to see and play the musics inside the music folder, localized in the same directory as the play.py"""
def play(sentence):
mlist = (glob.glob("music/*.mp3")) #gets all the names of the musics inside the folder music, in the same directory as the python files
if "show" in sentence or "list" in sentence:
@@ -58,13 +58,14 @@ def play(sentence):
uOpen(sentence)
break


"""plays the music wanted in the youtube"""
def uOpen(sentence):
sentence = sentence[5:] #sentence is sentence after play
print("Playing " + sentence)
url = "https://www.youtube.com/results?search_query=" + sentence
webbrowser.open(url) #opens google with that url

"""allows the user to open websites as long as the user knows the link (ex: google.com)"""
def uGoogle(sentence):
sentence = sentence[5:] #sentence is sentence after open
print("Opening " + sentence)

0 comments on commit 1177d00

Please sign in to comment.