Conditions | 4 |
Total Lines | 26 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
25 | def search(self, query, maxres, recs=False): |
||
26 | if recs: |
||
27 | search_response = self.api.search().list( |
||
28 | relatedToVideoId=query, |
||
29 | part='id,snippet', |
||
30 | maxResults=maxres, |
||
31 | type='video', |
||
32 | topicId='/m/04rlf', |
||
33 | ).execute() |
||
34 | else: |
||
35 | search_response = self.api.search().list( |
||
36 | q=query, |
||
37 | part='id,snippet', |
||
38 | maxResults=maxres, |
||
39 | type='video', |
||
40 | topicId='/m/04rlf', |
||
41 | ).execute() |
||
42 | |||
43 | videos = [] |
||
44 | |||
45 | for search_result in search_response.get('items', []): |
||
46 | if search_result['id']['kind'] == 'youtube#video': |
||
47 | videos.append([search_result['id']['videoId'], |
||
48 | search_result['snippet']['title'], |
||
49 | url_enc(search_result['snippet']['title'])]) |
||
50 | return videos |
||
51 |