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 traceback | ||||||
| import ycdl | import ycdl | ||||||
| import ytapi | import ytapi | ||||||
| 
 | import ycdl_repl | ||||||
| from voussoirkit import downloady | from voussoirkit import downloady | ||||||
| 
 | 
 | ||||||
| youtube_core = ytapi.Youtube(bot.YOUTUBE_KEY) | youtube_core = ytapi.Youtube(bot.YOUTUBE_KEY) | ||||||
| youtube = ycdl.YCDL(youtube_core) | youtube = ycdl.YCDL(youtube_core) | ||||||
| 
 | 
 | ||||||
| DIRECTORY = 'C:\\users\\owner\\youtube thumbnails' | DIRECTORY = '.\\youtube thumbnails' | ||||||
| 
 | 
 | ||||||
| videos = ycdl_repl.youtube.get_videos() | videos = ycdl_repl.youtube.get_videos() | ||||||
| for video in videos: | for video in videos: | ||||||
|  |  | ||||||
							
								
								
									
										8
									
								
								ycdl.py
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								ycdl.py
									
									
									
									
									
								
							|  | @ -106,13 +106,14 @@ class YCDL: | ||||||
|         statements = DB_INIT.split(';') |         statements = DB_INIT.split(';') | ||||||
|         for statement in statements: |         for statement in statements: | ||||||
|             self.cur.execute(statement) |             self.cur.execute(statement) | ||||||
|  |         self.sql.commit() | ||||||
| 
 | 
 | ||||||
|     def add_channel( |     def add_channel( | ||||||
|             self, |             self, | ||||||
|             channel_id, |             channel_id, | ||||||
|             commit=False, |             commit=True, | ||||||
|             download_directory=None, |             download_directory=None, | ||||||
|             get_videos=True, |             get_videos=False, | ||||||
|             name=None, |             name=None, | ||||||
|         ): |         ): | ||||||
|         if self.get_channel(channel_id) is not None: |         if self.get_channel(channel_id) is not None: | ||||||
|  | @ -233,10 +234,11 @@ class YCDL: | ||||||
|         videos.sort(key=lambda x: x['published'], reverse=True) |         videos.sort(key=lambda x: x['published'], reverse=True) | ||||||
|         return videos |         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): |         if not isinstance(video, ytapi.Video): | ||||||
|             video = self.youtube.get_video(video) |             video = self.youtube.get_video(video) | ||||||
| 
 | 
 | ||||||
|  |         if add_channel: | ||||||
|             self.add_channel(video.author_id, get_videos=False, commit=False) |             self.add_channel(video.author_id, get_videos=False, commit=False) | ||||||
|         self.cur.execute('SELECT * FROM videos WHERE id == ?', [video.id]) |         self.cur.execute('SELECT * FROM videos WHERE id == ?', [video.id]) | ||||||
|         fetch = self.cur.fetchone() |         fetch = self.cur.fetchone() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue