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: 8aab3b8075e04c908c8d1bf42f470500d2e46cb3
4
- data.tar.gz: 1f57acecf847a89146474c546ddd804d65ff4bf8
3
+ metadata.gz: 668a7869c8c3e2fc077921b8ccdb429e0c190cb6
4
+ data.tar.gz: 53a607f86828229695bd1183260d7c2cf35b14f4
5
5
  SHA512:
6
- metadata.gz: 833b63f0ff0eabd8a230c086b27f2e21e49705268c9d2e4216158ee099bf18192ab6a4cfbdacdcbc66ac36f8661a028ee06054747e5146ab9fda218b05d43f48
7
- data.tar.gz: 5b48a286e376a729791c6e0779dcd6a5efa77fc5886194cdbd51da33fe109f8e5283d22e61a3b60ffa657bd4332afb18ec83539acc173043fda3000ded5cee49
6
+ metadata.gz: 7d417af2d9efd7f60457768d738e7f45cf2526a5304278dc19f63b84301638809b69d8e5492534cc48f6835d3b450819e9cec2799a87a64da67bb0a3910a0e71
7
+ data.tar.gz: e275f1124329f43ef59c9f88156843c75a4fa11c6e0a56d44b453c219b185f97c21fc8eb6dce53f2c0f408a2510071762220a282adf2c42aa4875cc5ec1a9173
@@ -1,7 +1,9 @@
1
1
  class RemoteVideo < Content
2
- after_initialize :set_kind, :create_config, :load_info
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
- #begin
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
- #rescue
66
- # Rails.logger.debug("YouTube not reachable @ #{url}.")
67
- # config['video_id'] = ''
68
- # return
69
- #end
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.debug('No video found from ' + url)
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
- #begin
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
- #rescue
98
- # Rails.logger.debug("YouTube not reachable @ #{url}.")
99
- # config['video_id'] = ''
100
- # return
101
- #end
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>
@@ -1,3 +1,3 @@
1
1
  module ConcertoRemoteVideo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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-17 00:00:00.000000000 Z
11
+ date: 2014-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails