Skip to content

Instantly share code, notes, and snippets.

@tondol
Created October 30, 2017 16:54
Show Gist options
  • Save tondol/d4925d63accc19a86808aaf0b5ad7d34 to your computer and use it in GitHub Desktop.
Save tondol/d4925d63accc19a86808aaf0b5ad7d34 to your computer and use it in GitHub Desktop.
プン吉の動画をアレするスクリプト

Setup

$ brew install selenium-server-standalone
$ brew install chromedriver
$ brew install ffmpeg
$ brew install youtube-dl
$ bundle install --path=vendor/bundle

Run

$ bundle exec ruby download.rb
source "https://rubygems.org"
gem "watir"
#!/usr/local/bin/ruby
# -*- coding: utf-8 -*-
require 'pp'
require 'watir'
hrefs = ["https://www.openrec.tv/live/etLrwuF5sKV","https://www.openrec.tv/live/MzuG1vvBP1p","https://www.openrec.tv/movie/sxoRg7GxIxV","https://www.openrec.tv/live/AYIZinspZzu","https://www.openrec.tv/live/MUpZQa0BwxO","https://www.openrec.tv/movie/nMk08P1bEXp","https://www.openrec.tv/live/GjZ1Jih1hqE","https://www.openrec.tv/live/Uvtwep3Z5RA","https://www.openrec.tv/movie/93Nm8PwMAPK","https://www.openrec.tv/live/jk4Qez9CfBP","https://www.openrec.tv/live/UZiVVcBy7C5","https://www.openrec.tv/movie/CdHtzTHZYmt","https://www.openrec.tv/live/UWwJqfEVnIr","https://www.openrec.tv/live/qQquDkzDRkn","https://www.openrec.tv/movie/jk4rdzpFfW6","https://www.openrec.tv/live/N0vpb4_M8kr","https://www.openrec.tv/live/AMNrp17YoBk","https://www.openrec.tv/movie/jlkroF0r4gs","https://www.openrec.tv/live/5ROrPPVqibU","https://www.openrec.tv/live/UvIVeHV95C6","https://www.openrec.tv/movie/kmkcYxWQ9PQ","https://www.openrec.tv/live/MzGP1CP6POx","https://www.openrec.tv/live/UW7OxmfBnte","https://www.openrec.tv/movie/vdb6OL1RefC","https://www.openrec.tv/live/jFAWfvAn2tc","https://www.openrec.tv/movie/vKGwOqj6eHn","https://www.openrec.tv/live/_snwblL71xZ","https://www.openrec.tv/movie/B_zPM_7Fxau","https://www.openrec.tv/movie/VBFB8nJLtJo","https://www.openrec.tv/movie/UbLJrfSOnZL","https://www.openrec.tv/live/Uevokcqy7R2","https://www.openrec.tv/movie/mia3isVsyPi","https://www.openrec.tv/live/lcpNPEViXim","https://www.openrec.tv/live/Ub4BxfJAnsE","https://www.openrec.tv/movie/jFDwfr112t3","https://www.openrec.tv/live/VBO99n9qtTz","https://www.openrec.tv/movie/6MNp5JCbubw","https://www.openrec.tv/live/9sY084w8A3T","https://www.openrec.tv/movie/KS2r50og_GH"]
browser = Watir::Browser.new :chrome
browser.window.resize_to(960, 960)
browser.goto("https://www.openrec.tv/user/punpunkichi")
browser.cookies.add("ci_session", "YOUR_COOKIE_VALUE", domain: "www.openrec.tv", secure: true)
browser.goto("https://www.openrec.tv/user/punpunkichi")
puts "=== hrefs"
sources = hrefs.map {|href|
browser.goto(href)
html = browser.html()
title = browser.title()
source = nil
if html =~ %r|(https://\S+?\.cloudfront\.net/\S+?)/source.m3u8|
source = "#{$1}/chunklist_source/chunklist.m3u8"
elsif html =~ %r|(https://\S+?\.cloudfront\.net/\S+?)/index.m3u8|
source = "#{$1}/2000kbps.m3u8"
end
pp [title, source]
sleep 5
[title, source]
}
puts "=== sources"
sources.each {|title, source|
pp [title, source]
`youtube-dl #{source} -o "#{title}.%(ext)s"`
}
browser.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment