youtube-dl.rb 0.2.5.2016.02.22 → 0.3.0.2016.02.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -5
- data/1.0_RELEASE_GOALS.md +7 -0
- data/lib/youtube-dl.rb +2 -1
- data/lib/youtube-dl/version.rb +2 -2
- data/lib/youtube-dl/video.rb +37 -12
- data/test/test_helper.rb +2 -6
- data/test/youtube-dl/runner_test.rb +4 -4
- data/test/youtube-dl/support_test.rb +1 -1
- data/test/youtube-dl/video_test.rb +44 -33
- metadata +2 -6
- data/lib/youtube-dl/output.rb +0 -63
- data/test/fixtures.yml +0 -65
- data/test/youtube-dl/output_test.rb +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71b0588c9e08589efa63e4e4c843848fe4c7f9b5
|
4
|
+
data.tar.gz: e1761a7dd0b9a9a60277c4d9de3faf04b1ac994e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdc87830ebc48ebb30aaa346717a287f4e71d27ce98fb8b9f8c00476ca4136e04d7a7839abd413fb557163f2267b9f227405f887d65a582962e641fb24c61c1f
|
7
|
+
data.tar.gz: 543935c0880e41152a8c7345feea95621cd456d481a4d6b26b6f80bdbf552deb58d2e694958e9318778303bdb826042a4cb5df075362591a3b5a3abbbfb944b9
|
data/.travis.yml
CHANGED
@@ -3,16 +3,21 @@ before_install:
|
|
3
3
|
- sudo apt-get update -qq
|
4
4
|
|
5
5
|
rvm:
|
6
|
-
-
|
7
|
-
- 2.
|
8
|
-
- 2.2.
|
9
|
-
-
|
10
|
-
-
|
6
|
+
- 2.0.0 # Too old stable
|
7
|
+
- 2.1.8 # Old stable
|
8
|
+
- 2.2.4 # Previous Stable
|
9
|
+
- 2.3.0 # Current stable
|
10
|
+
- ruby-head # MRI head
|
11
|
+
- jruby # JRuby RVM default
|
12
|
+
- jruby-9.0.4.0 # JRuby 9k series
|
13
|
+
- jruby-head # JRuby Head
|
14
|
+
- rbx-2 # Rubinius stable
|
11
15
|
|
12
16
|
cache: bundler
|
13
17
|
|
14
18
|
matrix:
|
15
19
|
allow_failures:
|
20
|
+
- rvm: jruby
|
16
21
|
- rvm: jruby-head
|
17
22
|
|
18
23
|
notifications:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
youtube-dl.rb hits 1.0 when:
|
2
|
+
|
3
|
+
* [x] It works on all major Unix platforms
|
4
|
+
* [x] It works on Windows
|
5
|
+
* [ ] It fully supports all features of youtube-dl in a Ruby-friendly way
|
6
|
+
* [ ] It supports logging
|
7
|
+
* [ ] [It uses v1.0 Cocaine](https://github.com/thoughtbot/cocaine/blob/master/GOALS)
|
data/lib/youtube-dl.rb
CHANGED
data/lib/youtube-dl/version.rb
CHANGED
data/lib/youtube-dl/video.rb
CHANGED
@@ -34,35 +34,60 @@ module YoutubeDL
|
|
34
34
|
def download
|
35
35
|
raise ArgumentError.new('url cannot be nil') if @url.nil?
|
36
36
|
raise ArgumentError.new('url cannot be empty') if @url.empty?
|
37
|
+
|
37
38
|
@download_options = YoutubeDL::Options.new(runner_options)
|
38
|
-
|
39
|
+
set_information_from_json(YoutubeDL::Runner.new(url, @download_options).run)
|
39
40
|
end
|
40
41
|
|
41
42
|
alias_method :get, :download
|
42
43
|
|
43
|
-
# Returns
|
44
|
-
# [{:format_code => '000', :extension => 'avi', :resolution => '320x240', :note => 'More details about the format'}]
|
44
|
+
# Returns the expected filename
|
45
45
|
#
|
46
|
-
# @return [
|
47
|
-
def
|
48
|
-
@
|
46
|
+
# @return [String] Filename downloaded to
|
47
|
+
def filename
|
48
|
+
@information._filename
|
49
49
|
end
|
50
50
|
|
51
|
-
#
|
51
|
+
# Metadata information for the video, gotten from --print-json
|
52
52
|
#
|
53
|
-
# @return [
|
54
|
-
def
|
55
|
-
@
|
53
|
+
# @return [OpenStruct] information
|
54
|
+
def information
|
55
|
+
@information || grab_information_without_download
|
56
|
+
end
|
57
|
+
|
58
|
+
# Redirect methods for information getting
|
59
|
+
#
|
60
|
+
# @param method [Symbol] method name
|
61
|
+
# @param args [Array] method arguments
|
62
|
+
# @param block [Proc] explict block
|
63
|
+
# @return [Object] The value from @information
|
64
|
+
def method_missing(method, *args, &block)
|
65
|
+
value = information.send(method, *args, &block)
|
66
|
+
|
67
|
+
if value.nil?
|
68
|
+
super
|
69
|
+
else
|
70
|
+
value
|
71
|
+
end
|
56
72
|
end
|
57
73
|
|
58
|
-
|
74
|
+
private
|
59
75
|
|
60
76
|
# Add in other default options here.
|
61
77
|
def runner_options
|
62
78
|
{
|
63
79
|
color: false,
|
64
|
-
progress: false
|
80
|
+
progress: false,
|
81
|
+
print_json: true
|
65
82
|
}.merge(@options)
|
66
83
|
end
|
84
|
+
|
85
|
+
def set_information_from_json(json) # :nodoc:
|
86
|
+
@information = OpenStruct.new(JSON.parse(json))
|
87
|
+
end
|
88
|
+
|
89
|
+
def grab_information_without_download # :nodoc:
|
90
|
+
set_information_from_json(YoutubeDL::Runner.new(url, runner_options.merge({skip_download: true})).run)
|
91
|
+
end
|
67
92
|
end
|
68
93
|
end
|
data/test/test_helper.rb
CHANGED
@@ -31,10 +31,6 @@ def remove_downloaded_files
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
last_path = @fixtures
|
38
|
-
keys.each { |key| last_path = last_path[key] }
|
39
|
-
last_path
|
34
|
+
def travis_ci?
|
35
|
+
!!ENV['TRAVIS']
|
40
36
|
end
|
@@ -27,7 +27,7 @@ describe YoutubeDL::Runner do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should not have a newline char in the executable_path' do
|
30
|
-
assert_match
|
30
|
+
assert_match(/youtube-dl\z/, @runner.executable_path)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -51,17 +51,17 @@ describe YoutubeDL::Runner do
|
|
51
51
|
it 'should handle true boolean values' do
|
52
52
|
@runner.options.truthy_value = true
|
53
53
|
|
54
|
-
assert_match
|
54
|
+
assert_match(/youtube-dl .*--truthy-value\s--|\"http.*/, @runner.to_command)
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should handle false boolean values' do
|
58
58
|
@runner.options.false_value = false
|
59
59
|
|
60
|
-
assert_match
|
60
|
+
assert_match(/youtube-dl .*--no-false-value\s--|\"http.*/, @runner.to_command)
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should not have newline char in to_command' do
|
64
|
-
assert_match
|
64
|
+
assert_match(/youtube-dl\s/, @runner.to_command)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -66,39 +66,6 @@ describe YoutubeDL::Video do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
describe '#formats' do
|
70
|
-
before do
|
71
|
-
@formats = @video.formats
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should be an Array' do
|
75
|
-
assert_instance_of Array, @formats
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should be an Array of Hashes' do
|
79
|
-
@formats.each do |f|
|
80
|
-
assert_instance_of Hash, f
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should have a hash size of 4' do
|
85
|
-
assert_equal 4, @formats.first.size
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'should include the correct information' do
|
89
|
-
[:format_code, :resolution, :extension, :note].each do |key|
|
90
|
-
assert_includes @formats.first, key
|
91
|
-
assert_includes @formats.last, key
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should not have any whitespace in the notes' do
|
96
|
-
@formats.each do |format|
|
97
|
-
assert_nil format[:note].strip!
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
69
|
describe '#filename' do
|
103
70
|
before do
|
104
71
|
@video.options.configure do |c|
|
@@ -111,8 +78,24 @@ describe YoutubeDL::Video do
|
|
111
78
|
assert_equal TEST_FILENAME, @video.filename
|
112
79
|
end
|
113
80
|
|
81
|
+
it 'should be able to be predicted' do
|
82
|
+
predicted_filename = @video.information[:_filename]
|
83
|
+
@video.download
|
84
|
+
assert_equal predicted_filename, @video.filename
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should not return previously predicted filename' do
|
88
|
+
predicted_filename = @video.information[:_filename]
|
89
|
+
@video.configure do |c|
|
90
|
+
c.output = "#{TEST_FILENAME}.2"
|
91
|
+
end
|
92
|
+
@video.download
|
93
|
+
refute_equal @video.filename, predicted_filename
|
94
|
+
end
|
95
|
+
|
114
96
|
# Broken on Travis. Output test should be fine.
|
115
97
|
# it 'should give the correct filename when run through ffmpeg' do
|
98
|
+
# skip if travis_ci?
|
116
99
|
# @video.configure do |c|
|
117
100
|
# c.output = 'nope-%(id)s.%(ext)s'
|
118
101
|
# c.extract_audio = true
|
@@ -122,4 +105,32 @@ describe YoutubeDL::Video do
|
|
122
105
|
# assert_equal "nope-#{TEST_ID}.mp3", @video.filename
|
123
106
|
# end
|
124
107
|
end
|
108
|
+
|
109
|
+
describe '#information' do
|
110
|
+
before do
|
111
|
+
@information = @video.information
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should be an OpenStruct' do
|
115
|
+
assert_instance_of OpenStruct, @information
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#method_missing' do
|
120
|
+
it 'should pull values from @information' do
|
121
|
+
assert_equal 'youtube', @video.information[:extractor] # Sanity Check
|
122
|
+
assert_equal 'youtube', @video.extractor
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should return correct formats for things' do
|
126
|
+
assert_instance_of Array, @video.formats
|
127
|
+
assert_instance_of Hash, @video.subtitles
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should fail if a method does not exist' do
|
131
|
+
assert_raises NoMethodError do
|
132
|
+
@video.i_dont_exist
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
125
136
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: youtube-dl.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.2016.02.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sapslaj
|
@@ -135,21 +135,19 @@ files:
|
|
135
135
|
- ".rubocop.yml"
|
136
136
|
- ".rubocop_todo.yml"
|
137
137
|
- ".travis.yml"
|
138
|
+
- 1.0_RELEASE_GOALS.md
|
138
139
|
- Gemfile
|
139
140
|
- LICENSE.txt
|
140
141
|
- README.md
|
141
142
|
- Rakefile
|
142
143
|
- lib/youtube-dl.rb
|
143
144
|
- lib/youtube-dl/options.rb
|
144
|
-
- lib/youtube-dl/output.rb
|
145
145
|
- lib/youtube-dl/runner.rb
|
146
146
|
- lib/youtube-dl/support.rb
|
147
147
|
- lib/youtube-dl/version.rb
|
148
148
|
- lib/youtube-dl/video.rb
|
149
|
-
- test/fixtures.yml
|
150
149
|
- test/test_helper.rb
|
151
150
|
- test/youtube-dl/options_test.rb
|
152
|
-
- test/youtube-dl/output_test.rb
|
153
151
|
- test/youtube-dl/runner_test.rb
|
154
152
|
- test/youtube-dl/support_test.rb
|
155
153
|
- test/youtube-dl/video_test.rb
|
@@ -182,10 +180,8 @@ signing_key:
|
|
182
180
|
specification_version: 4
|
183
181
|
summary: youtube-dl wrapper for Ruby
|
184
182
|
test_files:
|
185
|
-
- test/fixtures.yml
|
186
183
|
- test/test_helper.rb
|
187
184
|
- test/youtube-dl/options_test.rb
|
188
|
-
- test/youtube-dl/output_test.rb
|
189
185
|
- test/youtube-dl/runner_test.rb
|
190
186
|
- test/youtube-dl/support_test.rb
|
191
187
|
- test/youtube-dl/video_test.rb
|
data/lib/youtube-dl/output.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
module YoutubeDL
|
2
|
-
# A class of voodoo methods for parsing youtube-dl output
|
3
|
-
class Output
|
4
|
-
# @return [String] Whatever youtube-dl spat out.
|
5
|
-
attr_accessor :output
|
6
|
-
|
7
|
-
# Initialize output parser
|
8
|
-
#
|
9
|
-
# @param output [String] Whatever youtube-dl spat out.
|
10
|
-
# @return [YoutubeDL::Output] self
|
11
|
-
def initialize(output)
|
12
|
-
@output = output
|
13
|
-
end
|
14
|
-
|
15
|
-
# Takes the output of '--list-formats'
|
16
|
-
#
|
17
|
-
# @return [Array] Array of supported formats
|
18
|
-
def supported_formats
|
19
|
-
# WARNING: This shit won't be documented or even properly tested. It's almost 3 in the morning and I have no idea what I'm doing.
|
20
|
-
header_index = output.index('format code')
|
21
|
-
return nil if header_index.nil?
|
22
|
-
|
23
|
-
formats = []
|
24
|
-
output.slice(header_index..-1).split("\n").each do |line|
|
25
|
-
format = {}
|
26
|
-
format[:format_code], format[:extension], format[:resolution], format[:note] = line.scan(/\A(\d+)\s+(\w+)\s+(\S+)\s(.*)/)[0]
|
27
|
-
formats.push format
|
28
|
-
end
|
29
|
-
formats.shift # The first line is just headers
|
30
|
-
return [] if formats.first.nil?
|
31
|
-
formats.map do |format|
|
32
|
-
format[:note].strip! # Get rid of any trailing whitespace on the note.
|
33
|
-
format[:format_code] = format[:format_code].to_i # convert format code to integer
|
34
|
-
format
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Takes the output of a download
|
39
|
-
#
|
40
|
-
# @return [String] filename saved, nil if no match
|
41
|
-
def filename
|
42
|
-
# Check to see if file was already downloaded
|
43
|
-
if already_downloaded?
|
44
|
-
output.scan(/\[download\]\s(.*)\shas already been downloaded/)[0][0]
|
45
|
-
else
|
46
|
-
if output.include? 'Merging formats into'
|
47
|
-
output.scan(/Merging formats into \"(.*)\"/)[0][0]
|
48
|
-
else
|
49
|
-
output.scan(/\[.*\] Destination:\s(.*)$/).last.last
|
50
|
-
end
|
51
|
-
end
|
52
|
-
rescue NoMethodError # There wasn't a match somewhere. Kill it with fire
|
53
|
-
nil
|
54
|
-
end
|
55
|
-
|
56
|
-
# Takes the output of a download
|
57
|
-
#
|
58
|
-
# @return [Boolean] Has the file already been downloaded?
|
59
|
-
def already_downloaded?
|
60
|
-
output.include? 'has already been downloaded'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/test/fixtures.yml
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
---
|
2
|
-
:output:
|
3
|
-
:download: |
|
4
|
-
[youtube] gvdf5n-zI14: Downloading webpage
|
5
|
-
[youtube] gvdf5n-zI14: Downloading video info webpage
|
6
|
-
[youtube] gvdf5n-zI14: Extracting video information
|
7
|
-
[youtube] gvdf5n-zI14: Downloading DASH manifest
|
8
|
-
[youtube] gvdf5n-zI14: Downloading DASH manifest
|
9
|
-
[download] Destination: nope.avi-gvdf5n-zI14.mp4
|
10
|
-
[download] 100% of 1.31MiB in 00:00
|
11
|
-
:download_ffmpeg: |
|
12
|
-
[youtube] gvdf5n-zI14: Downloading webpage
|
13
|
-
[youtube] gvdf5n-zI14: Downloading video info webpage
|
14
|
-
[youtube] gvdf5n-zI14: Extracting video information
|
15
|
-
[youtube] gvdf5n-zI14: Downloading DASH manifest
|
16
|
-
[youtube] gvdf5n-zI14: Downloading DASH manifest
|
17
|
-
[download] Destination: nope.avi-gvdf5n-zI14.f136.mp4
|
18
|
-
[download] 100% of 762.83KiB in 00:04
|
19
|
-
[download] Destination: nope.avi-gvdf5n-zI14.f141.m4a
|
20
|
-
[download] 100% of 282.57KiB in 00:00
|
21
|
-
[ffmpeg] Merging formats into "nope.avi-gvdf5n-zI14.mp4"
|
22
|
-
Deleting original file nope.avi-gvdf5n-zI14.f136.mp4 (pass -k to keep)
|
23
|
-
Deleting original file nope.avi-gvdf5n-zI14.f141.m4a (pass -k to keep)
|
24
|
-
:download_exists: |
|
25
|
-
[youtube] gvdf5n-zI14: Downloading webpage
|
26
|
-
[youtube] gvdf5n-zI14: Downloading video info webpage
|
27
|
-
[youtube] gvdf5n-zI14: Extracting video information
|
28
|
-
[youtube] gvdf5n-zI14: Downloading DASH manifest
|
29
|
-
[youtube] gvdf5n-zI14: Downloading DASH manifest
|
30
|
-
[download] nope.avi-gvdf5n-zI14.mp4 has already been downloaded
|
31
|
-
[download] 100% of 1.31MiB
|
32
|
-
:download_audio: |
|
33
|
-
[youtube] gvdf5n-zI14: Downloading webpage
|
34
|
-
[youtube] gvdf5n-zI14: Downloading video info webpage
|
35
|
-
[youtube] gvdf5n-zI14: Extracting video information
|
36
|
-
[youtube] gvdf5n-zI14: Downloading DASH manifest
|
37
|
-
[youtube] gvdf5n-zI14: Downloading DASH manifest
|
38
|
-
[download] Destination: nope-gvdf5n-zI14.m4a
|
39
|
-
[download] Download completed
|
40
|
-
[ffmpeg] Correcting container in "nope-gvdf5n-zI14.m4a"
|
41
|
-
[ffmpeg] Destination: nope-gvdf5n-zI14.mp3
|
42
|
-
Deleting original file nope-gvdf5n-zI14.m4a (pass -k to keep)
|
43
|
-
:list_formats: "[youtube] gvdf5n-zI14: Downloading webpage\n[youtube] gvdf5n-zI14:
|
44
|
-
Downloading video info webpage\n[youtube] gvdf5n-zI14: Extracting video information\n[youtube]
|
45
|
-
gvdf5n-zI14: Downloading DASH manifest\n[youtube] gvdf5n-zI14: Downloading DASH
|
46
|
-
manifest\n[info] Available formats for gvdf5n-zI14:\nformat code extension resolution
|
47
|
-
note\n171 webm audio only DASH audio 120k , vorbis@128k (44100Hz),
|
48
|
-
132.26KiB\n140 m4a audio only DASH audio 129k , m4a_dash container,
|
49
|
-
aac @128k (44100Hz), 142.59KiB\n141 m4a audio only DASH audio
|
50
|
-
\ 255k , m4a_dash container, aac @256k (44100Hz), 282.57KiB\n242 webm
|
51
|
-
\ 426x240 DASH video 109k , vp9, 1fps, video only, 118.40KiB\n160 mp4
|
52
|
-
\ 256x144 DASH video 110k , avc1.4d400c, 12fps, video only, 121.30KiB\n243
|
53
|
-
\ webm 640x360 DASH video 189k , vp9, 1fps, video only, 200.48KiB\n134
|
54
|
-
\ mp4 640x360 DASH video 237k , avc1.4d401e, 24fps, video only,
|
55
|
-
239.13KiB\n133 mp4 426x240 DASH video 248k , avc1.4d4015,
|
56
|
-
24fps, video only, 270.34KiB\n244 webm 854x480 DASH video 311k
|
57
|
-
, vp9, 1fps, video only, 333.92KiB\n135 mp4 854x480 DASH video
|
58
|
-
\ 430k , avc1.4d401e, 24fps, video only, 421.60KiB\n247 webm 1280x720
|
59
|
-
\ DASH video 572k , vp9, 1fps, video only, 596.27KiB\n136 mp4 1280x720
|
60
|
-
\ DASH video 788k , avc1.4d401f, 24fps, video only, 762.83KiB\n13 3gp
|
61
|
-
\ unknown small \n17 3gp 176x144 small , mp4a.40.2,
|
62
|
-
mp4v.20.3\n36 3gp 320x240 small , mp4a.40.2, mp4v.20.3\n5
|
63
|
-
\ flv 400x240 small \n43 webm 640x360 medium
|
64
|
-
, vorbis, vp8.0\n18 mp4 640x360 medium , mp4a.40.2, avc1.42001E\n22
|
65
|
-
\ mp4 1280x720 hd720 , mp4a.40.2, avc1.64001F (best)\n"
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
describe YoutubeDL::Output do
|
4
|
-
describe '#initialize' do
|
5
|
-
it 'should set the output variable' do
|
6
|
-
sample_output = "some sample output\n\n"
|
7
|
-
parser = YoutubeDL::Output.new(sample_output)
|
8
|
-
assert_equal sample_output, parser.output
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#supported_formats' do
|
13
|
-
before do
|
14
|
-
@parser = YoutubeDL::Output.new(fixture(:output, :list_formats))
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should find a match given the correct output' do
|
18
|
-
refute_nil @parser.supported_formats
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should find the correct match and in the correct format' do
|
22
|
-
assert_includes(@parser.supported_formats, {format_code: 5, extension: 'flv', resolution: '400x240', note: 'small'})
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should return nil if no match or wrong log format' do
|
26
|
-
bad_parser = YoutubeDL::Output.new(fixture(:output, :download))
|
27
|
-
assert_nil bad_parser.supported_formats
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#filename' do
|
32
|
-
before do
|
33
|
-
@parser_download = YoutubeDL::Output.new(fixture(:output, :download))
|
34
|
-
@parser_download_ffmpeg = YoutubeDL::Output.new(fixture(:output, :download_ffmpeg))
|
35
|
-
@parser_download_exists = YoutubeDL::Output.new(fixture(:output, :download_exists))
|
36
|
-
@parser_download_audio = YoutubeDL::Output.new(fixture(:output, :download_audio))
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should find a match given the correct output' do
|
40
|
-
refute_nil @parser_download.filename
|
41
|
-
refute_nil @parser_download_ffmpeg.filename
|
42
|
-
refute_nil @parser_download_exists.filename
|
43
|
-
refute_nil @parser_download_audio.filename
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should find the correct match' do
|
47
|
-
assert_equal 'nope.avi-gvdf5n-zI14.mp4', @parser_download.filename
|
48
|
-
assert_equal 'nope.avi-gvdf5n-zI14.mp4', @parser_download_ffmpeg.filename
|
49
|
-
assert_equal 'nope.avi-gvdf5n-zI14.mp4', @parser_download_exists.filename
|
50
|
-
assert_equal 'nope-gvdf5n-zI14.mp3', @parser_download_audio.filename
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should return nil if no match or wrong log format' do
|
54
|
-
bad_parser = YoutubeDL::Output.new(fixture(:output, :list_formats))
|
55
|
-
assert_nil bad_parser.filename
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#already_downloaded?' do
|
60
|
-
before do
|
61
|
-
@parser_download = YoutubeDL::Output.new(fixture(:output, :download))
|
62
|
-
@parser_download_ffmpeg = YoutubeDL::Output.new(fixture(:output, :download_ffmpeg))
|
63
|
-
@parser_download_exists = YoutubeDL::Output.new(fixture(:output, :download_exists))
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should return a truthy value if true' do
|
67
|
-
assert @parser_download_exists.already_downloaded?
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should return a falsy value if false' do
|
71
|
-
refute @parser_download.already_downloaded?
|
72
|
-
refute @parser_download_ffmpeg.already_downloaded?
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|