Skip to content

Commit

Permalink
Merge pull request #2 from antlarr/master
Browse files Browse the repository at this point in the history
Fix some python2 exclusive code to work also with python3
  • Loading branch information
JarbasAl committed Mar 14, 2018
2 parents ee90de9 + 70604bf commit c901459
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions __init__.py
@@ -1,11 +1,17 @@
# NO LICENSE
# These bits are free to do as they please, ones and zeros dont need licence or copyright

import urllib
import urllib2
import sys
from bs4 import BeautifulSoup
from mycroft.audio import wait_while_speaking
from mycroft.skills.core import MycroftSkill
if sys.version_info[0] < 3:
from urllib import quote
from urllib2 import urlopen
else:
from urllib.request import urlopen
from urllib.parse import quote

try:
from mycroft.skills.audioservice import AudioService
except ImportError:
Expand Down Expand Up @@ -69,9 +75,9 @@ def handle_play_song_intent(self, message):
(out, err) = self.p.communicate()

def search(self, text):
query = urllib.quote(text)
query = quote(text)
url = "https://www.youtube.com/results?search_query=" + query
response = urllib2.urlopen(url)
response = urlopen(url)
html = response.read()
soup = BeautifulSoup(html)
vid = soup.findAll(attrs={'class': 'yt-uix-tile-link'})
Expand Down

0 comments on commit c901459

Please sign in to comment.