Пример #1
0
 def confirm(self):
     dpr.add_item(self.data)
     if self.data[0]["Type"] == "Channel":            
         dpr.update_videos(self.data[0]["ID"])            
     elif self.data[0]["Type"] == "Video":
         dpr.channel_from_video(self.data[0]["ID"])     
     dpr.refresh()
     self.close()
Пример #2
0
        #try to match the IDs of all videos or channels with the IDs of the data from gather_data. 
        self.stats = {}
        for i in self.id_list:
            try:
                self.stats[i] = self.data[i][stat]
            except KeyError as e:
                self.stats[i] = "NaN"   
        self.df_stats = pd.DataFrame.from_dict(self.stats, orient="index", columns=[self.curr_time])                        
        #if there is no previous channels- or videos-file or if they are empty, don't merge with df_stats before writing    
        try:
            self.df_old = dpr.get_dataframe(output_file)
            self.df_new = self.df_old.join(self.df_stats, how="outer")            
            dpr.write_dataframetofile(self.df_new, output_file)
        except (ValueError, OSError):
            dpr.write_dataframetofile(self.df_stats, output_file)                                 
        
if __name__ == "__main__":
    channels = DataContainer("channels", "channels.csv")
    dpr.update_videos(channels.id_list) #Look for new Videos in all channels before updating the rest    
    channels.gather_data()
    channels.update_stats("channel_views.csv", "viewCount")
    channels.update_stats("channel_subscribers.csv", "subscriberCount")
    channels.update_stats("channel_videos.csv", "videoCount")
    channels.update_stats("channel_comments.csv", "commentCount")
    
    videos = DataContainer("videos", "videos.csv")  
    videos.gather_data()
    videos.update_stats("video_views.csv", "viewCount")
    videos.update_stats("video_likes.csv", "likeCount")
    videos.update_stats("video_dislikes.csv", "dislikeCount")
    videos.update_stats("video_comments.csv", "commentCount")