Clean up input type of ycdldb.download_video.
This commit is contained in:
		
							parent
							
								
									03ee7e387f
								
							
						
					
					
						commit
						18f617a45b
					
				
					 1 changed files with 10 additions and 7 deletions
				
			
		|  | @ -310,14 +310,17 @@ class YCDLDBVideoMixin: | ||||||
|         Create the queuefile within the channel's associated directory, or |         Create the queuefile within the channel's associated directory, or | ||||||
|         the default directory from the config file. |         the default directory from the config file. | ||||||
|         ''' |         ''' | ||||||
|         if isinstance(video, ytapi.Video): |         if isinstance(video, objects.Video): | ||||||
|             video_id = video.id |             pass | ||||||
|  |         elif isinstance(video, ytapi.Video): | ||||||
|  |             video = self.get_video(video.id) | ||||||
|  |         elif isinstance(video, str): | ||||||
|  |             video = self.get_video(video) | ||||||
|         else: |         else: | ||||||
|             video_id = video |             raise TypeError(video) | ||||||
| 
 | 
 | ||||||
|         video = self.get_video(video_id) |  | ||||||
|         if video.state != 'pending' and not force: |         if video.state != 'pending' and not force: | ||||||
|             self.log.debug('%s does not need to be downloaded.', video_id) |             self.log.debug('%s does not need to be downloaded.', video.id) | ||||||
|             return |             return | ||||||
| 
 | 
 | ||||||
|         try: |         try: | ||||||
|  | @ -328,12 +331,12 @@ class YCDLDBVideoMixin: | ||||||
|             download_directory = self.config['download_directory'] |             download_directory = self.config['download_directory'] | ||||||
|             extension = self.config['queuefile_extension'] |             extension = self.config['queuefile_extension'] | ||||||
| 
 | 
 | ||||||
|         self.log.info('Creating queuefile for %s.', video_id) |         self.log.info('Creating queuefile for %s.', video.id) | ||||||
| 
 | 
 | ||||||
|         download_directory = pathclass.Path(download_directory) |         download_directory = pathclass.Path(download_directory) | ||||||
|         download_directory.makedirs(exist_ok=True) |         download_directory.makedirs(exist_ok=True) | ||||||
| 
 | 
 | ||||||
|         queuefile = download_directory.with_child(video_id).replace_extension(extension) |         queuefile = download_directory.with_child(video.id).replace_extension(extension) | ||||||
|         queuefile.touch() |         queuefile.touch() | ||||||
| 
 | 
 | ||||||
|         video.mark_state('downloaded', commit=False) |         video.mark_state('downloaded', commit=False) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue