def parse_video_data(self, meta_data, video_url): """ 提取视频数据 参数: meta_data tuple 包含(playlist_id, vid) video_url string 提取页面的地址 返回: temp_video Video()实例 """ r = requests.get('http://pl.hd.sohu.com/videolist', params={ 'playlistid': meta_data[0], 'vid': meta_data[1] }) if r.status_code == 200: info = json.loads(r.text) extra_video_info = self.extra_video_info(info, video_url) vote_info = self.get_vote_info(meta_data) if vote_info: temp_video = Video() temp_video.name = extra_video_info['name'] temp_video.en_name = info['tvEnglishName'] temp_video.thumbnail = extra_video_info['largePicUrl'] temp_video.directors = str(info['directors']) temp_video.actors = str(info['actors']) temp_video.categories = str(info['categories']) temp_video.description = info['albumDesc'] temp_video.page_url = video_url temp_video.album_name = info['albumName'] temp_video.album_thumbnail = info['largeVerPicUrl'] temp_video.album_page_url = info['albumPageUrl'] temp_video.default_page_url = info['defaultPageUrl'] temp_video.playlist_id = meta_data[0] temp_video.vid = meta_data[1] temp_video.pid = info['pid'] temp_video.update_time = info['updateTime'] temp_video.publish_year = info['publishYear'] temp_video.area = info['area'] temp_video.play_length = extra_video_info['playLength'] temp_video.publish_time = extra_video_info['publishTime'] temp_video.up_vote = int(vote_info[0]) temp_video.down_vote = int(vote_info[1]) return temp_video else: print('无法读取网页', video_url)
def parse_video_data(self, meta_data, video_url): """ 提取视频数据 参数: meta_data tuple 包含(playlist_id, vid) video_url string 提取页面的地址 返回: temp_video Video()实例 """ r = requests.get('http://pl.hd.sohu.com/videolist', params={'playlistid': meta_data[0], 'vid': meta_data[1]}) if r.status_code == 200: info = json.loads(r.text) extra_video_info = self.extra_video_info(info, video_url) vote_info = self.get_vote_info(meta_data) if vote_info: temp_video = Video() temp_video.name = extra_video_info['name'] temp_video.en_name = info['tvEnglishName'] temp_video.thumbnail = extra_video_info['largePicUrl'] temp_video.directors = str(info['directors']) temp_video.actors = str(info['actors']) temp_video.categories = str(info['categories']) temp_video.description = info['albumDesc'] temp_video.page_url = video_url temp_video.album_name = info['albumName'] temp_video.album_thumbnail = info['largeVerPicUrl'] temp_video.album_page_url = info['albumPageUrl'] temp_video.default_page_url = info['defaultPageUrl'] temp_video.playlist_id = meta_data[0] temp_video.vid = meta_data[1] temp_video.pid = info['pid'] temp_video.update_time = info['updateTime'] temp_video.publish_year = info['publishYear'] temp_video.area = info['area'] temp_video.play_length = extra_video_info['playLength'] temp_video.publish_time = extra_video_info['publishTime'] temp_video.up_vote = int(vote_info[0]) temp_video.down_vote = int(vote_info[1]) return temp_video else: print('无法读取网页', video_url)