fetch_youtube_transcript 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +19 -0
- data/bin/fetch_youtube_transcript +36 -0
- data/fetch-youtube-transcript.gemspec +26 -0
- data/lib/fetch_youtube_transcript.rb +15 -0
- data/lib/fetch_youtube_transcript/version.rb +3 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b0a32f3e11a9860859f568804e35ff03d5a2de1a
|
4
|
+
data.tar.gz: 66ec6a930e59f184ddf4578af802c86747a23c3c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5853f95a419311401d81da8979b6aa09ae14bfa2bc38044f7cb4d6cb6f1b2f2b8d1752acf7c10fee2ad60a6b6a0ca054927c9da14cc4bf12d67bdf7ae9402d24
|
7
|
+
data.tar.gz: 54c654c0b885fea62a55a3384e2509bfb6f2f93531a59bc6e842e730ee9f5929107e88cfb4f0c3e8fd00ab8f3b4d9f8a38ccf22a0512ab1816901b7c2fb5d2ac
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.byebug_history
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fetch_youtube_transcript'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
require 'byebug'
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
optparse = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: fetch_youtube_transcript -v video_id -o output"
|
11
|
+
|
12
|
+
opts.on("-v", "--video VIDEO_ID", "Video id from Youtube") do |video_id|
|
13
|
+
options[:video_id] = video_id
|
14
|
+
end
|
15
|
+
|
16
|
+
opts.on("-o", "--output PATH", "Path where the English transcript file will be saved") do |output|
|
17
|
+
options[:output] = output
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
optparse.parse!
|
23
|
+
|
24
|
+
# from https://stackoverflow.com/a/2149183
|
25
|
+
mandatory = [:video_id, :output]
|
26
|
+
missing = mandatory.select{ |param| options[param].nil? }
|
27
|
+
unless missing.empty?
|
28
|
+
raise OptionParser::MissingArgument.new(missing.join(", "))
|
29
|
+
end
|
30
|
+
|
31
|
+
FetchYoutubeTranscript.new(video_id: options[:video_id]).download_transcript_to(options[:output])
|
32
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
33
|
+
puts $!.to_s
|
34
|
+
puts optparse
|
35
|
+
exit 1
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "fetch_youtube_transcript/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |gem|
|
8
|
+
gem.name = "fetch_youtube_transcript"
|
9
|
+
gem.version = FetchYoutubeTranscript::VERSION
|
10
|
+
gem.authors = ["Victor Goya"]
|
11
|
+
gem.email = ["phorque@phorque.it"]
|
12
|
+
gem.description = "Fetch Youtube Transcript"
|
13
|
+
gem.summary = "Fetch Youtube Transcript"
|
14
|
+
gem.homepage = "https://phorque.it"
|
15
|
+
|
16
|
+
gem.files = `git ls-files -z`.split("\x0")
|
17
|
+
gem.executables = %w(fetch_youtube_transcript)
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.bindir = 'bin'
|
20
|
+
|
21
|
+
gem.licenses = ["MIT"]
|
22
|
+
|
23
|
+
gem.required_ruby_version = "~> 2.0"
|
24
|
+
|
25
|
+
gem.add_development_dependency "byebug"
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
class FetchYoutubeTranscript
|
4
|
+
def initialize(options = {})
|
5
|
+
@video_id = options.delete(:video_id)
|
6
|
+
end
|
7
|
+
|
8
|
+
def download_transcript
|
9
|
+
Net::HTTP.get(URI("http://video.google.com/timedtext?lang=en&v=#{@video_id}"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def download_transcript_to(output)
|
13
|
+
File.open(output, "w").write(download_transcript)
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fetch_youtube_transcript
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Victor Goya
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: byebug
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Fetch Youtube Transcript
|
28
|
+
email:
|
29
|
+
- phorque@phorque.it
|
30
|
+
executables:
|
31
|
+
- fetch_youtube_transcript
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- Gemfile
|
37
|
+
- Gemfile.lock
|
38
|
+
- bin/fetch_youtube_transcript
|
39
|
+
- fetch-youtube-transcript.gemspec
|
40
|
+
- lib/fetch_youtube_transcript.rb
|
41
|
+
- lib/fetch_youtube_transcript/version.rb
|
42
|
+
homepage: https://phorque.it
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.5.2.1
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Fetch Youtube Transcript
|
66
|
+
test_files: []
|