acts_as_kaltura 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/acts_as_kaltura/annotation.rb +29 -32
- data/lib/acts_as_kaltura/delegator.rb +15 -17
- data/lib/acts_as_kaltura/extension.rb +2 -4
- data/lib/acts_as_kaltura/version.rb +1 -1
- data/lib/acts_as_kaltura/video.rb +88 -91
- data/lib/acts_as_kaltura.rb +1 -0
- metadata +18 -18
@@ -15,47 +15,44 @@ module ActsAsKaltura
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
def create_kaltura_annotation
|
19
|
+
if self.cuepoint_key.nil?
|
20
|
+
@kaltura_annotation = self.class.kaltura_client.cuepoint_service.
|
21
|
+
add( self.as_annotation_cuepoint )
|
22
|
+
raise KalturaAnnotationAddFailure if @kaltura_annotation.nil?
|
19
23
|
|
20
|
-
|
21
|
-
if self.cuepoint_key.nil?
|
22
|
-
@kaltura_annotation = self.class.kaltura_client.cuepoint_service.
|
23
|
-
add( self.as_annotation_cuepoint )
|
24
|
-
raise KalturaAnnotationAddFailure if @kaltura_annotation.nil?
|
25
|
-
|
26
|
-
self.cuepoint_key = @kaltura_annotation.id.to_s
|
27
|
-
end
|
24
|
+
self.cuepoint_key = @kaltura_annotation.id.to_s
|
28
25
|
end
|
26
|
+
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
28
|
+
def update_kaltura_annotation
|
29
|
+
if self.cuepoint_key.present?
|
30
|
+
@kaltura_annotation = self.class.kaltura_client.cuepoint_service.
|
31
|
+
update(self.cuepoint_key, self.as_annotation_cuepoint )
|
32
|
+
raise KalturaAnnotationUpdateFailure if @kaltura_annotation.nil?
|
36
33
|
end
|
34
|
+
end
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
36
|
+
def delete_kaltura_annotation
|
37
|
+
if self.cuepoint_key.present?
|
38
|
+
self.class.kaltura_client.cuepoint_service.delete(self.cuepoint_key)
|
39
|
+
@kaltura_annotation = nil
|
43
40
|
end
|
41
|
+
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
def kaltura_annotation
|
44
|
+
@kaltura_annotation ||= find_kaltura_annotation
|
45
|
+
end
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
def kaltura_annotation=(annotation)
|
48
|
+
@kaltura_annotation = annotation
|
49
|
+
end
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
51
|
+
private
|
52
|
+
def find_kaltura_annotation
|
53
|
+
if self.cuepoint_key.present?
|
54
|
+
self.class.kaltura_client.cuepoint_service.get(self.cuepoint_key)
|
58
55
|
end
|
59
|
-
|
56
|
+
end
|
60
57
|
end
|
61
58
|
end
|
@@ -24,27 +24,25 @@ module ActsAsKaltura
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
self.
|
32
|
-
self.send(:"#{attr}=", nil)
|
33
|
-
end
|
27
|
+
protected
|
28
|
+
def reset_kaltura_delegated_attributes
|
29
|
+
if self.class._kaltura_options.present?
|
30
|
+
self.class._kaltura_options[:delegate].each do |attr|
|
31
|
+
self.send(:"#{attr}=", nil)
|
34
32
|
end
|
35
33
|
end
|
34
|
+
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
def _lookup_local_attribute(attr)
|
37
|
+
self.read_attribute attr
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
40
|
+
def _lookup_kaltura_attribute(attr)
|
41
|
+
if entry = self.kaltura_entry
|
42
|
+
value = entry.send(attr)
|
43
|
+
self.update_column(attr, value) if value
|
44
|
+
value
|
47
45
|
end
|
48
|
-
|
46
|
+
end
|
49
47
|
end
|
50
48
|
end
|
@@ -8,10 +8,8 @@ module ActsAsKaltura
|
|
8
8
|
module Extension
|
9
9
|
extend ActiveSupport::Concern
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
@cuepoint_service ||= ActsAsKaltura::Extension::Service::CuePointService.new(self)
|
14
|
-
end
|
11
|
+
def cuepoint_service
|
12
|
+
@cuepoint_service ||= ActsAsKaltura::Extension::Service::CuePointService.new(self)
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
@@ -13,7 +13,7 @@ module ActsAsKaltura
|
|
13
13
|
end
|
14
14
|
|
15
15
|
module ClassMethods
|
16
|
-
def acts_as_kaltura_video(options = {})
|
16
|
+
def acts_as_kaltura_video(options = { })
|
17
17
|
# Set instance accessors
|
18
18
|
attr_accessor :video_file, :uploaded_video_token
|
19
19
|
self._kaltura_options = options
|
@@ -24,7 +24,7 @@ module ActsAsKaltura
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# Set validators
|
27
|
-
validates :video_file, :presence => {:on => :create}
|
27
|
+
validates :video_file, :presence => { :on => :create }
|
28
28
|
|
29
29
|
# Set filters
|
30
30
|
before_save :process_uploaded_video_file
|
@@ -34,118 +34,115 @@ module ActsAsKaltura
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
else
|
48
|
-
@video_file
|
49
|
-
end
|
50
|
-
@uploaded_video_token = self.class.kaltura_client.
|
51
|
-
media_service.upload( video_file_stream )
|
52
|
-
raise ActsAsKaltura::Video::NoUploadedTokenFound if @uploaded_video_token.nil?
|
37
|
+
#
|
38
|
+
# Push user uploaded video file to kaltura server
|
39
|
+
# If successful set upload token with the object
|
40
|
+
#
|
41
|
+
def process_uploaded_video_file
|
42
|
+
if @video_file.present?
|
43
|
+
video_file_stream = if @video_file.respond_to?(:path, true)
|
44
|
+
File.open(@video_file.path)
|
45
|
+
else
|
46
|
+
@video_file
|
53
47
|
end
|
48
|
+
@uploaded_video_token = self.class.kaltura_client.
|
49
|
+
media_service.upload(video_file_stream)
|
50
|
+
raise ActsAsKaltura::Video::NoUploadedTokenFound if @uploaded_video_token.nil?
|
54
51
|
end
|
52
|
+
end
|
55
53
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
54
|
+
#
|
55
|
+
# Create kaltura video entry based on current video data
|
56
|
+
# if successful set kaltura id
|
57
|
+
#
|
58
|
+
def create_kaltura_video_entry
|
59
|
+
if @video_file.present?
|
60
|
+
# There must have uploaded token otherwise this should be invoked
|
61
|
+
raise NoUploadedTokenFound if @uploaded_video_token.nil?
|
64
62
|
|
65
|
-
|
66
|
-
|
63
|
+
# Covert host model as kaltura entry
|
64
|
+
entry = as_kaltura_entry
|
67
65
|
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
# Request kaltura service to store video entry for the
|
67
|
+
# uploaded video file
|
68
|
+
stored_entry = add_kaltuar_video_file(entry)
|
71
69
|
|
72
|
-
|
73
|
-
|
70
|
+
# Nil return should throw exception
|
71
|
+
raise KalturaVideoAddFailure if stored_entry.nil?
|
74
72
|
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
# Set kaltura_key from stored kaltura entry
|
74
|
+
self.kaltura_key = stored_entry.id.to_s
|
75
|
+
self.kaltura_syncd_at = Time.now
|
78
76
|
|
79
|
-
|
80
|
-
end
|
77
|
+
self.class.run_kaltura_after_save_callbacks self
|
81
78
|
end
|
79
|
+
end
|
82
80
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
self.class.run_kaltura_after_save_callbacks self
|
81
|
+
#
|
82
|
+
# Update kaltura existing video entry
|
83
|
+
# If successful update kaltura_syncd_at
|
84
|
+
#
|
85
|
+
def update_kaltura_video_entry
|
86
|
+
if kaltura_key.present?
|
87
|
+
entry = as_kaltura_entry
|
88
|
+
update_kaltura_entry(entry)
|
89
|
+
|
90
|
+
if @video_file.nil?
|
91
|
+
entry.id = kaltura_key
|
92
|
+
add_kaltuar_video_file(entry)
|
98
93
|
end
|
99
|
-
end
|
100
94
|
|
101
|
-
|
102
|
-
find_kaltura_entry if @kaltura_entry.nil?
|
103
|
-
@kaltura_entry
|
95
|
+
self.class.run_kaltura_after_save_callbacks self
|
104
96
|
end
|
97
|
+
end
|
105
98
|
|
106
|
-
|
107
|
-
|
99
|
+
def kaltura_entry
|
100
|
+
find_kaltura_entry if @kaltura_entry.nil?
|
101
|
+
@kaltura_entry
|
102
|
+
end
|
103
|
+
|
104
|
+
def kaltura_entry=(entry)
|
105
|
+
@kaltura_entry = entry
|
106
|
+
end
|
107
|
+
|
108
|
+
def destroy_kaltura_video_entry
|
109
|
+
if kaltura_key
|
110
|
+
destroy_kaltura_entry
|
108
111
|
end
|
112
|
+
end
|
109
113
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
+
private
|
115
|
+
def add_kaltuar_video_file(entry)
|
116
|
+
if @video_file && @uploaded_video_token
|
117
|
+
self.class.kaltura_client.media_service.
|
118
|
+
add_from_uploaded_file(entry, @uploaded_video_token)
|
114
119
|
end
|
120
|
+
end
|
115
121
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
end
|
122
|
+
def update_kaltura_entry(entry)
|
123
|
+
if kaltura_key.present?
|
124
|
+
self.class.kaltura_client.media_service.update(kaltura_key, entry)
|
125
|
+
self.kaltura_syncd_at = Time.now
|
126
|
+
end
|
127
|
+
end
|
123
128
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
end
|
129
|
+
def find_kaltura_entry
|
130
|
+
if kaltura_key
|
131
|
+
if @kaltura_entry.nil?
|
132
|
+
@kaltura_entry = self.class.kaltura_client.media_service.get(kaltura_key)
|
129
133
|
end
|
130
134
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
@kaltura_entry = self.class.kaltura_client.media_service.get(kaltura_key)
|
135
|
-
end
|
136
|
-
|
137
|
-
@kaltura_entry
|
138
|
-
end
|
139
|
-
end
|
135
|
+
@kaltura_entry
|
136
|
+
end
|
137
|
+
end
|
140
138
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
139
|
+
def destroy_kaltura_entry
|
140
|
+
if kaltura_key
|
141
|
+
self.class.kaltura_client.media_service.delete(kaltura_key)
|
142
|
+
@kaltura_entry = nil
|
143
|
+
end
|
144
|
+
rescue
|
147
145
|
|
148
|
-
end
|
149
146
|
end
|
150
147
|
end
|
151
148
|
end
|
data/lib/acts_as_kaltura.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_kaltura
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jeweler
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152318060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,40 +21,40 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152318060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: velir_kaltura-ruby
|
27
|
+
requirement: &2152315520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152315520
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: activesupport
|
38
|
+
requirement: &2152312960 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 3.1.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152312960
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: activerecord
|
49
|
+
requirement: &2152310640 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.1.3
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152310640
|
58
58
|
description: Acts as kaltura
|
59
59
|
email: hasan@somewherein.net
|
60
60
|
executables: []
|