kaltura_fu 0.1.0.prel
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.
- data/.gitignore +2 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +66 -0
- data/Rakefile +57 -0
- data/VERSION.yml +5 -0
- data/config/kaltura.yml +22 -0
- data/install.rb +1 -0
- data/javascripts/kaltura_upload.js +67 -0
- data/kaltura_fu.gemspec +65 -0
- data/lib/kaltura_fu/category.rb +112 -0
- data/lib/kaltura_fu/report.rb +147 -0
- data/lib/kaltura_fu/video.rb +190 -0
- data/lib/kaltura_fu/view_helpers.rb +182 -0
- data/lib/kaltura_fu.rb +112 -0
- data/rails/init.rb +22 -0
- data/spec/kaltura_fu_spec.rb +166 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/kaltura_fu_tasks.rake +45 -0
- data/test/kaltura_fu_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- data/uninstall.rb +1 -0
- metadata +108 -0
data/.gitignore
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
kaltura_fu
|
2
|
+
--------------
|
3
|
+
**Homepage**: [http://www.velir.com](http://www.velir.com)
|
4
|
+
**Author**: [Patrick Robertson](mailto:patrick.robertson@velir.com)
|
5
|
+
**Copyright**: 2010
|
6
|
+
**License**: [MIT License](file:MIT-LICENSE)
|
7
|
+
|
8
|
+
About Kaltura
|
9
|
+
----------------
|
10
|
+
[Kaltura](http://kaltura.org/) is an open source video streaming service.
|
11
|
+
|
12
|
+
About kaltura_fu
|
13
|
+
------------------
|
14
|
+
|
15
|
+
kaltura_fu is a rails plugin that extends the basic functionality of the Kaltura ruby client and adds in some Rails view helpers to generate video players, thumbnails, and the uploader.
|
16
|
+
|
17
|
+
Installation:
|
18
|
+
-------------
|
19
|
+
Install the plugin with the command
|
20
|
+
script/plugin install git@github.com:patricksrobertson/kaltura_fu.git
|
21
|
+
Run
|
22
|
+
rake kaltura_fu:install:all
|
23
|
+
This will install the config/kaltura.yml file into your application's root directory and the kaltura_upload.js into the application's public/javascripts directory. You may choose to run these commands instead:
|
24
|
+
rake kaltura_fu:install:config
|
25
|
+
rake kaltura_fu:install:js
|
26
|
+
|
27
|
+
|
28
|
+
Usage:
|
29
|
+
------
|
30
|
+
Kaltura_fu provides four ActionView helper methods presently:
|
31
|
+
|
32
|
+
* include_kaltura_fu
|
33
|
+
* kaltura_thumbnail(entry_id, options={})
|
34
|
+
* kaltura_player_embed(entry_id,options={})
|
35
|
+
* kaltura_upload_embed(options={})
|
36
|
+
|
37
|
+
include_kaltura_fu embeds the kaltura_upload.js into the header.
|
38
|
+
|
39
|
+
kaltura_thumbnail(entry_id, options={}) has the following parameters:
|
40
|
+
|
41
|
+
* entry_id - The Kaltura entry_id of which you want to display a thumbnail
|
42
|
+
* hash of options. The supported options are:
|
43
|
+
|
44
|
+
* :size=> Array of integers. [width,height]. This can be defaulted in the config with thumb_width and thumb_height.
|
45
|
+
* :second=> Integer. Specify the second of the video to create the thumbnail with.
|
46
|
+
|
47
|
+
kaltura_player_embed(entry_id,options={}) has the following parameters:
|
48
|
+
|
49
|
+
* entry_id - The Kaltura entry_id that you want to display in the player.
|
50
|
+
* hash of options. The supported options are:
|
51
|
+
|
52
|
+
* :div_id=> String. Specifies the div ID of the object that will be embeded. Defaults to kplayer.
|
53
|
+
* :player_conf_id=> String. The configuration ID of the player to use. This can be defaulted in the config with player_conf_id.
|
54
|
+
|
55
|
+
kaltura_upload_embed(options={}) has the following parameters:
|
56
|
+
|
57
|
+
* hash of options: The supported options are:
|
58
|
+
|
59
|
+
* none at this time.
|
60
|
+
|
61
|
+
|
62
|
+
To Do's
|
63
|
+
-------
|
64
|
+
* Buff the options for the upload script a bit more.
|
65
|
+
|
66
|
+
Copyright (c) 2010 [Patrick Robertson](http://www.velir.com), released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "kaltura_fu"
|
9
|
+
gem.summary = "Rails gem for making Kaltura integrations easier."
|
10
|
+
gem.email = "patrick.robertson@velir.com"
|
11
|
+
gem.homepage = "http://github.com/Velir/kaltura_fu"
|
12
|
+
gem.authors = ["Patrick Robertson"]
|
13
|
+
gem.add_dependency('velir_kaltura-ruby', '>=0.4.3')
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/*_test.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/*_test.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
if File.exist?('VERSION.yml')
|
47
|
+
config = YAML.load(File.read('VERSION.yml'))
|
48
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
49
|
+
else
|
50
|
+
version = ""
|
51
|
+
end
|
52
|
+
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
54
|
+
rdoc.title = "kaltura-ruby #{version}"
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
end
|
data/VERSION.yml
ADDED
data/config/kaltura.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# config/kaltura.yml
|
2
|
+
base: &base
|
3
|
+
login_email: 'USER_EMAIL'
|
4
|
+
login_password: 'THE_PASSWORD'
|
5
|
+
partner_id: 'PARTNER_ID'
|
6
|
+
subpartner_id: 'PARTNER_ID * 100'
|
7
|
+
administrator_secret: 'ADMINISTRATOR_SECRET'
|
8
|
+
user_secret: 'USER_SECRET'
|
9
|
+
thumb_width: '300'
|
10
|
+
thumb_height: '300'
|
11
|
+
player_conf_id: 'whatever'
|
12
|
+
service_url: 'http://www.kaltura.com'
|
13
|
+
|
14
|
+
development:
|
15
|
+
<<: *base
|
16
|
+
|
17
|
+
test:
|
18
|
+
<<: *base
|
19
|
+
|
20
|
+
|
21
|
+
production:
|
22
|
+
<<: *base
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -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/kaltura_fu.gemspec
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{kaltura_fu}
|
8
|
+
s.version = "0.1.0.prel"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Patrick Robertson"]
|
12
|
+
s.date = %q{2010-10-07}
|
13
|
+
s.email = %q{patrick.robertson@velir.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README.markdown"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
".gitignore",
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README.markdown",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION.yml",
|
23
|
+
"config/kaltura.yml",
|
24
|
+
"install.rb",
|
25
|
+
"javascripts/kaltura_upload.js",
|
26
|
+
"kaltura_fu.gemspec",
|
27
|
+
"lib/kaltura_fu.rb",
|
28
|
+
"lib/kaltura_fu/category.rb",
|
29
|
+
"lib/kaltura_fu/report.rb",
|
30
|
+
"lib/kaltura_fu/video.rb",
|
31
|
+
"lib/kaltura_fu/view_helpers.rb",
|
32
|
+
"rails/init.rb",
|
33
|
+
"spec/kaltura_fu_spec.rb",
|
34
|
+
"spec/spec_helper.rb",
|
35
|
+
"tasks/kaltura_fu_tasks.rake",
|
36
|
+
"test/kaltura_fu_test.rb",
|
37
|
+
"test/test_helper.rb",
|
38
|
+
"uninstall.rb"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/Velir/kaltura_fu}
|
41
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = %q{1.3.7}
|
44
|
+
s.summary = %q{Rails gem for making Kaltura integrations easier.}
|
45
|
+
s.test_files = [
|
46
|
+
"spec/kaltura_fu_spec.rb",
|
47
|
+
"spec/spec_helper.rb",
|
48
|
+
"test/kaltura_fu_test.rb",
|
49
|
+
"test/test_helper.rb"
|
50
|
+
]
|
51
|
+
|
52
|
+
if s.respond_to? :specification_version then
|
53
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
|
+
s.specification_version = 3
|
55
|
+
|
56
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
57
|
+
s.add_runtime_dependency(%q<velir_kaltura-ruby>, [">= 0.4.3"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<velir_kaltura-ruby>, [">= 0.4.3"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<velir_kaltura-ruby>, [">= 0.4.3"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module KalturaFu
|
2
|
+
|
3
|
+
##
|
4
|
+
# The Category module provides class methods to add/append category metadata to Kaltura entries.
|
5
|
+
#
|
6
|
+
# @author Patrick Robertson
|
7
|
+
#
|
8
|
+
# @example Create a new Category Filter on the Kaltura Management Console:
|
9
|
+
# create_category('waffles')
|
10
|
+
#
|
11
|
+
# @example Append a Category to the end of the Entries metadata list:
|
12
|
+
# add_category_to_video('1_xw34a324','pancakes')
|
13
|
+
#
|
14
|
+
# @example Append a Category and make sure it is a KMC filter if it doesn't exist:
|
15
|
+
# add_category_to_video('1_wx34a324','pancakes',true)
|
16
|
+
#
|
17
|
+
# @example Set the Category metadata to a specific category and overriding the existing values:
|
18
|
+
# set_category('1_wx34a324','Ninja Pancake Assasin')
|
19
|
+
##
|
20
|
+
module Category
|
21
|
+
include KalturaFu::Video
|
22
|
+
##
|
23
|
+
# Appends a category to the Kaltura entry. It is capable of adding the category to the Kaltura server
|
24
|
+
# if it doesn't already exist. This method will not override existing categories, instead it appends the new
|
25
|
+
# category to the end of the list.
|
26
|
+
#
|
27
|
+
# @param [String] video_id Kaltura entry_id of the video.
|
28
|
+
# @param [String] category The category to add to the Kaltura entry.
|
29
|
+
# @param [Boolean] force_add true/false flag to force adding the category to the Kaltura server if it doesn't already
|
30
|
+
# exist. Defaults to false.
|
31
|
+
#
|
32
|
+
# @return [Kaltura::MediaEntry] Returns the entry updated with the new category appended.
|
33
|
+
##
|
34
|
+
def add_category_to_video(video_id,category,force_add=false)
|
35
|
+
KalturaFu.check_for_client_session
|
36
|
+
|
37
|
+
existing_category = category_exists?(category)
|
38
|
+
if force_add && !existing_category
|
39
|
+
self.create_category(category)
|
40
|
+
elsif !force_add && !existing_category
|
41
|
+
raise "Category: #{category} does not exist. Either use the force add flag or manually add the category."
|
42
|
+
end
|
43
|
+
|
44
|
+
video = get_video_info(video_id)
|
45
|
+
updated_entry = Kaltura::MediaEntry.new
|
46
|
+
if video.categories.nil?
|
47
|
+
updated_categories = category
|
48
|
+
else
|
49
|
+
updated_categories = video.categories + "," + category
|
50
|
+
end
|
51
|
+
updated_entry.categories = updated_categories
|
52
|
+
KalturaFu.client.media_service.update(video_id,updated_entry)
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Creates a category on the Kaltura server if it doesn't already exist.
|
57
|
+
#
|
58
|
+
# @param [String] category_name category you wish to add.
|
59
|
+
##
|
60
|
+
def create_category(category_name)
|
61
|
+
KalturaFu.check_for_client_session
|
62
|
+
|
63
|
+
existing_category = self.category_exists?(category_name)
|
64
|
+
unless existing_category
|
65
|
+
category = Kaltura::Category.new
|
66
|
+
category.name = category_name
|
67
|
+
KalturaFu.client.category_service.add(category)
|
68
|
+
else
|
69
|
+
existing_category
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# Sets the Kaltura entry metadata to the desired category. It will overwrite existing categories.
|
75
|
+
#
|
76
|
+
# @param [String] video_id Kaltura entry_id of the video.
|
77
|
+
# @param [String] category The category to add to the Kaltura entry.
|
78
|
+
#
|
79
|
+
# @return [Boolean] Returns true if the entry was updated, otherwise false.
|
80
|
+
##
|
81
|
+
def set_category(video_id,category)
|
82
|
+
KalturaFu.check_for_client_session
|
83
|
+
|
84
|
+
if video_exists?(video_id)
|
85
|
+
updated_entry = Kaltura::MediaEntry.new
|
86
|
+
updated_entry.categories = category
|
87
|
+
KalturaFu.client.media_service.update(video_id,updated_entry)
|
88
|
+
true
|
89
|
+
else
|
90
|
+
false
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
protected
|
95
|
+
|
96
|
+
##
|
97
|
+
# @private
|
98
|
+
##
|
99
|
+
def category_exists?(category_name)
|
100
|
+
KalturaFu.check_for_client_session
|
101
|
+
|
102
|
+
category_filter = Kaltura::Filter::CategoryFilter.new
|
103
|
+
category_filter.full_name_equal = category_name
|
104
|
+
category_check = KalturaFu.client.category_service.list(category_filter).objects
|
105
|
+
if category_check.nil?
|
106
|
+
false
|
107
|
+
else
|
108
|
+
category_check
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
module KalturaFu
|
2
|
+
|
3
|
+
##
|
4
|
+
# The Report module provides class methods to retrieve analytic information and reports from Kaltura entries.
|
5
|
+
#
|
6
|
+
# @author Patrick Robertson
|
7
|
+
##
|
8
|
+
module Report
|
9
|
+
|
10
|
+
##
|
11
|
+
# Returns an Array of hashes that contains a Kaltura content drop-off report ordered by # of plays descending.
|
12
|
+
# Kaltura treats # of plays as a string, so 5 comes before 353.
|
13
|
+
#
|
14
|
+
# @param [Date] from_date The starting date for the report. The end date is currently always today.
|
15
|
+
# @param [String] video_list a comma delimited list of Kaltura entry_id's to report upon.
|
16
|
+
#
|
17
|
+
# @return [Array] An array of Hashes that contains the entry_id, total plays, and then plays for 25%, 50%, 75% and 100% through the content.
|
18
|
+
##
|
19
|
+
def generate_report(from_date,video_list)
|
20
|
+
hash_array = []
|
21
|
+
|
22
|
+
KalturaFu.check_for_client_session
|
23
|
+
|
24
|
+
report_filter = Kaltura::Filter::ReportInputFilter.new
|
25
|
+
report_filter.from_date = from_date.to_i
|
26
|
+
report_filter.to_date = Time.now.utc.to_i
|
27
|
+
report_pager = Kaltura::FilterPager.new
|
28
|
+
report_pager.page_size = 1000
|
29
|
+
|
30
|
+
report_raw = KalturaFu.client.report_service.get_table(Kaltura::Constants::ReportType::CONTENT_DROPOFF,
|
31
|
+
report_filter,
|
32
|
+
report_pager,
|
33
|
+
Kaltura::Constants::Media::OrderBy::PLAYS_DESC,
|
34
|
+
video_list)
|
35
|
+
unless report_raw.data.nil?
|
36
|
+
report_split_by_entry = report_raw.data.split(";")
|
37
|
+
report_split_by_entry.each do |row|
|
38
|
+
segment = row.split(",")
|
39
|
+
row_hash = {}
|
40
|
+
row_hash[:entry_id] = segment.at(0)
|
41
|
+
row_hash[:plays] = segment.at(2)
|
42
|
+
row_hash[:play_through_25] = segment.at(3)
|
43
|
+
row_hash[:play_through_50] = segment.at(4)
|
44
|
+
row_hash[:play_through_75] = segment.at(5)
|
45
|
+
row_hash[:play_through_100] = segment.at(6)
|
46
|
+
hash_array << row_hash
|
47
|
+
end
|
48
|
+
|
49
|
+
hash_array = hash_array.sort{|a,b| b[:plays].to_i <=> a[:plays].to_i}
|
50
|
+
end
|
51
|
+
hash_array
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# creates a report CSV on the kaltura server and then returns the url to grab it. Unfortunately the MIME type of the resource is "text/plain"
|
56
|
+
# instead of "text/csv" so there isn't a ton you can do with it.
|
57
|
+
#
|
58
|
+
# @param [Date] from_date The starting date for the report. The end date is currently always today.
|
59
|
+
# @param [String] video_list a comma delimited list of Kaltura entry_id's to report upon.
|
60
|
+
#
|
61
|
+
# @return [String] URL to grab the report in CSV format.
|
62
|
+
##
|
63
|
+
def generate_report_csv_url(from_date,video_list)
|
64
|
+
report_title = "TTV Video Report"
|
65
|
+
report_text = "I'm not sure what this is"
|
66
|
+
headers = "Kaltura Entry,Plays,25% Play-through,50% Play-through, 75% Play-through, 100% Play-through, Play-Through Ratio"
|
67
|
+
|
68
|
+
KalturaFu.check_for_client_session
|
69
|
+
|
70
|
+
report_filter = Kaltura::Filter::ReportInputFilter.new
|
71
|
+
report_filter.from_date = from_date.to_i
|
72
|
+
report_filter.to_date = Time.now.utc.to_i
|
73
|
+
report_pager = Kaltura::FilterPager.new
|
74
|
+
report_pager.page_size = 1000
|
75
|
+
|
76
|
+
report_url = KalturaFu.client.report_service.get_url_for_report_as_csv(report_title,
|
77
|
+
report_text,
|
78
|
+
headers,
|
79
|
+
Kaltura::Constants::ReportType::CONTENT_DROPOFF,
|
80
|
+
report_filter,
|
81
|
+
"",
|
82
|
+
report_pager,
|
83
|
+
Kaltura::Constants::Media::OrderBy::PLAYS_DESC,
|
84
|
+
video_list)
|
85
|
+
report_url
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Returns a grand total of the plays broken down by content drop-off given a list of Kaltura entries.
|
90
|
+
#
|
91
|
+
# @param [Date] from_date The starting date for the report. The end date is currently always today.
|
92
|
+
# @param [String] video_list a comma delimited list of Kaltura entry_id's to report upon.
|
93
|
+
#
|
94
|
+
# @return [Hash] a list that contains total plays and plays broken down to 25%, 50%, 75%, and 100% through content.
|
95
|
+
##
|
96
|
+
def generate_report_total(from_date,video_list)
|
97
|
+
row_hash = {}
|
98
|
+
|
99
|
+
KalturaFu.check_for_client_session
|
100
|
+
|
101
|
+
report_filter = Kaltura::Filter::ReportInputFilter.new
|
102
|
+
report_filter.from_date = from_date.to_i
|
103
|
+
report_filter.to_date = Time.now.utc.to_i
|
104
|
+
report_raw = KalturaFu.client.report_service.get_total(Kaltura::Constants::ReportType::CONTENT_DROPOFF,
|
105
|
+
report_filter,
|
106
|
+
video_list)
|
107
|
+
unless report_raw.data.nil?
|
108
|
+
segment = report_raw.data.split(",")
|
109
|
+
row_hash[:plays] = segment.at(0)
|
110
|
+
row_hash[:play_through_25] = segment.at(1)
|
111
|
+
row_hash[:play_through_50] = segment.at(2)
|
112
|
+
row_hash[:play_through_75] = segment.at(3)
|
113
|
+
row_hash[:play_through_100] = segment.at(4)
|
114
|
+
|
115
|
+
row_hash
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
##
|
120
|
+
# Returns the total number of Kaltura entries that had any plays during the reporting period.
|
121
|
+
#
|
122
|
+
# @param [Date] from_date The starting date for the report. The end date is currently always today.
|
123
|
+
# @param [String] video_list a comma delimited list of Kaltura entry_id's to report upon.
|
124
|
+
##
|
125
|
+
def generate_report_video_count(from_date,video_list)
|
126
|
+
row_hash = {}
|
127
|
+
|
128
|
+
KalturaFu.check_for_client_session
|
129
|
+
|
130
|
+
report_filter = Kaltura::Filter::ReportInputFilter.new
|
131
|
+
report_filter.from_date = from_date.to_i
|
132
|
+
report_filter.to_date = Time.now.utc.to_i
|
133
|
+
report_pager = Kaltura::FilterPager.new
|
134
|
+
report_pager.page_size = 1000
|
135
|
+
|
136
|
+
report_raw = KalturaFu.client.report_service.get_table(Kaltura::Constants::ReportType::CONTENT_DROPOFF,
|
137
|
+
report_filter,
|
138
|
+
report_pager,
|
139
|
+
Kaltura::Constants::Media::OrderBy::PLAYS_DESC,
|
140
|
+
video_list)
|
141
|
+
unless report_raw.data.nil?
|
142
|
+
report_raw.total_count
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|