concerto_remote_video 0.1.0 → 0.2.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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 668a7869c8c3e2fc077921b8ccdb429e0c190cb6
|
|
4
|
+
data.tar.gz: 53a607f86828229695bd1183260d7c2cf35b14f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d417af2d9efd7f60457768d738e7f45cf2526a5304278dc19f63b84301638809b69d8e5492534cc48f6835d3b450819e9cec2799a87a64da67bb0a3910a0e71
|
|
7
|
+
data.tar.gz: e275f1124329f43ef59c9f88156843c75a4fa11c6e0a56d44b453c219b185f97c21fc8eb6dce53f2c0f408a2510071762220a282adf2c42aa4875cc5ec1a9173
|
data/app/models/remote_video.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
class RemoteVideo < Content
|
|
2
|
-
after_initialize :set_kind, :create_config
|
|
2
|
+
after_initialize :set_kind, :create_config#, :load_info
|
|
3
3
|
|
|
4
4
|
after_find :load_config
|
|
5
|
+
|
|
6
|
+
before_validation :load_info
|
|
5
7
|
before_validation :save_config
|
|
6
8
|
|
|
7
9
|
validate :video_id_must_exist
|
|
@@ -55,20 +57,26 @@ class RemoteVideo < Content
|
|
|
55
57
|
def load_info
|
|
56
58
|
# dont abort if there is a duration specified
|
|
57
59
|
return if self.config['video_id'].nil? #|| !self.duration.nil?
|
|
60
|
+
return if !self.new_record?
|
|
61
|
+
|
|
58
62
|
require 'net/http'
|
|
59
63
|
if self.config['video_vendor'] == VIDEO_VENDORS[:YouTube][:id]
|
|
60
|
-
|
|
64
|
+
begin
|
|
61
65
|
video_id = URI.escape(self.config['video_id'])
|
|
62
66
|
url = "http://gdata.youtube.com/feeds/api/videos?q=#{video_id}&v=2&max-results=1&format=5&alt=jsonc"
|
|
63
67
|
json = Net::HTTP.get_response(URI.parse(url)).body
|
|
64
68
|
data = ActiveSupport::JSON.decode(json)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
rescue MultiJson::ParseError => e
|
|
70
|
+
Rails.logger.error("Could not parse results from YouTube @ #{url}: #{e.message}: #{json}")
|
|
71
|
+
errors.add(:video_id, "Could not parse results from YouTube")
|
|
72
|
+
return
|
|
73
|
+
rescue
|
|
74
|
+
Rails.logger.error("YouTube not reachable @ #{url}.")
|
|
75
|
+
errors.add(:video_id, "Could not get information about video from YouTube")
|
|
76
|
+
return
|
|
77
|
+
end
|
|
70
78
|
if data['data']['totalItems'].to_i <= 0
|
|
71
|
-
Rails.logger.
|
|
79
|
+
Rails.logger.error('No video found from ' + url)
|
|
72
80
|
self.config['video_id'] = ''
|
|
73
81
|
return
|
|
74
82
|
end
|
|
@@ -80,10 +88,8 @@ class RemoteVideo < Content
|
|
|
80
88
|
self.config['title'] = video_data['title']
|
|
81
89
|
self.config['description'] = video_data['description']
|
|
82
90
|
elsif self.config['video_vendor'] == VIDEO_VENDORS[:Vimeo][:id]
|
|
83
|
-
#todo: put these info urls in the VV constant
|
|
84
|
-
#http://vimeo.com/api/v2/video/video_id.json
|
|
85
91
|
data=[]
|
|
86
|
-
|
|
92
|
+
begin
|
|
87
93
|
video_id = URI.escape(self.config['video_id'])
|
|
88
94
|
url = "http://vimeo.com/api/v2/video/#{video_id}.json"
|
|
89
95
|
uri = URI.parse(url)
|
|
@@ -94,11 +100,11 @@ class RemoteVideo < Content
|
|
|
94
100
|
json = response.body
|
|
95
101
|
data = ActiveSupport::JSON.decode(json)
|
|
96
102
|
end
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
rescue => e
|
|
104
|
+
Rails.logger.error("Could not get information about video from Vimeo @ #{url}: #{e.message}")
|
|
105
|
+
config['video_id'] = ''
|
|
106
|
+
return
|
|
107
|
+
end
|
|
102
108
|
if data.empty?
|
|
103
109
|
Rails.logger.debug('No video found from ' + url)
|
|
104
110
|
self.config['video_id'] = ''
|
|
@@ -9,12 +9,3 @@
|
|
|
9
9
|
|
|
10
10
|
<%= render :partial => 'contents/form_elements/dates', :locals => {:form => form} %>
|
|
11
11
|
</fieldset>
|
|
12
|
-
|
|
13
|
-
<fieldset>
|
|
14
|
-
<legend><span><%=t('contents.submit_to_feeds')%></span></legend>
|
|
15
|
-
<div class="clearfix">
|
|
16
|
-
<% if @content.new_record? %>
|
|
17
|
-
<%= render :partial => 'contents/form_elements/feeds' %>
|
|
18
|
-
<% end %>
|
|
19
|
-
</div>
|
|
20
|
-
</fieldset>
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: concerto_remote_video
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian Michalski
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-06-
|
|
11
|
+
date: 2014-06-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|