Created
October 1, 2016 15:33
-
-
Save ryanfb/7aba526efd4d1ff64f1ca63b529f13a0 to your computer and use it in GitHub Desktop.
Screenshot a random channel from your HDHomeRun device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'json' | |
# hdhomerun device ASDF found at 10.0.1.1 | |
hdhomerun_discover = `hdhomerun_config discover | head -1` | |
hdhomerun_ip = hdhomerun_discover.split(' ').last | |
lineup = JSON.parse(Net::HTTP.get(URI("http://#{hdhomerun_ip}/lineup.json"))) | |
lineup_clear = lineup.reject{|c| c['DRM'] == 1} | |
lineup_hd = lineup_clear.select{|c| c['HD'] == 1} | |
$stderr.puts "#{lineup.length} channels" | |
$stderr.puts "#{lineup_clear.length} non-DRM channels" | |
$stderr.puts "#{lineup_hd.length} non-DRM HD channels" | |
channel = lineup_hd.sample | |
filename = "#{Time.now.strftime("%Y-%m-%d-%H-%M-%S")}-#{channel['GuideName']}.png" | |
$stderr.puts channel.inspect | |
`curl -o test.ts #{channel['URL']}?duration=2` | |
`ffmpeg -i test.ts -ss 00:00:01 -vf "yadif=0:-1:0" -vframes 1 "#{filename}"` | |
$stderr.puts filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment