bremen 0.1.0 → 0.1.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.
data/README.md CHANGED
@@ -53,15 +53,16 @@ You can add optional parameters for filtering. But not supports all official API
53
53
 
54
54
  Retrieving methods return Track object(s).
55
55
 
56
- attribute | |
57
- -----------|----------------------|
58
- uid | unique key in a site |
59
- url | |
60
- title | |
61
- author | |
62
- length | duration of track |
63
- created_at | released datetime |
64
- updated_at | modified datetime |
56
+ attribute | |
57
+ --------------|------------------------|
58
+ uid | unique key in a site |
59
+ url | |
60
+ title | |
61
+ author | |
62
+ length | duration of track |
63
+ thumbnail_url | thumbnail image |
64
+ created_at | released datetime |
65
+ updated_at | modified datetime |
65
66
 
66
67
  ## API References
67
68
 
@@ -36,6 +36,7 @@ module Bremen
36
36
  title: hash['name'],
37
37
  author: hash['user']['name'],
38
38
  length: hash['audio_length'].to_i,
39
+ thumbnail_url: hash['pictures']['medium'],
39
40
  created_at: created_at,
40
41
  updated_at: created_at,
41
42
  })
@@ -37,14 +37,13 @@ module Bremen
37
37
  private
38
38
  def convert_singly response
39
39
  uid = response.scan(%r{<link rel="canonical" href="/watch/([^"]+)">}).flatten.first
40
- title = CGI.unescape(response.scan(%r{<meta property="og:title" content="(.+)">}).flatten.first.to_s)
41
- length = response.scan(%r{<meta property="video:duration" content="(\d+)">}).flatten.first.to_i
42
40
  created_at = Time.parse(response.scan(%r{<meta property="video:release_date" content="(.+)">}).flatten.first.to_s)
43
41
  new({
44
42
  uid: uid,
45
43
  url: "#{BASE_URL}watch/#{uid}",
46
- title: title,
47
- length: length,
44
+ title: CGI.unescape(response.scan(%r{<meta property="og:title" content="(.+)">}).flatten.first.to_s),
45
+ length: response.scan(%r{<meta property="video:duration" content="(\d+)">}).flatten.first.to_i,
46
+ thumbnail_url: response.scan(%r{<meta property="og:image" content="(.+)">}).flatten.first,
48
47
  created_at: created_at,
49
48
  updated_at: created_at,
50
49
  })
@@ -60,6 +59,7 @@ module Bremen
60
59
  url: "#{BASE_URL}watch/#{uid}",
61
60
  title: CGI.unescape(html.scan(%r{<a [^>]+ class="watch" [^>]+>(.+)</a>}).flatten.first.to_s),
62
61
  length: min.to_i * 60 + sec.to_i,
62
+ thumbnail_url: html.scan(%r{<img src="([^"]+)"[^>]*class="img_std96" ?/?>}).flatten.first,
63
63
  created_at: created_at,
64
64
  updated_at: created_at,
65
65
  })
@@ -45,6 +45,7 @@ module Bremen
45
45
  title: hash['title'],
46
46
  author: hash['user']['username'],
47
47
  length: (hash['duration'].to_i / 1000).round,
48
+ thumbnail_url: hash['artwork_url'] ? hash['artwork_url'].sub(%r{\?.*}, '') : nil,
48
49
  created_at: Time.parse(hash['created_at']),
49
50
  updated_at: Time.parse(hash['created_at']),
50
51
  })
data/lib/bremen/track.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Bremen
2
2
  module Track
3
- attr_accessor :uid, :url, :title, :author, :length, :created_at, :updated_at
3
+ attr_accessor :uid, :url, :title, :author, :thumbnail_url, :length, :created_at, :updated_at
4
4
 
5
5
  def initialize attrs = {}
6
6
  attrs.each do |key, value|
@@ -1,3 +1,3 @@
1
1
  module Bremen
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -39,6 +39,7 @@ module Bremen
39
39
  title: hash['title']['$t'],
40
40
  author: hash['author'].first['name']['$t'],
41
41
  length: hash['media$group']['yt$duration']['seconds'].to_i,
42
+ thumbnail_url: hash['media$group']['media$thumbnail'][0]['url'],
42
43
  created_at: Time.parse(hash['published']['$t']),
43
44
  updated_at: Time.parse(hash['updated']['$t']),
44
45
  })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bremen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: