rget 4.10.0 → 4.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/webradio.rb +3 -0
- data/lib/youtube.rb +40 -0
- data/rget.gemspec +2 -2
- data/rget.yaml +4 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 399f9407dcfa7a2c99884c4c7c1cac60fabaae386622bac006896d877e2f1c71
|
4
|
+
data.tar.gz: 5ba2047c907946753452437b51ecf3a55f3e7fa97e247c6ffab04f10badda4fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0d57aff2683b09e53fbd663a11db02e862430d51ed97588c317e1432aa0b5d13625fc6747a8c83b210b1b394a726c48662af5c2b22ba24bbd08d8ddebf08487
|
7
|
+
data.tar.gz: de34fca3119bbb1a78704131e0a825fe3f2d0b77d1426dbe08bb0cf94eed751f6961b1c34e37a55f2907dfafed803877f692aeafffe780f9513b1b239270ba03
|
data/README.md
CHANGED
@@ -8,9 +8,10 @@ Downloading newest radio programs on the web. Supported radio stations are:
|
|
8
8
|
* himalaya.fm
|
9
9
|
* Asobi Store
|
10
10
|
* stand.fm
|
11
|
+
* YouTube (playlist only)
|
11
12
|
|
12
13
|
If you want to save files as MP3, needs `ffmpeg` command.
|
13
|
-
To download niconico video, also needs latest `youtube-dl` command (you can get it from `https://yt-dl.org/`), then specify
|
14
|
+
To download niconico video or YouTube, also needs latest `youtube-dl` command (you can get it from `https://yt-dl.org/`), then specify user ID and password to `~/.netrc` for niconico as:
|
14
15
|
|
15
16
|
```
|
16
17
|
machine niconico
|
data/lib/webradio.rb
CHANGED
@@ -32,6 +32,9 @@ class WebRadio
|
|
32
32
|
when %r[^https://stand\.fm/channels/]
|
33
33
|
require 'standfm'
|
34
34
|
StandFm.new(params, options)
|
35
|
+
when %r[^https://www\.youtube\.com/playlist]
|
36
|
+
require 'youtube'
|
37
|
+
Youtube.new(params, options)
|
35
38
|
else
|
36
39
|
raise UnsupportError, "unsupported url: #{params['url']}"
|
37
40
|
end
|
data/lib/youtube.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Youtube < WebRadio
|
5
|
+
def initialize(params, options)
|
6
|
+
super
|
7
|
+
@offset = 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def download
|
11
|
+
html = URI.open(@url).read
|
12
|
+
json_str = html.scan(/ytInitialData = (.*);<\/script>/).flatten.first
|
13
|
+
json = JSON.parse(json_str)
|
14
|
+
title = json["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][0]["tabRenderer"]["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0]["playlistVideoListRenderer"]["contents"][0]["playlistVideoRenderer"]["title"]["runs"][0]["text"]
|
15
|
+
@cover = json["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][0]["tabRenderer"]["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0]["playlistVideoListRenderer"]["contents"][0]["playlistVideoRenderer"]["thumbnail"]["thumbnails"].last["url"]
|
16
|
+
mp4_url = "https://www.youtube.com#{json["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][0]["tabRenderer"]["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0]["playlistVideoListRenderer"]["contents"][0]["playlistVideoRenderer"]["navigationEndpoint"]["commandMetadata"]["webCommandMetadata"]["url"]}"
|
17
|
+
serial = title.scan(/[0-9]+/).first
|
18
|
+
|
19
|
+
mp4_file = "#{@label}##{serial}.mp4"
|
20
|
+
mp3_file = "#{@label}##{serial}.mp3"
|
21
|
+
begin
|
22
|
+
mp3nize(mp4_file, mp3_file) do
|
23
|
+
loop do
|
24
|
+
print '.'
|
25
|
+
_, err, status = Open3.capture3("youtube-dl -f mp4 -o #{mp4_file} --netrc '#{mp4_url}'")
|
26
|
+
break if status == 0
|
27
|
+
next if err =~ /403: Forbidden/
|
28
|
+
raise ForbiddenError.new("Could not access to #{mp4_url}") if err =~ /TypeError|AssertionError/
|
29
|
+
raise DownloadError.new(err)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
rescue ForbiddenError
|
33
|
+
puts "#{$!.message}, try next."
|
34
|
+
@offset += 1
|
35
|
+
retry
|
36
|
+
rescue NotFoundError
|
37
|
+
raise DownloadError.new('video not found')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/rget.gemspec
CHANGED
@@ -4,10 +4,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "rget"
|
7
|
-
spec.version = "4.
|
7
|
+
spec.version = "4.11.0"
|
8
8
|
spec.authors = ["Tada, Tadashi"]
|
9
9
|
spec.email = ["t@tdtds.jp"]
|
10
|
-
spec.description = %q{Downloading newest radio programs on the web. Supported radio stations are hibiki, onsen, niconico, himalaya, asobi store
|
10
|
+
spec.description = %q{Downloading newest radio programs on the web. Supported radio stations are hibiki, onsen, niconico, himalaya, asobi store, stand.fm and youtube playlist.}
|
11
11
|
spec.summary = %q{Downloading newest radio programs on the web.}
|
12
12
|
spec.homepage = "https://github.com/wasamas/rget"
|
13
13
|
spec.license = "GPL"
|
data/rget.yaml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rget
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tada, Tadashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -151,7 +151,7 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
description: Downloading newest radio programs on the web. Supported radio stations
|
154
|
-
are hibiki, onsen, niconico, himalaya, asobi store
|
154
|
+
are hibiki, onsen, niconico, himalaya, asobi store, stand.fm and youtube playlist.
|
155
155
|
email:
|
156
156
|
- t@tdtds.jp
|
157
157
|
executables:
|
@@ -183,6 +183,7 @@ files:
|
|
183
183
|
- lib/podcast.rb
|
184
184
|
- lib/standfm.rb
|
185
185
|
- lib/webradio.rb
|
186
|
+
- lib/youtube.rb
|
186
187
|
- rget.gemspec
|
187
188
|
- rget.yaml
|
188
189
|
homepage: https://github.com/wasamas/rget
|