bremen 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -9
- data/lib/bremen/mixcloud.rb +1 -0
- data/lib/bremen/nicovideo.rb +4 -4
- data/lib/bremen/soundcloud.rb +1 -0
- data/lib/bremen/track.rb +1 -1
- data/lib/bremen/version.rb +1 -1
- data/lib/bremen/youtube.rb +1 -0
- metadata +1 -1
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
|
59
|
-
url
|
60
|
-
title
|
61
|
-
author
|
62
|
-
length
|
63
|
-
|
64
|
-
|
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
|
|
data/lib/bremen/mixcloud.rb
CHANGED
data/lib/bremen/nicovideo.rb
CHANGED
@@ -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:
|
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
|
})
|
data/lib/bremen/soundcloud.rb
CHANGED
@@ -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
data/lib/bremen/version.rb
CHANGED
data/lib/bremen/youtube.rb
CHANGED
@@ -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
|
})
|