Beispiel #1
0
 def search_videos_by_keyword(self,
                              keyword,
                              category=None,
                              period='week',
                              orderby='relevance',
                              public_type='all',
                              paid=None,
                              timeless=None,
                              timemore=None,
                              streamtypes=None,
                              page=1,
                              count=20):
     """doc: http://open.youku.com/docs/doc?id=81
     """
     url = 'https://openapi.youku.com/v2/searches/video/by_keyword.json'
     params = {
         'client_id': self.client_id,
         'keyword': keyword,
         'category': category,
         'period': period,
         'orderby': orderby,
         'public_type': public_type,
         'paid': paid,
         'timeless': timeless,
         'timemore': timemore,
         'streamtypes': streamtypes,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #2
0
 def search_shows_by_keyword(self,
                             keyword,
                             unite=0,
                             source_site=None,
                             category=None,
                             release_year=None,
                             area=None,
                             orderby='view-count',
                             paid=None,
                             hasvideotype=None,
                             page=1,
                             count=20):
     """doc: http://open.youku.com/docs/doc?id=82
     """
     url = 'https://openapi.youku.com/v2/searches/show/by_keyword.json'
     params = {
         'client_id': self.client_id,
         'keyword': keyword,
         'unite': unite,
         'source_site': source_site,
         'category': category,
         'release_year': release_year,
         'area': area,
         'orderby': orderby,
         'paid': paid,
         'hasvideotype': hasvideotype,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #3
0
 def find_shows_by_category(self,
                            category,
                            genre=None,
                            area=None,
                            release_year=None,
                            paid=None,
                            orderby='view-today-count',
                            streamtypes=None,
                            person=None,
                            page=1,
                            count=20):
     """doc: http://open.youku.com/docs/doc?id=62
     """
     url = 'https://openapi.youku.com/v2/shows/by_category.json'
     params = {
         'client_id': self.client_id,
         'category': category,
         'genre': genre,
         'area': area,
         'release_year': release_year,
         'paid': paid,
         'orderby': orderby,
         'streamtypes': streamtypes,
         'person': person,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #4
0
 def search_show_top_unite(self,
                           category,
                           genre=None,
                           area=None,
                           year=None,
                           orderby=None,
                           headnum=1,
                           tailnum=1,
                           onesiteflag=None,
                           page=1,
                           count=20):
     """doc: http://open.youku.com/docs/doc?id=86
     """
     url = 'https://openapi.youku.com/v2/searches/show/top_unite.json'
     params = {
         'client_id': self.client_id,
         'category': category,
         'genre': genre,
         'area': area,
         'year': year,
         'orderby': orderby,
         'headnum': headnum,
         'tailnum': tailnum,
         'onesiteflag': onesiteflag,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #5
0
 def search_videos_by_keyword(self, keyword, category=None,
                              period='week', orderby='relevance',
                              public_type='all', paid=None,
                              timeless=None, timemore=None,
                              streamtypes=None,
                              page=1, count=20):
     """doc: http://open.youku.com/docs/doc?id=81
     """
     url = 'https://openapi.youku.com/v2/searches/video/by_keyword.json'
     params = {
         'client_id': self.client_id,
         'keyword': keyword,
         'category': category,
         'period': period,
         'orderby': orderby,
         'public_type': public_type,
         'paid': paid,
         'timeless': timeless,
         'timemore': timemore,
         'streamtypes': streamtypes,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #6
0
 def find_shows_by_category(self, category, genre=None, area=None,
                            release_year=None, paid=None,
                            orderby='view-today-count',
                            streamtypes=None, person=None,
                            page=1, count=20):
     """doc: http://open.youku.com/docs/doc?id=62
     """
     url = 'https://openapi.youku.com/v2/shows/by_category.json'
     params = {
         'client_id': self.client_id,
         'category': category,
         'genre': genre,
         'area': area,
         'release_year': release_year,
         'paid': paid,
         'orderby': orderby,
         'streamtypes': streamtypes,
         'person': person,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #7
0
 def find_persons_by_type(self,
                          type,
                          nationality=None,
                          gender=None,
                          firstletter=None,
                          orderby='view-week-count',
                          page=1,
                          count=20):
     """doc: http://open.youku.com/docs/docs?id=89
     """
     url = 'https://openapi.youku.com/v2/persons/by_type.json'
     params = {
         'client_id': self.client_id,
         'type': type,
         'nationality': nationality,
         'gender': gender,
         'firstletter': firstletter,
         'orderby': orderby,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #8
0
 def search_shows_by_keyword(self, keyword, unite=0, source_site=None,
                             category=None, release_year=None,
                             area=None, orderby='view-count',
                             paid=None, hasvideotype=None,
                             page=1, count=20):
     """doc: http://open.youku.com/docs/doc?id=82
     """
     url = 'https://openapi.youku.com/v2/searches/show/by_keyword.json'
     params = {
         'client_id': self.client_id,
         'keyword': keyword,
         'unite': unite,
         'source_site': source_site,
         'category': category,
         'release_year': release_year,
         'area': area,
         'orderby': orderby,
         'paid': paid,
         'hasvideotype': hasvideotype,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #9
0
 def update_video(self,
                  access_token,
                  video_id,
                  title=None,
                  tags=None,
                  category=None,
                  copyright_type=None,
                  public_type=None,
                  watch_password=None,
                  description=None,
                  thumbnail_seq=None):
     """doc: http://open.youku.com/docs/doc?id=50
     """
     url = 'https://openapi.youku.com/v2/videos/update.json'
     data = {
         'client_id': self.client_id,
         'access_token': access_token,
         'video_id': video_id,
         'title': title,
         'tags': tags,
         'category': category,
         'copyright_type': copyright_type,
         'public_type': public_type,
         'watch_password': watch_password,
         'description': description,
         'thumbnail_seq': thumbnail_seq
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data, verify=False)
     check_error(r)
     return r.json()['id']
Beispiel #10
0
 def _find_users(self, user_ids=None, user_names=None):
     url = 'https://openapi.youku.com/v2/users/show_batch.json'
     data = {
         'client_id': self.client_id,
         'user_ids': user_ids,
         'user_names': user_names
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     if r.status_code == 400:
         # Youku return 400 if no result, but this is not friendly.
         return None
     check_error(r)
     return r.json()
Beispiel #11
0
 def _find_users(self, user_ids=None, user_names=None):
     url = 'https://openapi.youku.com/v2/users/show_batch.json'
     data = {
         'client_id': self.client_id,
         'user_ids': user_ids,
         'user_names': user_names
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     if r.status_code == 400:
         # Youku return 400 if no result, but this is not friendly.
         return None
     check_error(r)
     return r.json()
Beispiel #12
0
 def destroy_friendship(self, access_token, user_id=None, user_name=None):
     """doc: ??
     """
     url = 'https://openapi.youku.com/v2/users/friendship/destroy.json'
     data = {
         'client_id': self.client_id,
         'access_token': access_token,
         'user_id': user_id,
         'user_name': user_name
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     check_error(r)
     return r.json()
Beispiel #13
0
 def destroy_friendship(self, access_token,
                        user_id=None, user_name=None):
     """doc: ??
     """
     url = 'https://openapi.youku.com/v2/users/friendship/destroy.json'
     data = {
         'client_id': self.client_id,
         'access_token': access_token,
         'user_id': user_id,
         'user_name': user_name
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     check_error(r)
     return r.json()
Beispiel #14
0
 def search_show_address_unite(self, progammeId,
                               source_site=None, type=None):
     """doc: http://open.youku.com/docs/doc?id=85
     """
     url = 'https://openapi.youku.com/v2/searches/show/address_unite.json'
     params = {
         'client_id': self.client_id,
         'progammeId': progammeId,
         'source_site': source_site,
         'type': type
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #15
0
 def friendship_followers(self, user_id=None, user_name=None,
                          page=1, count=20):
     """doc: http://open.youku.com/docs/doc?id=27
     """
     url = 'https://openapi.youku.com/v2/users/friendship/followers.json'
     data = {
         'client_id': self.client_id,
         'page': page,
         'count': count,
         'user_id': user_id,
         'user_name': user_name
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     check_error(r)
     return r.json()
Beispiel #16
0
 def search_show_address_unite(self,
                               progammeId,
                               source_site=None,
                               type=None):
     """doc: http://open.youku.com/docs/doc?id=85
     """
     url = 'https://openapi.youku.com/v2/searches/show/address_unite.json'
     params = {
         'client_id': self.client_id,
         'progammeId': progammeId,
         'source_site': source_site,
         'type': type
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #17
0
 def create_playlist(self, access_token, title, tags,
                     category=None, description=None):
     """doc: http://open.youku.com/docs/doc?id=72
     """
     url = 'https://openapi.youku.com/v2/playlists/create.json'
     data = {
         'client_id': self.client_id,
         'access_token': access_token,
         'title': title,
         'tags': tags,
         'category': category,
         'description': description
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     check_error(r)
     return r.json()['id']
Beispiel #18
0
 def create_playlist(self, access_token, title, tags,
                     category=None, description=None):
     """doc: http://open.youku.com/docs/doc?id=72
     """
     url = 'https://openapi.youku.com/v2/playlists/create.json'
     data = {
         'client_id': self.client_id,
         'access_token': access_token,
         'title': title,
         'tags': tags,
         'category': category,
         'description': description
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     check_error(r)
     return r.json()['id']
Beispiel #19
0
 def create_comment(self, access_token, video_id, content,
                    reply_id=None, captcha_key=None, captcha_text=None):
     """doc: http://open.youku.com/docs/doc?id=41
     """
     url = 'https://openapi.youku.com/v2/comments/create.json'
     data = {
         'client_id': self.client_id,
         'access_token': access_token,
         'video_id': video_id,
         'content': content,
         'reply_id': reply_id,
         'captcha_key': captcha_key,
         'captcha_text': captcha_text
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     check_error(r)
     return r.json()['id']
Beispiel #20
0
 def friendship_followers(self,
                          user_id=None,
                          user_name=None,
                          page=1,
                          count=20):
     """doc: http://open.youku.com/docs/doc?id=27
     """
     url = 'https://openapi.youku.com/v2/users/friendship/followers.json'
     data = {
         'client_id': self.client_id,
         'page': page,
         'count': count,
         'user_id': user_id,
         'user_name': user_name
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     check_error(r)
     return r.json()
Beispiel #21
0
 def find_videos_by_show(self, show_id, show_videotype=None,
                         show_videostage=None, orderby='videoseq-asc',
                         page=1, count=20):
     """doc: http://open.youku.com/docs/doc?id=64
     """
     url = 'https://openapi.youku.com/v2/shows/videos.json'
     params = {
         'client_id': self.client_id,
         'show_id': show_id,
         'page': page,
         'count': count,
         'show_videotype': show_videotype,
         'show_videostage': show_videostage,
         'orderby': orderby
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #22
0
 def find_persons_by_type(self, type, nationality=None, gender=None,
                          firstletter=None, orderby='view-week-count',
                          page=1, count=20):
     """doc: http://open.youku.com/docs/docs?id=89
     """
     url = 'https://openapi.youku.com/v2/persons/by_type.json'
     params = {
         'client_id': self.client_id,
         'type': type,
         'nationality': nationality,
         'gender': gender,
         'firstletter': firstletter,
         'orderby': orderby,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #23
0
 def create_comment(self,
                    access_token,
                    video_id,
                    content,
                    reply_id=None,
                    captcha_key=None,
                    captcha_text=None):
     """doc: http://open.youku.com/docs/doc?id=41
     """
     url = 'https://openapi.youku.com/v2/comments/create.json'
     data = {
         'client_id': self.client_id,
         'access_token': access_token,
         'video_id': video_id,
         'content': content,
         'reply_id': reply_id,
         'captcha_key': captcha_key,
         'captcha_text': captcha_text
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     check_error(r)
     return r.json()['id']
Beispiel #24
0
 def find_videos_by_show(self,
                         show_id,
                         show_videotype=None,
                         show_videostage=None,
                         orderby='videoseq-asc',
                         page=1,
                         count=20):
     """doc: http://open.youku.com/docs/doc?id=64
     """
     url = 'https://openapi.youku.com/v2/shows/videos.json'
     params = {
         'client_id': self.client_id,
         'show_id': show_id,
         'page': page,
         'count': count,
         'show_videotype': show_videotype,
         'show_videostage': show_videostage,
         'orderby': orderby
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()
Beispiel #25
0
 def update_video(self, access_token, video_id, title=None,
                  tags=None, category=None, copyright_type=None,
                  public_type=None, watch_password=None,
                  description=None, thumbnail_seq=None):
     """doc: http://open.youku.com/docs/doc?id=50
     """
     url = 'https://openapi.youku.com/v2/videos/update.json'
     data = {
         'client_id': self.client_id,
         'access_token': access_token,
         'video_id': video_id,
         'title': title,
         'tags': tags,
         'category': category,
         'copyright_type': copyright_type,
         'public_type': public_type,
         'watch_password': watch_password,
         'description': description,
         'thumbnail_seq': thumbnail_seq
     }
     data = remove_none_value(data)
     r = requests.post(url, data=data)
     check_error(r)
     return r.json()['id']
Beispiel #26
0
 def search_show_top_unite(self, category, genre=None, area=None,
                           year=None, orderby=None, headnum=1,
                           tailnum=1, onesiteflag=None,
                           page=1, count=20):
     """doc: http://open.youku.com/docs/doc?id=86
     """
     url = 'https://openapi.youku.com/v2/searches/show/top_unite.json'
     params = {
         'client_id': self.client_id,
         'category': category,
         'genre': genre,
         'area': area,
         'year': year,
         'orderby': orderby,
         'headnum': headnum,
         'tailnum': tailnum,
         'onesiteflag': onesiteflag,
         'page': page,
         'count': count
     }
     params = remove_none_value(params)
     r = requests.get(url, params=params)
     check_error(r)
     return r.json()