-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmovies.py
35 lines (22 loc) · 860 Bytes
/
movies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import requests
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
base_url = 'https://api.themoviedb.org/3'
api_key = config['TMDB']['API_KEY']
def get_trendings(is_day):
endpoint = ''
if is_day:
endpoint = '/trending/movie/day'
else:
endpoint = '/trending/movie/week'
parameters = '?' + 'language=pt-BR' + '&api_key=' + api_key
final_url = base_url + endpoint + parameters
response = requests.get(final_url).json()
return [movie['title'] for movie in response['results']]
def search_movies(query):
endpoint = '/search/movie'
parameters = '?' + 'query=' + query + '&language=pt-BR' + '&api_key=' + api_key
final_url = base_url + endpoint + parameters
response = requests.get(final_url).json()
return [movie['title'] for movie in response['results']]