python - Youtube search in Django -> manage.py: error: unrecognized arguments: shell -
if use code in idle - ok, when use in django project, i.e. run via python manage.py shell
see next:
usage: manage.py [--auth_host_name auth_host_name] [--noauth_local_webserver] [--auth_host_port [auth_host_port [auth_host_port ...]]] [--logging_level {debug,info,warning,error,critical}] [--max-results max_results] manage.py: error: unrecognized arguments: shell
i found error occurs @ line: args = argparser.parse_args()
, can not find how fix that. can help?
edit: once launched shell, call youtube_search(), when interpreter executes line args = argparser.parse_args()
, shell closes , see message above.
as don't need pass arguments command line function, removed this:
argparser.add_argument("--q", help="search term", default="google") argparser.add_argument("--max-results", help="max results", default=25) args = argparser.parse_args()
and pass arguments need directly function:
search_queue = 'jingle bells' max_results = 5 youtube_search(search_queue, max_results)
and make changes here:
def youtube_search(q, max_results): # old version: def youtube_search(options): youtube = build(youtube_api_service_name, youtube_api_version, developerkey=developer_key) # call search.list method retrieve results matching specified # query term. search_response = youtube.search().list( q=q, # old version: q=options.q, part="id,snippet", maxresults=max_results # old version: maxresults=options.max_results ).execute()