minor improvement
This commit is contained in:
		
							parent
							
								
									a8faad6573
								
							
						
					
					
						commit
						72e121d585
					
				
					 2 changed files with 8 additions and 6 deletions
				
			
		|  | @ -3,13 +3,13 @@ import os | |||
| import traceback | ||||
| import ycdl | ||||
| import ytapi | ||||
| 
 | ||||
| import ycdl_repl | ||||
| from voussoirkit import downloady | ||||
| 
 | ||||
| youtube_core = ytapi.Youtube(bot.YOUTUBE_KEY) | ||||
| youtube = ycdl.YCDL(youtube_core) | ||||
| 
 | ||||
| DIRECTORY = 'C:\\users\\owner\\youtube thumbnails' | ||||
| DIRECTORY = '.\\youtube thumbnails' | ||||
| 
 | ||||
| videos = ycdl_repl.youtube.get_videos() | ||||
| for video in videos: | ||||
|  |  | |||
							
								
								
									
										10
									
								
								ycdl.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ycdl.py
									
									
									
									
									
								
							|  | @ -106,13 +106,14 @@ class YCDL: | |||
|         statements = DB_INIT.split(';') | ||||
|         for statement in statements: | ||||
|             self.cur.execute(statement) | ||||
|         self.sql.commit() | ||||
| 
 | ||||
|     def add_channel( | ||||
|             self, | ||||
|             channel_id, | ||||
|             commit=False, | ||||
|             commit=True, | ||||
|             download_directory=None, | ||||
|             get_videos=True, | ||||
|             get_videos=False, | ||||
|             name=None, | ||||
|         ): | ||||
|         if self.get_channel(channel_id) is not None: | ||||
|  | @ -233,11 +234,12 @@ class YCDL: | |||
|         videos.sort(key=lambda x: x['published'], reverse=True) | ||||
|         return videos | ||||
| 
 | ||||
|     def insert_video(self, video, commit=True): | ||||
|     def insert_video(self, video, *, add_channel=True, commit=True): | ||||
|         if not isinstance(video, ytapi.Video): | ||||
|             video = self.youtube.get_video(video) | ||||
| 
 | ||||
|         self.add_channel(video.author_id, get_videos=False, commit=False) | ||||
|         if add_channel: | ||||
|             self.add_channel(video.author_id, get_videos=False, commit=False) | ||||
|         self.cur.execute('SELECT * FROM videos WHERE id == ?', [video.id]) | ||||
|         fetch = self.cur.fetchone() | ||||
|         if fetch is not None: | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue