#
# NETFLIX FUNCTION API
#
def find_show_id(name):
"""
Given a string name of a netflix show,
return the string ID for the show from titles.csv
"""
def find_actor_id(name):
"""
Given a string name of an actor,
return a string ID of the actor from credits.csv
"""
def find_show_title(show_id):
"""
Given a string ID of a show,
return a string title of the show with that ID in titles.csv
"""
def find_actors(target_show_id):
"""
Given a string ID of a show,
return a list of strings of all actors in that show from credits.csv
"""
def find_shows(actor_id):
"""
Given a string ID of an actor,
return a list of strings of all shows with that actor from credits.csv
"""
# DON'T CHANGE THIS FUNCTION!
def sort_list_by_frequency(alist):
"""
Utility function provided by SD211 (DON'T CHANGE IT!)
This takes a list of strings, and returns a new condensed list of the same strings, but in sorted
order based on how many times each unique string appeared in the given list.
"""
alist = sorted(alist)
counts = []
curr = ''
n = 0
for item in alist:
if item != curr:
if n > 0:
counts.append( (n,curr) )
n = 0
curr = item
n += 1
return [ x[1] for x in sorted(counts,reverse=True) ]
if __name__ == '__main__':
print('These are tests for the Netflix API. Feel free to add your own!')
if find_show_id('Stranger Things') != 'ts38796':
print('ERROR: find_show_id')
else:
print('PASS: find_show_id')
if find_actor_id('winona ryder') != '5937':
print('ERROR: find_actor_id')
else:
print('PASS: find_actor_id')
if find_show_title('ts38796') != 'Stranger Things':
print('ERROR: find_show_title')
else:
print('PASS: find_show_title')
if find_actors('ts38796')==None or find_actors('ts38796')[:4] != ['Winona Ryder', 'David Harbour', 'Millie Bobby Brown', 'Finn Wolfhard']:
print('ERROR: find_actors', find_actors('ts38796'))
else:
print('PASS: find_actors')
if find_shows('2317')==None or find_shows('2317')[:4] != ['Big Daddy', 'Grown Ups', 'The Ridiculous 6', 'The Do-Over']:
print('ERROR: find_shows', find_shows('2317'))
else:
print('PASS: find_shows')