Skip to content

Commit

Permalink
Handling Korean Characters
Browse files Browse the repository at this point in the history
  • Loading branch information
NoSyu committed Jan 21, 2015
1 parent be672c5 commit 8071510
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugins/gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from random import shuffle

def gif(searchterm, unsafe=False):
searchterm = quote(searchterm)
searchterm = quote(searchterm.encode('utf8'))

safe = "&safe=" if unsafe else "&safe=active"
searchurl = "https://www.google.com/search?tbs=itp:animated&tbm=isch&q={0}{1}".format(searchterm, safe)
Expand Down
2 changes: 1 addition & 1 deletion plugins/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import requests

def google(q):
query = quote(q)
query = quote(q.encode('utf8'))
url = "https://encrypted.google.com/search?q={0}".format(query)
soup = BeautifulSoup(requests.get(url).text)

Expand Down
2 changes: 1 addition & 1 deletion plugins/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from random import shuffle

def image(searchterm, unsafe=False):
searchterm = quote(searchterm)
searchterm = quote(searchterm.encode('utf8'))

safe = "&safe=" if unsafe else "&safe=active"
searchurl = "https://www.google.com/search?tbm=isch&q={0}{1}".format(searchterm, safe)
Expand Down
2 changes: 1 addition & 1 deletion plugins/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def makemap(query):
else:
querywords.append(word)

query = quote(" ".join(querywords))
query = quote(" ".join(querywords).encode('utf8'))

# Slack seems to ignore the size param
#
Expand Down
2 changes: 1 addition & 1 deletion plugins/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}

def weather(searchterm):
searchterm = quote(searchterm)
searchterm = quote(searchterm.encode('utf8'))
url = 'http://api.openweathermap.org/data/2.5/forecast/daily?q={0}&cnt=5&mode=json&units=imperial'
url = url.format(searchterm)

Expand Down
2 changes: 1 addition & 1 deletion plugins/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def wiki(searchterm):
"""return the top wiki search result for the term"""
searchterm = quote(searchterm)
searchterm = quote(searchterm.encode('utf8'))

url = "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={0}&format=json"
url = url.format(searchterm)
Expand Down
2 changes: 1 addition & 1 deletion plugins/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests

def youtube(searchterm):
searchterm = quote(searchterm)
searchterm = quote(searchterm.encode('utf8'))
url = "https://gdata.youtube.com/feeds/api/videos?q={0}&orderBy=relevance&alt=json"
url = url.format(searchterm)

Expand Down

3 comments on commit 8071510

@llimllib
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for finding this! I will fix it in the main source file, I feel terrible I didn't think to test with unicode.

@dongwookim-ml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's great to contribute this repository! our group really enjoy your code btw :)

@llimllib
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad it is helpful :bowtie:

Please sign in to comment.