refactored some method names
This commit is contained in:
		
							
								
								
									
										12
									
								
								coub-dl.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								coub-dl.py
									
									
									
									
									
								
							@@ -38,13 +38,13 @@ def print_opt(*args, **kwargs):
 | 
				
			|||||||
        print(*args, **kwargs)
 | 
					        print(*args, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def getCmdStdErr(command):
 | 
					def get_command_stderr(command):
 | 
				
			||||||
    process = Popen(command, stderr=PIPE, stdout=PIPE)
 | 
					    process = Popen(command, stderr=PIPE, stdout=PIPE)
 | 
				
			||||||
    out, err = process.communicate()
 | 
					    out, err = process.communicate()
 | 
				
			||||||
    return err
 | 
					    return err
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def getDuration(ffprobe_output):
 | 
					def get_duration(ffprobe_output):
 | 
				
			||||||
    durationPattern = r'.*Duration:\s(.+),\sstart.*'
 | 
					    durationPattern = r'.*Duration:\s(.+),\sstart.*'
 | 
				
			||||||
    regex = match(durationPattern, str(ffprobe_output))
 | 
					    regex = match(durationPattern, str(ffprobe_output))
 | 
				
			||||||
    duration = regex.groups()[0] if regex else None
 | 
					    duration = regex.groups()[0] if regex else None
 | 
				
			||||||
@@ -70,7 +70,7 @@ def download_video_stream():
 | 
				
			|||||||
         stdout=DEVNULL, stderr=DEVNULL)
 | 
					         stdout=DEVNULL, stderr=DEVNULL)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def readExtensions():
 | 
					def read_extensions():
 | 
				
			||||||
    for file in listdir():
 | 
					    for file in listdir():
 | 
				
			||||||
        for filename in FILES:
 | 
					        for filename in FILES:
 | 
				
			||||||
            if match('^{}.*'.format(FILES[filename]), file):
 | 
					            if match('^{}.*'.format(FILES[filename]), file):
 | 
				
			||||||
@@ -171,11 +171,11 @@ if exists(FILES[File.OUTPUT]):
 | 
				
			|||||||
# download streams and update FILE dict with extensions
 | 
					# download streams and update FILE dict with extensions
 | 
				
			||||||
download_audio_stream()
 | 
					download_audio_stream()
 | 
				
			||||||
download_video_stream()
 | 
					download_video_stream()
 | 
				
			||||||
readExtensions()
 | 
					read_extensions()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# get stream lengths via ffprobe
 | 
					# get stream lengths via ffprobe
 | 
				
			||||||
audioData= getDuration(getCmdStdErr(('ffprobe', FILES[Stream.AUDIO]))).split(':')
 | 
					audioData= get_duration(get_command_stderr(('ffprobe', FILES[Stream.AUDIO]))).split(':')
 | 
				
			||||||
videoData = getDuration(getCmdStdErr(('ffprobe', FILES[Stream.VIDEO]))).split(':')
 | 
					videoData = get_duration(get_command_stderr(('ffprobe', FILES[Stream.VIDEO]))).split(':')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
audioLen = timedelta(hours=float(audioData[0]), minutes=float(audioData[1]), seconds=float(audioData[2]))
 | 
					audioLen = timedelta(hours=float(audioData[0]), minutes=float(audioData[1]), seconds=float(audioData[2]))
 | 
				
			||||||
videoLen = timedelta(hours=float(videoData[0]), minutes=float(videoData[1]), seconds=float(videoData[2]))
 | 
					videoLen = timedelta(hours=float(videoData[0]), minutes=float(videoData[1]), seconds=float(videoData[2]))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user