Add method insert_playlist.
This commit is contained in:
		
							parent
							
								
									1a7662b6bd
								
							
						
					
					
						commit
						d0bfbaadfe
					
				
					 1 changed files with 9 additions and 0 deletions
				
			
		|  | @ -263,6 +263,15 @@ class YCDLDB: | ||||||
|         videos = [{key: video[SQL_VIDEO[key]] for key in SQL_VIDEO} for video in videos] |         videos = [{key: video[SQL_VIDEO[key]] for key in SQL_VIDEO} for video in videos] | ||||||
|         return videos |         return videos | ||||||
| 
 | 
 | ||||||
|  |     def insert_playlist(self, playlist_id, commit=True): | ||||||
|  |         video_generator = self.youtube.get_playlist_videos(playlist_id) | ||||||
|  |         results = [self.insert_video(video, commit=False) for video in video_generator] | ||||||
|  | 
 | ||||||
|  |         if commit: | ||||||
|  |             self.sql.commit() | ||||||
|  | 
 | ||||||
|  |         return results | ||||||
|  | 
 | ||||||
|     def insert_video(self, video, *, add_channel=True, commit=True): |     def insert_video(self, video, *, add_channel=True, commit=True): | ||||||
|         if not isinstance(video, ytapi.Video): |         if not isinstance(video, ytapi.Video): | ||||||
|             video = self.youtube.get_video(video) |             video = self.youtube.get_video(video) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue