Skip to content

Commit 4c891cb

Browse files
committed
Fix: Fix Youtube query and change triggering phrase.
1 parent 49a63f0 commit 4c891cb

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ It can understand human speech, talk to user and execute basic commands.
1212

1313
#### Assistant Skills
1414
* **Opens a web page** (e.g 'Jarvis open youtube')
15-
* **Play a video in Youtube** (e.g 'find in you tdex in youtube')
15+
* **Play music in Youtube** (e.g 'play mozart')
1616
* **Opens libreoffice suite applications (calc, writer, impress)** (e.g 'Jarvis open calc')
1717
* **Tells about something**, by searching on the internet (e.g 'Jarvis tells me about oranges')
1818
* **Tells the weather** for a place (e.g 'Jarvis tell_the_skills me the weather in London')

src/jarvis/jarvis/skills/collection/browser.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,24 @@ def tell_me_about(cls, voice_transcript, skill):
6161
def open_in_youtube(cls, voice_transcript, skill):
6262
"""
6363
Open a video in youtube.
64-
:param voice_transcript: string (e.g 'about google')
64+
:param voice_transcript: string (e.g 'play mozart')
6565
:param skill: dict (e.g
6666
"""
6767

6868
tags = cls.extract_tags(voice_transcript, skill['tags'])
6969
for tag in tags:
70-
reg_ex = re.search(tag + ' ([a-zA-Z]+)', voice_transcript)
70+
reg_ex = re.search(tag + ' (.*)', voice_transcript)
71+
7172
try:
7273
if reg_ex:
7374
search_text = reg_ex.group(1)
74-
base = "https://www.youtube.com/results?search_query=" + "&orderby=viewCount"
75-
r = requests.get(base + search_text.replace(' ', '+'))
75+
base = "https://www.youtube.com/results?search_query={0}&orderby=viewCount"
76+
r = requests.get(base.format(search_text.replace(' ', '+')))
7677
page = r.text
7778
soup = bs(page, 'html.parser')
7879
vids = soup.findAll('a', attrs={'class': 'yt-uix-tile-link'})
79-
video = 'https://www.youtube.com' + vids[0]['href']
80+
video = 'https://www.youtube.com' + vids[0]['href'] + "&autoplay=1"
81+
cls.console(info_log="Play Youtube video: {0}".format(video))
8082
subprocess.Popen(["python", "-m", "webbrowser", "-t", video], stdout=subprocess.PIPE, shell=False)
8183
except Exception as e:
8284
cls.console(error_log="Error with the execution of skill with message {0}".format(e))

src/jarvis/jarvis/skills/registry.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@
157157
{
158158
'enable': True,
159159
'func': BrowserSkills.open_in_youtube,
160-
'tags': 'youtube, find in youtube, play in youtube',
161-
'description': 'Plays a video in Youtube'
160+
'tags': 'play',
161+
'description': 'Plays music in Youtube'
162162
},
163163

164164
{

0 commit comments

Comments
 (0)