videos 0.0.1 → 0.0.2

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWFhNzZiYjE1OWQ5Mjc3Yzk3NWQ3ZWUwNTMzYTUzNWI3YzM2NDY2NQ==
4
+ MjIwOTliN2Q4YTdhYzNlOWQwMzY3YzZhZTUxM2Y2ZWU0ZmQyNTRhYQ==
5
5
  data.tar.gz: !binary |-
6
- MmE3Mzc2MDM4YWRmN2M2MTFmOWI5NjdkNDU3ZWE2NDE0MjJjZDA5Nw==
6
+ NzdmMjQxODJlMzZkYzg2YjM3YTdiMmM2NTBmNjJjYTM2MzQ1NTM4MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjQ5ZDYzMDEyMzk4YTEwMTk2OGU1YTMyYjc1MjVmODczMTNiOGI4N2VhZmYy
10
- MjUwMDEzNjQ3MmQ4NTkwMjAwOTc5OTMwNWQxOGMxODhiOWE3NGNhZmFmMzIz
11
- Y2Q2Yzg3MzQ0NjY1YjVmY2EzMWJlNzJmYWVmMWRiOGU1ZWM0Mjg=
9
+ YzIyNDhjOWNkYjY5NjE2MzdmYjBjYTQ5ODdkMDVhODNiZGE5NTI4NTliODcy
10
+ ZGFmNGVkMGUwNjE2MTMxNGQ2MmQ1NTU4ODJmZDIzM2ZhNWUwNDAxZWI4NjQx
11
+ ODQyZTJhNTNjNGFjZmIyNGZlMDYzYTIyMWI2NjJlOTYzZWI5MzE=
12
12
  data.tar.gz: !binary |-
13
- MTA3ZThkZGIwOTE0ZWMyYTIyYTRmNWM0NDY1MGZjMDY0NGU3ZmU5ODQxNzkw
14
- NDUxMzZmZmYxZWM3MTM2ZGFjNWNmOGNkNDRhMDU0MzQzODhjMjNjZDI5NTZh
15
- MmZkM2Y3YWM0MzgwYTgzYThmNWMyYzczNTFiZmU3MmEyZWY4ZTY=
13
+ YzA4MDE0ZWJkMmRlMjY0NzYwMzAyNzVjMmRmMGYwMDhjYzQ5ZjI5MDY1MzUy
14
+ YmM0Y2Q2NTc0ZDEzOGM0YzZkZTFmZDA4ZDJjOTdkN2YyN2NkMjhkMjYyMDYy
15
+ MDZhMTI4NWM2ZjFhZDI1MWQ3YTVhZjgzNDZiMzlhOTIxN2M4MjY=
@@ -7,7 +7,7 @@
7
7
  #actions { float: right; }
8
8
 
9
9
  #header > form {
10
- width: 684px;
10
+ width: 691px;
11
11
  margin-left: auto;
12
12
  margin-right: auto;
13
13
  }
@@ -27,7 +27,7 @@
27
27
  <input type="text" id="search" class="form-control">
28
28
  <span class="btn-group sort">
29
29
  <button class="btn btn-default" data-sort="publishedOn" type="button">Published On</button>
30
- <button class="btn btn-default" data-sort="pages" type="button">Pages</button>
30
+ <button class="btn btn-default" data-sort="length" type="button">Length</button>
31
31
  <button class="btn btn-default" data-sort="title" type="button">Title</button>
32
32
  </span>
33
33
  <span class="btn-group sort-direction">
@@ -7,9 +7,9 @@ controllers.index = function(search, sort, sortDirection) {
7
7
  if(type == "publishedOn") return function(video) {
8
8
  return video.publishedOn;
9
9
  };
10
- /* if(type == "pages") return function(video) {
11
- return video.pageUrls.length;
12
- };*/
10
+ if(type == "length") return function(video) {
11
+ return video.length;
12
+ };
13
13
  if(type == "title") return function(video) {
14
14
  return video.title.toLowerCase();
15
15
  };
@@ -84,6 +84,22 @@ controllers.index = function(search, sort, sortDirection) {
84
84
  return a.href;
85
85
  }
86
86
 
87
+ function formatLength(length) {
88
+ var out = [];
89
+ if(length >= 3600) {
90
+ out.push(Math.floor(length / 3600) + "h");
91
+ length = length % 3600;
92
+ }
93
+ if(length >= 60) {
94
+ out.push(Math.floor(length / 60) + "m");
95
+ length = length % 60;
96
+ }
97
+ if(length >= 1) {
98
+ out.push(Math.floor(length) + "s");
99
+ }
100
+ return out.join(" ");
101
+ }
102
+
87
103
  function addVideos(videos) {
88
104
  $("#items").empty();
89
105
 
@@ -97,7 +113,8 @@ controllers.index = function(search, sort, sortDirection) {
97
113
  link.append(img);
98
114
  item.append(link);
99
115
 
100
- item.append('<div class="info-wrapper"><div class="info"><div class="title">' + video.title + '</div></div>');
116
+ item.append('<div class="info-wrapper"><div class="info"><div class="title">' + video.title + '</div>' +
117
+ '<img src="img/icons/film.png" title="Video Length"> ' + formatLength(video.length) + '</div>');
101
118
 
102
119
  $("#items").append(item);
103
120
  });
@@ -7,14 +7,14 @@ class Videos::Update
7
7
 
8
8
  @files = videos_package.root_path.descendant_files.reject { |p| p.basename.to_s[0..0] == '.' }
9
9
  @videos = []
10
- #load_data
10
+ load_data
11
11
  process
12
12
  save_data
13
13
  puts "\nDone!"
14
14
  end
15
15
 
16
16
  def load_data
17
- self.videos = (Videos::Videos.load_json(video_package.videos_path + "data.json") || []).map { |b| Videos::Video.from_hash(video_package, b) }
17
+ self.videos = (Videos::Videos.load_json(videos_package.videos_path + "data.json") || []).map { |b| Videos::Video.from_hash(videos_package, b) }
18
18
  end
19
19
 
20
20
  def save_data
@@ -35,7 +35,13 @@ class Videos::Update
35
35
  $stdout.write "\rProcessing #{i + 1} of #{@files.length} (#{(((i + 1) / @files.length.to_f) * 100.0).round}%)"
36
36
  $stdout.flush
37
37
 
38
- created f
38
+ #video = videos.find { |v| v.path.to_s == f.to_s }
39
+
40
+ #if video
41
+ # updated video
42
+ #else
43
+ created f
44
+ #end
39
45
  end
40
46
  #handle deleted first
41
47
  #@directories.each do |d|
@@ -56,11 +62,12 @@ class Videos::Update
56
62
  def created(f)
57
63
  video = Videos::Video.new(videos_package, f)
58
64
  video.generate_thumbnail
65
+ video.get_metadata
59
66
  videos << video
60
67
  end
61
68
 
62
69
  def updated(video)
63
- puts "updating: #{video.inspect}"
64
- #
70
+ video.generate_thumbnail
71
+ video.get_metadata
65
72
  end
66
73
  end
@@ -1,3 +1,3 @@
1
1
  module Videos
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,10 +1,13 @@
1
1
  class Videos::Video
2
2
  attr_reader :videos_package
3
3
  attr_reader :path
4
+ attr_reader :metadata
5
+ attr_accessor :length
4
6
 
5
7
  def initialize(videos_package, path)
6
8
  @videos_package = videos_package
7
9
  @path = path
10
+ @metadata = {}
8
11
  end
9
12
 
10
13
  def path_hash
@@ -66,9 +69,17 @@ class Videos::Video
66
69
  FileUtils.rm_rf(temp_directory) if temp_directory
67
70
  end
68
71
 
72
+ def get_metadata
73
+ return unless length.nil?
74
+
75
+ output = `mpv --really-quiet -identify --frames=0 --ao=null #{path.to_s.shellescape}`.encode("ASCII-8BIT", undef: :replace, invalid: :replace, replace: "?")
76
+ @metadata = Hash[output.split("\n").map { |l| l.gsub(/^\[identify\] /, "").split("=", 2) }]
77
+ @length = metadata["ID_LENGTH"].to_f
78
+ end
79
+
69
80
  def self.from_hash(videos_package, data)
70
- video = Videos::Video.new(videos_package)
71
- video.path = videos_package.url_to_pathname(Addressable::URI.parse(data["url"]))
81
+ video = Videos::Video.new(videos_package, videos_package.url_to_pathname(Addressable::URI.parse(data["url"])))
82
+ video.length = data["length"]
72
83
  video
73
84
  end
74
85
 
@@ -78,6 +89,7 @@ class Videos::Video
78
89
  "title" => title,
79
90
  "publishedOn" => path.mtime.to_i,
80
91
  "thumbnailUrl" => thumbnail_url,
92
+ "length" => length,
81
93
  "key" => path_hash
82
94
  }
83
95
  end
@@ -9,7 +9,7 @@ class Videos::Videos
9
9
  def url_to_pathname(url)
10
10
  path = Addressable::URI.unencode_component(url.normalized_path)
11
11
  path.gsub!(/^\//, "") #Make relative, if we allow mounting at a different root URL this will need to remove the root instead of just '/'
12
- root_url_path + path
12
+ root_path + path
13
13
  end
14
14
 
15
15
  def self.gem_path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: videos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brenton "B-Train" Fletcher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-07 00:00:00.000000000 Z
11
+ date: 2014-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler