yt-download to /tmp first
This commit is contained in:
		
							parent
							
								
									705b662782
								
							
						
					
					
						commit
						290f8d3183
					
				
					 1 changed files with 6 additions and 1 deletions
				
			
		
							
								
								
									
										7
									
								
								robot.py
									
										
									
									
									
								
							
							
						
						
									
										7
									
								
								robot.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
#!/usr/bin/env python3
 | 
			
		||||
import logging
 | 
			
		||||
import os
 | 
			
		||||
import shutil
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
import requests
 | 
			
		||||
| 
						 | 
				
			
			@ -13,6 +14,7 @@ logging.basicConfig(level=logging.INFO,
 | 
			
		|||
logger = logging.getLogger("kunsax")
 | 
			
		||||
 | 
			
		||||
DIR = os.path.dirname(os.path.realpath(__file__))
 | 
			
		||||
TMP_DIR = '/tmp'
 | 
			
		||||
OUT_DIR = DIR + '/out'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -34,10 +36,13 @@ def download_ydl(urls, date):
 | 
			
		|||
    ydl_opts = {
 | 
			
		||||
        'noplaylist': True,
 | 
			
		||||
        'download_archive': DIR + '/downloaded.lst',
 | 
			
		||||
        'outtmpl': OUT_DIR + '/' + datestr(date) + '__%(title)s__%(id)s.%(ext)s'
 | 
			
		||||
        'outtmpl': TMP_DIR + '/' + datestr(date) + '__%(title)s__%(id)s.%(ext)s'
 | 
			
		||||
    }
 | 
			
		||||
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
 | 
			
		||||
        ydl.download(urls)
 | 
			
		||||
        for filename in map(ydl.prepare_filename, map(ydl.extract_info, urls)):
 | 
			
		||||
            logger.info("Moving %s to %s..." % (filename, OUT_DIR))
 | 
			
		||||
            shutil.move(filename, OUT_DIR)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def download_raw(url, date):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue