-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserve.py
35 lines (24 loc) · 937 Bytes
/
serve.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
35
import string
import googleapiclient.discovery
import config
import random
DEVELOPER_KEY = config.CONFIG['secret_key']
API_SERVICE_NAME = 'youtube'
API_VERSION = 'v3'
def search_list_by_keyword(client, **kwargs):
response = client.search().list(
**kwargs
).execute()
return response.get('items')
def getvideo():
client = googleapiclient.discovery.build(
API_SERVICE_NAME, API_VERSION, developerKey=DEVELOPER_KEY)
random_string = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(1))
output = search_list_by_keyword(client,
part='snippet',
maxResults=25,
q=random_string,
channelId='UCFKE7WVJfvaHW5q283SxchA',
type='video',
videoEmbeddable ='true')
return output