Ejemplo n.º 1
0
def read_list(listfile):
	i=0
	url_list = list() 
	lf  = open(listfile, "r")
	v = 0
	for line in lf:
		if line.strip():
			vid = dict() 
			l = line.rstrip().split("#",1) 
			attrs = l[0].split('\t') 
			attrs = [attr.strip() for attr in attrs if attr.strip()] 
			id_str = attrs[0] if(len(attrs) > 0) else "" 
			vid["comment"] = l[1].strip() if(len(l) > 1) else "" 
			vid["status"], vid["uid_type"], vid["id"] = get_uid_from_ref(id_str) 
			vid["attrs"] = attrs[1:] if (len(attrs)>0) else "" 
			url_list.append(vid) 
			v = v+1 if(vid['uid_type'] == "video") else v 
				
		i += 1 

	return  url_list, v   
Ejemplo n.º 2
0
		uid_ref = args[0] 
	else : 
		logm.critical("Missing source. supply at least one reference to download") 
		logm.critical(usage_str,sys.argv[0])
		sys.exit(2)

	return folder, uid_ref  

#---------------------------------------------------------------
# Main function

logm = setup_main_logger() 

(folder, uidref) = parse_arguments(sys.argv[1:]) 

sp_char, id_type, vid = get_uid_from_ref(uidref)

if(id_type == "ytlist"): 
	url_list, count  = read_list(vid) 
	logm.info("Downloading %d videos from list %s",count,vid) 
	download_list(url_list,folder) 

elif (id_type == "video"):
	if(sp_char == "") : 
		logm.info("Downloading video: [%s]",vid) 
		download_video(vid,folder) 
	else : 
		status = skip_codes[sp_char] if skip_codes.has_key(sp_char) else "ERROR" 
		logm.info("Skipping vid %s: Status %s (%s)",vid,status,sp_char) 
else:
	logm.info("Type currently not supported. or Error in id_reference")