parent
0d87cbb715
commit
64d0f30ee1
@ -0,0 +1,2 @@
|
||||
*~
|
||||
private.d/*
|
||||
@ -1,3 +1,13 @@
|
||||
# videolinks-in-smplayer
|
||||
|
||||
When used as default browser in DE (eg Trinity), it opens video links in video player.
|
||||
This set of script and sub-scripts opens various links in video player instead of in the default browser
|
||||
|
||||
## How to use
|
||||
|
||||
In Trinity desktop just set this script as default browser. It will parse all links and not recogized ones opens in default browser defined in x-www-browser
|
||||
|
||||
## How it works
|
||||
|
||||
Main script goes through all defined directories with the scripts, runs one by one and if it doesn't recognize the link, it ends with return code 1. If link matches, sub-script runs app defined in second parameter and returns code 0 to the main script. When main script receives RC 0 it ends execution immediately.
|
||||
|
||||
Execution of main script can be also stoped by return code 127 which interrupts running with message to stderr.
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
if ARGV[0].nil? or ARGV[0].empty? or ARGV[1].nil? or ARGV[1].empty? then
|
||||
$stderr.puts "Missing parameter(s). 2 parameters expected, " + ARGV.length.to_s + " was given."
|
||||
exit 127
|
||||
end
|
||||
|
||||
link = "#{ARGV[0]}"
|
||||
player = "#{ARGV[1]}"
|
||||
|
||||
if link =~ /http[s]?:\/\/www\.youtube\.com\/watch.+/i or link =~ /http[s]?:\/\/youtu\.be\/.+/i
|
||||
fork {
|
||||
exec("#{player} \"#{link}\"")
|
||||
}
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
end
|
||||
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
if ARGV[0].nil? or ARGV[0].empty? or ARGV[1].nil? or ARGV[1].empty? then
|
||||
$stderr.puts "Missing parameter(s). 2 parameters expected, " + ARGV.length.to_s + " was given."
|
||||
exit 127
|
||||
end
|
||||
|
||||
link = "#{ARGV[0]}"
|
||||
player = "#{ARGV[1]}"
|
||||
|
||||
if link =~ /http[s]?:\/\/i\.imgur\.com\/(.+)\.webm/i or link =~ /http[s]?:\/\/i\.imgur\.com\/(.+)\.gifv/i or link =~ /http[s]?:\/\/i\.imgur\.com\/(.+)\.mp4/i
|
||||
|
||||
link = "http://i.imgur.com/#{$1}.mp4"
|
||||
fork {
|
||||
exec("#{player} -no-close-at-end -actions \"repeat true\" \"#{link}\"")
|
||||
}
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
end
|
||||
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
if ARGV[0].nil? or ARGV[0].empty? or ARGV[1].nil? or ARGV[1].empty? then
|
||||
$stderr.puts "Missing parameter(s). 2 parameters expected, " + ARGV.length.to_s + " was given."
|
||||
exit 127
|
||||
end
|
||||
|
||||
link = "#{ARGV[0]}"
|
||||
player = "#{ARGV[1]}"
|
||||
|
||||
if link =~ /http[s]?:\/\/i\.4cdn\.org\/.+\/.+\.webm/i
|
||||
|
||||
link.sub!(/https/, "http")
|
||||
fork {
|
||||
exec("#{player} -no-close-at-end -actions \"repeat false\" \"#{link}\"")
|
||||
}
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
end
|
||||
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
if ARGV[0].nil? or ARGV[0].empty? or ARGV[1].nil? or ARGV[1].empty? then
|
||||
$stderr.puts "Missing parameter(s). 2 parameters expected, " + ARGV.length.to_s + " was given."
|
||||
exit 127
|
||||
end
|
||||
|
||||
link = "#{ARGV[0]}"
|
||||
player = "#{ARGV[1]}"
|
||||
|
||||
if link =~ /http[s]?:\/\/zippy\.gfycat\.com\/(.+)\.webm/i
|
||||
|
||||
link = "http://zippy.gfycat.com/#{$1}.webm"
|
||||
fork {
|
||||
exec("#{player} -no-close-at-end -actions \"repeat false\" \"#{link}\"")
|
||||
}
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
end
|
||||
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
if ARGV[0].nil? or ARGV[0].empty? or ARGV[1].nil? or ARGV[1].empty? then
|
||||
$stderr.puts "Missing parameter(s). 2 parameters expected, " + ARGV.length.to_s + " was given."
|
||||
exit 127
|
||||
end
|
||||
|
||||
link = "#{ARGV[0]}"
|
||||
player = "#{ARGV[1]}"
|
||||
|
||||
if link =~ /http:\/\/.*\.apcdn\.com\/.+\.webm/i
|
||||
|
||||
fork {
|
||||
exec("#{player} -no-close-at-end -actions \"repeat false\" \"#{link}\"")
|
||||
}
|
||||
exit 0
|
||||
elsif link =~ /http[s]?:\/\/apina\.biz\/(.+)\.webm/i
|
||||
|
||||
link = "http://termite.apcdn.com/full/#{$1}.webm"
|
||||
fork {
|
||||
exec("#{player} -no-close-at-end -actions \"repeat false\" \"#{link}\"")
|
||||
}
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
end
|
||||
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
if ARGV[0].nil? or ARGV[0].empty? or ARGV[1].nil? or ARGV[1].empty? then
|
||||
$stderr.puts "Missing parameter(s). 2 parameters expected, " + ARGV.length.to_s + " was given."
|
||||
exit 127
|
||||
end
|
||||
|
||||
link = "#{ARGV[0]}"
|
||||
player = "#{ARGV[1]}"
|
||||
|
||||
if link =~ /http[s]?:\/\/gfycat\.com\/(.+)/i
|
||||
if link =~ /^http:.*/
|
||||
link.gsub!(/^http:/, 'https:')
|
||||
end
|
||||
%x(curl #{link} 2> /dev/null).match(/id="mp4Source" src="https:(.*?)" type="video.*>/)
|
||||
link = "http:#{$1}"
|
||||
|
||||
fork {
|
||||
exec("#{player} -no-close-at-end -actions \"repeat false\" \"#{link}\"")
|
||||
}
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
end
|
||||
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
if ARGV[0].nil? or ARGV[0].empty? or ARGV[1].nil? or ARGV[1].empty? then
|
||||
$stderr.puts "Missing parameter(s). 2 parameters expected, " + ARGV.length.to_s + " was given."
|
||||
exit 127
|
||||
end
|
||||
|
||||
link = "#{ARGV[0]}"
|
||||
player = "#{ARGV[1]}"
|
||||
|
||||
if link =~ /http[s]?:\/\/example\.com\/(.+)\.example/i
|
||||
|
||||
fork {
|
||||
exec("#{player} -no-close-at-end -actions \"repeat false\" \"#{link}\"")
|
||||
}
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
end
|
||||
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
#command to run as player
|
||||
player = "smplayer"
|
||||
basepath = "~/TEMP/"
|
||||
|
||||
# Directories where to look for scripts
|
||||
# Order does matter - you can override generic script by your own
|
||||
directories = [
|
||||
"~/.yt-smplayer.d/",
|
||||
"#{basepath}yt-smplayer/private.d/",
|
||||
"#{basepath}yt-smplayer/scripts.d/"
|
||||
]
|
||||
|
||||
if ARGV[0].nil? or ARGV[0].empty? then
|
||||
$stderr.puts "No link as parameter."
|
||||
exit
|
||||
else
|
||||
link = "#{ARGV[0]}"
|
||||
end
|
||||
|
||||
# for file in Dir.glob("/home/chytrex/TEMP/yt-smplayer/private.d/*.rb").sort!
|
||||
|
||||
# List of expected return codes
|
||||
#
|
||||
# 0 - Link processed - player started
|
||||
# 1 - Link doesn't match
|
||||
# 127 - Link not present - fatal failure - stop whole further processing
|
||||
|
||||
directories.each {
|
||||
|dir|
|
||||
# Make sure to expand paths like ~
|
||||
dir = File.expand_path(dir)
|
||||
if Dir.exist?(dir) then
|
||||
for file in Dir.glob("#{dir}/*.rb").sort!
|
||||
# puts "Running - ruby \"#{file}\" \"#{link}\" \"#{player}\""
|
||||
system("ruby \"#{file}\" \"#{link}\" \"#{player}\"")
|
||||
rc = $?.exitstatus.to_i
|
||||
if rc == 0
|
||||
exit 0
|
||||
elsif rc == 127
|
||||
$stderr.puts "Fatal error trigerred by #{file}. Terminating..."
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
exec "x-www-browser \"#{link}\""
|
||||
Loading…
Reference in new issue