parent
d6720e6bb6
commit
48a825c9b7
@ -0,0 +1 @@
|
|||||||
|
*~
|
||||||
@ -1,3 +1,7 @@
|
|||||||
# iprima-series-dl
|
# iprima-series-dl
|
||||||
|
|
||||||
Simple ruby script for getting links via curl and downloading them via youtube-dl script from iprima.cz archive
|
Simple ruby script for getting links via curl and downloading them via youtube-dl script from iprima.cz archive.
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
* curl
|
||||||
|
* youtube-dl
|
||||||
|
|||||||
@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
|
filename = "links.txt"
|
||||||
|
template = "#EP#_#TITLE##EXT#"
|
||||||
|
|
||||||
|
if ARGV[0].nil? or ARGV[0].empty? then
|
||||||
|
puts "Please enter iprima series URL"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
url = ARGV[0]
|
||||||
|
|
||||||
|
data = `curl #{url} 2> /dev/null | grep epizoda`.split("\n").reverse
|
||||||
|
links = []
|
||||||
|
|
||||||
|
fd = File.open(filename, "w+")
|
||||||
|
data.each {
|
||||||
|
|line|
|
||||||
|
if line =~ /.*href="(\/\/.*?)".*/ then
|
||||||
|
links.push "http:#{$1}"
|
||||||
|
fd.puts "http:#{$1}"
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
fd.puts
|
||||||
|
fd.close
|
||||||
|
count = links.size
|
||||||
|
|
||||||
|
if count > 0 then
|
||||||
|
puts "Links found: #{count}"
|
||||||
|
puts links
|
||||||
|
|
||||||
|
if `which youtube-dl`.empty? then
|
||||||
|
puts "ERROR: youtube-dl not found"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
puts
|
||||||
|
puts "Trying to download links..."
|
||||||
|
|
||||||
|
system("youtube-dl -f best -a #{filename}")
|
||||||
|
|
||||||
|
basedir = '.'
|
||||||
|
files = Dir.glob("*.mp4").sort
|
||||||
|
files.each {
|
||||||
|
|name|
|
||||||
|
if name =~/^(.*) \((\d+)\) - (.*)-p\d+(\.mp4)$/ then
|
||||||
|
season=$1
|
||||||
|
ep=$2
|
||||||
|
title=$3
|
||||||
|
ext=$4
|
||||||
|
if ep.to_i < 10 then
|
||||||
|
ep = "0#{ep}"
|
||||||
|
end
|
||||||
|
newname = template.gsub("#EP#", ep).gsub("#TITLE#", title).gsub("#SEASON#", season).gsub("#EXT#", ext)
|
||||||
|
puts "Got: #{name}"
|
||||||
|
puts "Renaming to: #{newname}"
|
||||||
|
File.rename(name, newname)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
puts "No links found..."
|
||||||
|
end
|
||||||
Loading…
Reference in new issue