Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle utf-8 characters in the search query #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions follow-youtube-recommendations.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_search_results(self, search_terms, max_results, top_rated=False):
assert max_results < 20, 'max_results was not implemented to be > 20'

if self._verbose:
print ('Searching for {}'.format(search_terms))
print (u'Searching for {}'.format(search_terms))

# Trying to get results from cache
if search_terms in self._search_infos and len(self._search_infos[search_terms]) >= max_results:
Expand Down Expand Up @@ -357,11 +357,14 @@ def compare_keywords(query, search_results, branching, depth, name, gl, language
with open(file_name, 'w') as fp:
json.dump(top_videos, fp)

def to_unicode(s):
return unicode(s, 'utf-8')

def main():
global parser
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--query', help='The start search query')
parser.add_argument('--name', help='Name given to the file')
parser.add_argument('--query', help='The start search query', type=to_unicode)
parser.add_argument('--name', help='Name given to the file', type=to_unicode)
parser.add_argument('--searches', default='5', type=int, help='The number of search results to start the exploration')
parser.add_argument('--branch', default='3', type=int, help='The branching factor of the exploration')
parser.add_argument('--depth', default='5', type=int, help='The depth of the exploration')
Expand Down