Compare commits

...

5 commits

4 changed files with 52 additions and 65 deletions

View file

@ -1,26 +1,32 @@
# FOSDEM Recorder
:turning_light: This project has been discontinued. It was replaced with [fosdem-recorder.cr](#FIXME).
## Prerequisites
* Make sure you have Ruby installed
* Make sure you have a recent Ruby version installed
* Make sure you have the 'bundler' Gem installed
## Installation
Install project dependencies
$ bundle install
## Usage
Get information about given URL
$ bundle exec fosdem-recorder info URL
$ fosdem_recorder info URL
Schedule video download for given URL
$ bundle exec fosdem-recorder download URL
$ fosdem_recorder download URL
Real example
@ -33,42 +39,18 @@ $ bundle exec fosdem-recorder info https://fosdem.org/2021/schedule/event/sca_we
* url = https://stream.fosdem.org/dcomposition.m3u8
$ bundle exec fosdem-recorder info https://fosdem.org/2021/schedule/event/sca_weclome/
[... schedules the download ... ]
[... schedules the download with 'at'... ]
[... downloads the file with 'ffmpeg'... ]
[... a MP4 file will be created once the video is downloaded ...]
```
# Fosdem
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fosdem`. To experiment with that code, run `bin/console` for an interactive prompt.
TODO: Delete this and the text above, and describe your gem
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'fosdem'
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install fosdem
## Usage
TODO: Write usage instructions here
## Development
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/glenux/fosdem.
Bug reports and pull requests are welcome on GitHub at https://github.com/glenux/fosdem-recorder.

View file

@ -1,15 +0,0 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/setup"
require "fosdem"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require "irb"
IRB.start(__FILE__)

View file

@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx
bundle install
# Do any other automated setup that you need to do here

View file

@ -1,21 +1,33 @@
# frozen_string_literal: true
# Cli part of FosdemRecorder
module FosdemRecorder
# Fosdem Cli - Download and cut streams video
class Cli < Thor
desc 'info URL', 'Get information about URL'
def info(url)
meta = _get_meta(url)
puts meta[:title]
puts "* start = #{meta[:start_str]}"
puts "* stop = #{meta[:stop_str]}"
puts "* length = #{meta[:duration_str]}"
puts "* stream url = #{meta[:stream_url]}"
puts meta[:title].green
puts "* event start = #{meta[:event_start]}"
puts "* event stop = #{meta[:event_stop]}"
puts "* event length = #{meta[:duration_str]}"
puts "* stream url = #{meta[:stream_url]}"
end
desc 'download URL', 'Download conference described at URL'
def download(url)
meta = _get_meta(url)
cmd = "echo ffmpeg -i #{meta[:stream_url]} -c copy -t #{meta[:duration_str]} \"#{meta[:title_sane]}.mp4\" | at #{meta[:start_str]}"
localtime = meta[:event_start].localtime
timeformat = format(
'%<hours>02d:%<minutes>02d %<year>d-%<month>02d-%<day>02d',
hours: localtime.hour,
minutes: localtime.min,
year: localtime.year,
month: localtime.month,
day: localtime.day
)
cmd = "echo ffmpeg -i #{meta[:stream_url]} -c copy -t #{meta[:duration_str]} \"#{meta[:title_sane]}.mp4\" | at #{timeformat}"
puts "Command: #{cmd}".yellow
system cmd
end
@ -25,14 +37,28 @@ module FosdemRecorder
def _validate_url(url)
return if url =~ %r{^https://fosdem.org/\d+/schedule/event/.*}
if url =~ %r{^https://fosdem.org/.*}
warn 'ERROR: not a schedule page. URL must contain .../schedule/event/...'
exit 1
end
warn 'ERROR: not a fosdem stream. URL must start with https://fosdem.org/...'
exit 1
end
def _get_meta(url)
puts "Loading data from #{url}".yellow
mechanize = Mechanize.new
page = mechanize.get(url)
# body_class = page.at('body').attr('class')
# if body_class != 'schedule-event'
# STDERR.puts "ERROR: Not an event schedule page!"
# exit 1
# end
puts body_class
title = page.title
title_sane =
title
@ -46,7 +72,7 @@ module FosdemRecorder
.at('.side-box .icon-play')
.parent
.at('.value-title')
.text
.attr('title')
.strip
play_start = Time.parse(play_start_str)
@ -56,7 +82,8 @@ module FosdemRecorder
.at('.side-box .icon-stop')
.parent
.at('.value-title')
.text.strip
.attr('title')
.strip
play_stop = Time.parse(play_stop_str)
@ -81,11 +108,12 @@ module FosdemRecorder
title: title,
title_sane: title_sane,
stream_url: stream_url,
start_str: play_start_str,
stop_str: play_stop_str,
event_start: play_start,
event_stop: play_stop,
event_start_str: play_start_str,
event_stop_str: play_stop_str,
duration_str: duration_str
}
end
end
end