rget 4.2.4 → 4.3.0

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nicovideo.rb +22 -17
  3. data/rget.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58c0cccf4ff513e28b10ff4b8158348ec0e6a9d3ecf4effe79daf848e2aef70c
4
- data.tar.gz: d7c2f8c4dd59afe8e4c5ec2d7400d7474641ce6ac85380cd80ba3c041d675ca2
3
+ metadata.gz: d6fa9111f5bf98f850fe37ffb0ae7c527fb3388bf3727fbd2b0d57d2b3a1046f
4
+ data.tar.gz: 83a382e8df65d131a76e3dd657cfe166fd8b58f25677848ef152a7145e78e861
5
5
  SHA512:
6
- metadata.gz: 3b6b3e743533af3e138b8b23e1d99af9e4bd8dffe261b0962ec88e2aacbde3a7e35c8e0d35355307fe4ced11b638ac50651a8f25727aa3393f7afa1766f8c01c
7
- data.tar.gz: 0bbec18f7c687d617ad9f0cec312df0bc0b71f48acf4d2fab23ef0bf2e110bbae82ad44690a6f0458f0cc0616dfe2afe196f7060ef7efcd15b085dc49c793db2
6
+ metadata.gz: c3724a95a6b539622e5d40a2a48b4335db37c12308af3fd7f534193bc746c0b4ed6a5e10f6430fd2f31e9b59f6c5bf50b6961bc4064f513c8f52ff9af1711ecb
7
+ data.tar.gz: f95c9f32efb1ae8d00c039dae7bc80fd763b07446f1152985e23d1831e29d687c08e0f951c3fb535b73b106aa7de45548beae06971b1fec356c4175c1c2d07e7
data/lib/nicovideo.rb CHANGED
@@ -18,15 +18,12 @@ class Nicovideo < WebRadio
18
18
 
19
19
  def download
20
20
  begin
21
- player_url = get_player_url(@url)
21
+ video = get_video(@url)
22
22
  rescue NoMethodError
23
23
  raise DownloadError.new('video not found')
24
24
  end
25
- video_id = Pathname(URI(player_url).path).basename.to_s
26
- @cover = thumbinfo(video_id, 'thumbnail_url') unless @cover
27
-
28
- video = @nico.video(video_id)
29
- title = video.title || thumbinfo(video_id, 'title') || video_id
25
+ @cover = thumbinfo(video, 'thumbnail_url') unless @cover
26
+ title = video.title || thumbinfo(video, 'title') || video.id
30
27
  title.tr!('0-9', '0-9')
31
28
  serial = title.scan(/(?:[#第]|[  ]EP|track-)(\d+)|/).flatten.compact[0].to_i
32
29
  appendix = title =~ /おまけ|アフタートーク/ ? 'a' : ''
@@ -64,21 +61,29 @@ class Nicovideo < WebRadio
64
61
  end
65
62
 
66
63
  private
67
- def get_player_url(list_url)
64
+ def get_video(list_url)
65
+ video_url = nil
66
+ offset = 0
68
67
  begin
69
- rss = RSS::Parser.parse(list_url)
70
- item = rss.items.first
71
- return item.link
72
- rescue RSS::NotWellFormedError
73
- html = open(list_url, &:read)
74
- url = html.scan(%r|/watch/[\w]+|).first
75
- raise WebRadio::DownloadError.new('video not found in this pege') unless url
76
- return "http://www.nicovideo.jp#{url}"
68
+ begin
69
+ rss = RSS::Parser.parse(list_url)
70
+ item = rss.items.first
71
+ video_url = item.link
72
+ rescue RSS::NotWellFormedError
73
+ html = open(list_url, &:read)
74
+ url = html.scan(%r|/watch/[\w]+|).first
75
+ raise WebRadio::DownloadError.new('video not found in this pege') unless url
76
+ video_url = "http://www.nicovideo.jp#{url}"
77
+ end
78
+ video = @nico.video(Pathname(URI(video_url).path).basename.to_s)
79
+ rescue Net::HTTPForbidden
80
+ offset += 1
81
+ return
77
82
  end
78
83
  end
79
84
 
80
- def thumbinfo(video_id, elem = nil)
81
- xml = open("http://ext.nicovideo.jp/api/getthumbinfo/#{video_id}").read
85
+ def thumbinfo(video, elem = nil)
86
+ xml = open("http://ext.nicovideo.jp/api/getthumbinfo/#{video.id}").read
82
87
  if elem
83
88
  return xml.scan(%r|<#{elem}>(.*)</#{elem}>|m).flatten.first
84
89
  else
data/rget.gemspec CHANGED
@@ -4,7 +4,7 @@ $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.2.4"
7
+ spec.version = "4.3.0"
8
8
  spec.authors = ["TADA Tadashi"]
9
9
  spec.email = ["t@tdtds.jp"]
10
10
  spec.description = %q{Downloading newest radio programs on the web. Supported radio stations are hibiki, onsen, niconico and freshlive.}
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.2.4
4
+ version: 4.3.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: 2017-11-06 00:00:00.000000000 Z
11
+ date: 2017-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor