Skip to content

Instantly share code, notes, and snippets.

@weirongxu
Last active August 29, 2015 14:03
Show Gist options
  • Save weirongxu/66acc5d74537ae1d575a to your computer and use it in GitHub Desktop.
Save weirongxu/66acc5d74537ae1d575a to your computer and use it in GitHub Desktop.
aria2c by uri file.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import re, os
name = 'Video Name'
num = 1
for line in file('uri', 'r'):
p = re.compile(r'\..{1,5}\?')
ex = p.search(line)
os.system("aria2c -x5 -o %s%02d.%s '%s'"
% ( name,
num,
ex.group()[1:-1],
line)
)
num += 1
#!/usr/bin/env bash
ext()
{
ext=$(echo $@ | grep -oE '\..{1,5}\?')
len=${#ext}
echo ${ext:1:$len-2}
}
name_base='Video Name'
start_num=1
while read line
do
# echo aria2c -x5 -o `printf "$name_base%02d.$(ext $line)" $start_num` "$line"
aria2c -x5 -o `printf "$name_base%02d.$(ext $line)" $start_num` "$line"
((start_num++))
done < uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment