kaltura_box 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +2 -0
- data/kaltura_box.gemspec +28 -0
- data/lib/generators/kaltura_box/install_generator.rb +16 -0
- data/lib/generators/templates/kaltura_box.rb +18 -0
- data/lib/generators/templates/kaltura_upload.js +67 -0
- data/lib/kaltura_box.rb +10 -0
- data/lib/kaltura_box/api.rb +13 -0
- data/lib/kaltura_box/category.rb +18 -0
- data/lib/kaltura_box/category/class_methods.rb +50 -0
- data/lib/kaltura_box/category/instance_methods.rb +30 -0
- data/lib/kaltura_box/client.rb +45 -0
- data/lib/kaltura_box/configuration.rb +22 -0
- data/lib/kaltura_box/entry.rb +36 -0
- data/lib/kaltura_box/entry/class_methods.rb +51 -0
- data/lib/kaltura_box/entry/instance_methods.rb +13 -0
- data/lib/kaltura_box/entry/metadata.rb +152 -0
- data/lib/kaltura_box/entry/metadata/class_and_instance_methods.rb +54 -0
- data/lib/kaltura_box/entry/metadata/class_methods.rb +69 -0
- data/lib/kaltura_box/version.rb +3 -0
- data/spec/api_spec.rb +22 -0
- data/spec/category_spec.rb +51 -0
- data/spec/entry_spec.rb +38 -0
- data/spec/metadata_spec.rb +256 -0
- data/spec/spec_helper.rb +68 -0
- data/spec/support/video.flv +0 -0
- data/vendor/kaltura-ruby-client/README +20 -0
- data/vendor/kaltura-ruby-client/Rakefile +19 -0
- data/vendor/kaltura-ruby-client/kaltura.gemspec +15 -0
- data/vendor/kaltura-ruby-client/kaltura.yml +7 -0
- data/vendor/kaltura-ruby-client/lib/kaltura.rb +31 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_client.rb +14450 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_client_base.rb +432 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_abc_screeners_watermark_access_control_client_plugin.rb +37 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_ad_cue_point_client_plugin.rb +108 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_annotation_client_plugin.rb +237 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_aspera_client_plugin.rb +61 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_attachment_client_plugin.rb +227 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_audit_client_plugin.rb +349 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_bulk_upload_client_plugin.rb +109 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_bulk_upload_csv_client_plugin.rb +55 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_bulk_upload_filter_client_plugin.rb +46 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_bulk_upload_xml_client_plugin.rb +40 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_caption_client_plugin.rb +406 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_caption_search_client_plugin.rb +138 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_code_cue_point_client_plugin.rb +97 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_content_distribution_client_plugin.rb +1717 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_cue_point_client_plugin.rb +290 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_document_client_plugin.rb +522 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_drm_client_plugin.rb +204 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_drop_folder_client_plugin.rb +810 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_drop_folder_xml_bulk_upload_client_plugin.rb +39 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_email_notification_client_plugin.rb +276 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_event_notification_client_plugin.rb +405 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_external_media_client_plugin.rb +203 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_file_sync_client_plugin.rb +151 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_http_notification_client_plugin.rb +309 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_kontiki_client_plugin.rb +72 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_like_client_plugin.rb +82 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_metadata_client_plugin.rb +788 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_multi_centers_client_plugin.rb +45 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_short_link_client_plugin.rb +231 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_tag_search_client_plugin.rb +145 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_var_console_client_plugin.rb +238 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_velocix_client_plugin.rb +40 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_virus_scan_client_plugin.rb +263 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_webex_drop_folder_client_plugin.rb +121 -0
- data/vendor/kaltura-ruby-client/lib/kaltura_plugins/kaltura_widevine_client_plugin.rb +195 -0
- data/vendor/kaltura-ruby-client/license.txt +674 -0
- data/vendor/kaltura-ruby-client/test/access_control_service_test.rb +75 -0
- data/vendor/kaltura-ruby-client/test/base_entry_service_test.rb +267 -0
- data/vendor/kaltura-ruby-client/test/configuration_test.rb +178 -0
- data/vendor/kaltura-ruby-client/test/cue_point_service_test.rb +67 -0
- data/vendor/kaltura-ruby-client/test/data_service_test.rb +76 -0
- data/vendor/kaltura-ruby-client/test/document_service_test.rb +41 -0
- data/vendor/kaltura-ruby-client/test/media/test.mov +0 -0
- data/vendor/kaltura-ruby-client/test/media/test.pdf +0 -0
- data/vendor/kaltura-ruby-client/test/media/test.png +0 -0
- data/vendor/kaltura-ruby-client/test/media/test.swf +0 -0
- data/vendor/kaltura-ruby-client/test/media/test.wmv +0 -0
- data/vendor/kaltura-ruby-client/test/media_service_test.rb +294 -0
- data/vendor/kaltura-ruby-client/test/metadata_profile_service_test.rb +63 -0
- data/vendor/kaltura-ruby-client/test/test_helper.rb +59 -0
- metadata +220 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: ef074ebbbc9f5d418b83bceaf45f25e5ce4668d1
|
|
4
|
+
data.tar.gz: 1eb48ebcb0461976d12e1949c35c765e60608cba
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f585e2fd7efcdcc2d0497d31d68706e7742591e900c0ac9e927ce2970e20bcd53cb23fc40668a4ccda4202094b573650a10843314653e92b785df7b6d164fc04
|
|
7
|
+
data.tar.gz: 73b163b702644eea8a8dc66ae3dfefc7ff442cc56d76539e76dc2ed7453687411d61e2769cba8e3e2124a04f434a28553116131c8ffd0276f062a42ab3a42e79
|
data/.gitignore
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
*.bundle
|
|
19
|
+
*.so
|
|
20
|
+
*.o
|
|
21
|
+
*.a
|
|
22
|
+
mkmf.log
|
|
23
|
+
.ruby-version
|
|
24
|
+
.ruby-gemset
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 shinn
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# KalturaBox
|
|
2
|
+
|
|
3
|
+
Customized Ruby wrapper for Kaltura API
|
|
4
|
+
|
|
5
|
+
Heavily influenced and continuation of [Kaltura_Fu](https://github.com/Velir/kaltura_fu)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
gem 'kaltura_box'
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install kaltura_box
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
# For the Entry class
|
|
24
|
+
class Video < ActiveRecord::Base
|
|
25
|
+
include KalturaBox::Entry
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Category class
|
|
29
|
+
class Category < ActiveRecord::Base
|
|
30
|
+
include KalturaBox::Category
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Entry listing from Kaltura
|
|
34
|
+
Video.video_list
|
|
35
|
+
|
|
36
|
+
# Create videos based on Kaltura entries
|
|
37
|
+
Video.update_all_videos!
|
|
38
|
+
|
|
39
|
+
# Retrieve a kaltura entry
|
|
40
|
+
video = Video.new(entry_id: "0_7ivwzhbh")
|
|
41
|
+
video.get
|
|
42
|
+
|
|
43
|
+
# Tagging
|
|
44
|
+
video.set_tags = "noodles, food, yummy" # Create a new set of tags
|
|
45
|
+
video.add_tags = "rice, fruits" # Add more tags to the existing tag list
|
|
46
|
+
video.add_tag("bacon") # Add a single tag
|
|
47
|
+
video.get_tags # Retrieve tags
|
|
48
|
+
|
|
49
|
+
# Kaltura Metadata
|
|
50
|
+
video.set(name: "bla", description: "blablabla")
|
|
51
|
+
video.set_name = "bla"
|
|
52
|
+
video.set_description = "blablabla"
|
|
53
|
+
|
|
54
|
+
## Contributing
|
|
55
|
+
|
|
56
|
+
1. Fork it ( https://github.com/[my-github-username]/kaltura_box/fork )
|
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
60
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/kaltura_box.gemspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'kaltura_box/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "kaltura_box"
|
|
8
|
+
spec.version = KalturaBox::VERSION
|
|
9
|
+
spec.authors = ["Shinn Chong"]
|
|
10
|
+
spec.email = ["shinnyx@gmail.com"]
|
|
11
|
+
spec.summary = %q{Ruby wrapper for Kaltura API}
|
|
12
|
+
spec.description = spec.summary
|
|
13
|
+
spec.homepage = "https://github.com/shinnyx/kaltura_box"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_runtime_dependency('kaltura-ruby-client')
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
24
|
+
spec.add_development_dependency "rake"
|
|
25
|
+
spec.add_development_dependency 'rspec'
|
|
26
|
+
spec.add_development_dependency 'activerecord'
|
|
27
|
+
spec.add_development_dependency 'sqlite3'
|
|
28
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module KalturaBox
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
source_root File.expand_path("../../templates",__FILE__)
|
|
5
|
+
desc "Copies the KalturaBox config file and upload JS to your app."
|
|
6
|
+
|
|
7
|
+
def copy_config
|
|
8
|
+
copy_file "kaltura_box.rb", "config/initializers/kaltura_box.rb"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def copy_javascript
|
|
12
|
+
copy_file "kaltura_upload.js", "public/javascripts/kaltura_upload.js"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Set up the following configuration with environment variables (Recommended)
|
|
2
|
+
#
|
|
3
|
+
# Obtain your Kaltura API publisher credentials via the KMC Integration Settings
|
|
4
|
+
# http://www.kaltura.com/index.php/kmc/kmc4#account|integration
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
KalturaBox.config do |c|
|
|
8
|
+
c.login_email = ENV["USER_EMAIL"]
|
|
9
|
+
c.login_password = ENV["THE_PASSWORD"]
|
|
10
|
+
c.partner_id = ENV["PARTNER_ID"]
|
|
11
|
+
c.subpartner_id = ENV["PARTNER_ID"].to_i * 100
|
|
12
|
+
c.administrator_secret = ENV["ADMINISTRATOR_SECRET"]
|
|
13
|
+
c.user_secret = ENV["USER_SECRET"]
|
|
14
|
+
c.thumb_width = "300"
|
|
15
|
+
c.thumb_height = "300"
|
|
16
|
+
c.player_conf_id = ENV["whatever"]
|
|
17
|
+
c.service_url = "http://www.kaltura.com"
|
|
18
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var flashObj;
|
|
2
|
+
var delegate = {};
|
|
3
|
+
var mediaTypeInput;
|
|
4
|
+
|
|
5
|
+
//KSU handlers
|
|
6
|
+
delegate.readyHandler = function()
|
|
7
|
+
{
|
|
8
|
+
flashObj = document.getElementById("uploader");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
delegate.selectHandler = function()
|
|
12
|
+
{
|
|
13
|
+
//flashObj.upload();
|
|
14
|
+
console.log("selectHandler()");
|
|
15
|
+
console.log(flashObj.getTotalSize());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function setMediaType()
|
|
19
|
+
{
|
|
20
|
+
var mediaType = document.getElementById("mediaTypeInput").value;
|
|
21
|
+
//alert(mediaType);
|
|
22
|
+
console.log(mediaType);
|
|
23
|
+
flashObj.setMediaType(mediaType);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
delegate.singleUploadCompleteHandler = function(args)
|
|
27
|
+
{
|
|
28
|
+
|
|
29
|
+
flashObj.addEntries();
|
|
30
|
+
console.log("singleUploadCompleteHandler", args[0].title);
|
|
31
|
+
document.getElementById('button_submit').disabled = false;
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
delegate.allUploadsCompleteHandler = function()
|
|
36
|
+
{
|
|
37
|
+
console.log("allUploadsCompleteHandler");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
delegate.entriesAddedHandler = function(entries)
|
|
41
|
+
{
|
|
42
|
+
//alert(entries.length);
|
|
43
|
+
var entry = entries[0];
|
|
44
|
+
//alert(entry.entryId);
|
|
45
|
+
document.getElementById('video_entry_id').value = entry.entryId
|
|
46
|
+
console.log(entries);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
delegate.progressHandler = function(args)
|
|
50
|
+
{
|
|
51
|
+
document.getElementById('video_title').value = args[2].title;
|
|
52
|
+
var bob = Math.round(args[0] / args[1] * 100);
|
|
53
|
+
document.getElementById('progress').value = bob;
|
|
54
|
+
console.log(args[2].title + ": " + args[0] + " / " + args[1]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
delegate.uiConfErrorHandler = function()
|
|
58
|
+
{
|
|
59
|
+
console.log("ui conf loading error");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
<!--- JavaScript callback methods to activate Kaltura services via the KSU widget.-->
|
|
63
|
+
function upload()
|
|
64
|
+
{
|
|
65
|
+
flashObj.upload();
|
|
66
|
+
//flashObj.addEntries();
|
|
67
|
+
}
|
data/lib/kaltura_box.rb
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'kaltura'
|
|
2
|
+
require "kaltura_box/api"
|
|
3
|
+
require "kaltura_box/category"
|
|
4
|
+
require "kaltura_box/client"
|
|
5
|
+
require "kaltura_box/entry"
|
|
6
|
+
require "kaltura_box/version"
|
|
7
|
+
|
|
8
|
+
module KalturaBox
|
|
9
|
+
require 'kaltura_fu/railtie' if defined?(Rails) && Rails.version.split(".").first > "2"
|
|
10
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'kaltura'
|
|
2
|
+
require 'kaltura_box/category/class_methods'
|
|
3
|
+
require 'kaltura_box/category/instance_methods'
|
|
4
|
+
|
|
5
|
+
module KalturaBox
|
|
6
|
+
module Category
|
|
7
|
+
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.extend ClassMethods
|
|
10
|
+
base.class_eval do
|
|
11
|
+
include ClassMethods
|
|
12
|
+
include InstanceMethods
|
|
13
|
+
end
|
|
14
|
+
super
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'kaltura'
|
|
2
|
+
|
|
3
|
+
module KalturaBox
|
|
4
|
+
module Category
|
|
5
|
+
module ClassMethods
|
|
6
|
+
|
|
7
|
+
def list
|
|
8
|
+
client = KalturaBox::Client.update_session
|
|
9
|
+
category = Kaltura::KalturaCategoryService.new(client)
|
|
10
|
+
category_list = category.list
|
|
11
|
+
category_list.objects
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def update_all_categories!
|
|
15
|
+
list.each do |category|
|
|
16
|
+
self.create(
|
|
17
|
+
name: category.name,
|
|
18
|
+
full_name: category.full_name,
|
|
19
|
+
description: category.description,
|
|
20
|
+
ref_id: category.id,
|
|
21
|
+
entries_count: category.entries_count
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add(name, description, destroy_after_create = false)
|
|
27
|
+
client = KalturaBox::Client.update_session
|
|
28
|
+
category_svc = Kaltura::KalturaCategoryService.new(client)
|
|
29
|
+
|
|
30
|
+
new_category = Kaltura::KalturaCategory.new
|
|
31
|
+
new_category.name = name
|
|
32
|
+
new_category.description = description
|
|
33
|
+
|
|
34
|
+
if category = category_svc.add(new_category)
|
|
35
|
+
@cat_obj = self.create(
|
|
36
|
+
name: category.name,
|
|
37
|
+
full_name: category.full_name,
|
|
38
|
+
description: category.description,
|
|
39
|
+
ref_id: category.id,
|
|
40
|
+
entries_count: category.entries_count
|
|
41
|
+
)
|
|
42
|
+
category_svc.delete(@cat_obj.ref_id) if destroy_after_create
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
@cat_obj
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'kaltura'
|
|
2
|
+
|
|
3
|
+
module KalturaBox
|
|
4
|
+
module Category
|
|
5
|
+
module InstanceMethods
|
|
6
|
+
|
|
7
|
+
def edit(options={})
|
|
8
|
+
client = KalturaBox::Client.update_session
|
|
9
|
+
category_svc = Kaltura::KalturaCategoryService.new(client)
|
|
10
|
+
|
|
11
|
+
category = Kaltura::KalturaCategory.new
|
|
12
|
+
category.name = options[:name]
|
|
13
|
+
category.description = options[:description]
|
|
14
|
+
|
|
15
|
+
if category = category_svc.update(self.ref_id, category)
|
|
16
|
+
self.update(name: category.name, description: category.description)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def remove
|
|
21
|
+
client = KalturaBox::Client.update_session
|
|
22
|
+
category_svc = Kaltura::KalturaCategoryService.new(client)
|
|
23
|
+
|
|
24
|
+
result = category_svc.delete(self.ref_id) # should returns nil
|
|
25
|
+
self.destroy
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'kaltura'
|
|
2
|
+
require 'kaltura_box/configuration'
|
|
3
|
+
|
|
4
|
+
module KalturaBox
|
|
5
|
+
class Client
|
|
6
|
+
attr_accessor :client, :client_config, :session_key
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
|
|
10
|
+
def create
|
|
11
|
+
self.setup_config unless @client_config
|
|
12
|
+
@client = Kaltura::KalturaClient.new(@client_config)
|
|
13
|
+
@client.ks = @session_key
|
|
14
|
+
@client
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def setup_config
|
|
18
|
+
raise "Missing Partner Identifier" unless KalturaBox.config.partner_id
|
|
19
|
+
@client_config = Kaltura::KalturaConfiguration.new(KalturaBox.config.partner_id)
|
|
20
|
+
@client_config.service_url = KalturaBox.config.service_url
|
|
21
|
+
|
|
22
|
+
self.generate_session_key
|
|
23
|
+
|
|
24
|
+
@client_config
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def generate_session_key
|
|
28
|
+
self.update_session
|
|
29
|
+
|
|
30
|
+
raise "Missing Administrator Secret" unless KalturaBox.config.administrator_secret
|
|
31
|
+
begin
|
|
32
|
+
@session_key = @client.session_service.start(KalturaBox.config.administrator_secret, '', Kaltura::KalturaSessionType::ADMIN)
|
|
33
|
+
rescue Kaltura::KalturaAPIError => e
|
|
34
|
+
puts e.message
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def update_session
|
|
39
|
+
@client ? @client : self.create
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|