videos 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjIwOTliN2Q4YTdhYzNlOWQwMzY3YzZhZTUxM2Y2ZWU0ZmQyNTRhYQ==
4
+ M2UwMzM2OWI1ZDU0ODViNTMzOTJiMzIyYTlhNTQ3ZjM0YzQyNTk1Nw==
5
5
  data.tar.gz: !binary |-
6
- NzdmMjQxODJlMzZkYzg2YjM3YTdiMmM2NTBmNjJjYTM2MzQ1NTM4MA==
6
+ NmQ1OTE0YmI0MTJiYmZkMGE3N2YyMWM4NTJlMjJiNmEwNzJhMjExOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzIyNDhjOWNkYjY5NjE2MzdmYjBjYTQ5ODdkMDVhODNiZGE5NTI4NTliODcy
10
- ZGFmNGVkMGUwNjE2MTMxNGQ2MmQ1NTU4ODJmZDIzM2ZhNWUwNDAxZWI4NjQx
11
- ODQyZTJhNTNjNGFjZmIyNGZlMDYzYTIyMWI2NjJlOTYzZWI5MzE=
9
+ NjI2ZmE3NmNmNGVjZDQzMWE4Nzg5ZTFhN2RkYTI4ZWQ3YWViN2RiOTIzYjkz
10
+ NWU5YzJiMmI3ODA5NTYxYzhlNmFkZDY2ZGVkZjQ5MmFhZTE0ZGEzODI2NjMx
11
+ NTkyNDg4MzRiMTJlMWEzMWQ3NmI5NDcxYzEzZDczZDYwMjRjYWU=
12
12
  data.tar.gz: !binary |-
13
- YzA4MDE0ZWJkMmRlMjY0NzYwMzAyNzVjMmRmMGYwMDhjYzQ5ZjI5MDY1MzUy
14
- YmM0Y2Q2NTc0ZDEzOGM0YzZkZTFmZDA4ZDJjOTdkN2YyN2NkMjhkMjYyMDYy
15
- MDZhMTI4NWM2ZjFhZDI1MWQ3YTVhZjgzNDZiMzlhOTIxN2M4MjY=
13
+ ZDMyMGQzMjc3OGJiYTljMTY3Y2ZjMWI2YjM4ZjQ4ZjRiZjVkMTNmOGNkM2Ux
14
+ NzQ0ZWJiNjVlYWMzMzIxMDU0ZWJkYmM3NDFlNGY0OTZlOThlYjE1MjI1YTM0
15
+ NDg2OWJmMDJiNGM3MmM0MmIzNGFlMmIxM2ZlZGNhZTU3OGI4M2Q=
@@ -31,6 +31,7 @@
31
31
  #items li .info { padding: 2px; }
32
32
  #items li .info img { vertical-align: middle; }
33
33
  #items li .info .title { padding-bottom: 3px; }
34
+ #items li .info .labels { margin-bottom: 4px; }
34
35
  #items .tag_list { min-height: 1.2em; }
35
36
  #items .tag_list:hover { background-color: #ffffaa; }
36
37
  #items input { width: 100%; }
@@ -21,7 +21,7 @@ controllers.index = function(search, sort, sortDirection) {
21
21
  _.each(words, function(word) {
22
22
  regex = RegExp(word, "i");
23
23
  videos = _.filter(videos, function(video) {
24
- return video.title.match(regex);
24
+ return video.title.match(regex) || video.resolution.match(regex);
25
25
  });
26
26
  });
27
27
  }
@@ -84,7 +84,7 @@ controllers.index = function(search, sort, sortDirection) {
84
84
  return a.href;
85
85
  }
86
86
 
87
- function formatLength(length) {
87
+ function formatLengthNumeric(length) {
88
88
  var out = [];
89
89
  if(length >= 3600) {
90
90
  out.push(Math.floor(length / 3600) + "h");
@@ -100,6 +100,21 @@ controllers.index = function(search, sort, sortDirection) {
100
100
  return out.join(" ");
101
101
  }
102
102
 
103
+ function formatLength(length) {
104
+ return '<span class="label label-default" title="Video Length"><span class="glyphicon glyphicon-expand"></span> ' +
105
+ formatLengthNumeric(length) + '</span>';
106
+ }
107
+
108
+ function formatResolution(resolution) {
109
+ if(resolution == "1080p") {
110
+ return '<span class="label label-success" title="Video Width/Height"><span class="glyphicon ' +
111
+ 'glyphicon-hd-video"></span> 1080p</span>';
112
+ }
113
+ else {
114
+ return '<span class="label label-default" title="Video Width/Height">' + resolution + '</span>';
115
+ }
116
+ }
117
+
103
118
  function addVideos(videos) {
104
119
  $("#items").empty();
105
120
 
@@ -114,7 +129,8 @@ controllers.index = function(search, sort, sortDirection) {
114
129
  item.append(link);
115
130
 
116
131
  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>');
132
+ '<div class="labels">' + formatLength(video.length) + ' ' + formatResolution(video.resolution) +
133
+ '</div></div>');
118
134
 
119
135
  $("#items").append(item);
120
136
  });
data/lib/videos.rb CHANGED
@@ -10,6 +10,7 @@ require "shellwords"
10
10
  require "addressable/uri"
11
11
  require "naturally"
12
12
  require "RMagick"
13
+ require "nokogiri"
13
14
 
14
15
  #Core Extensions
15
16
  require "videos/core_ext/pathname"
@@ -8,7 +8,7 @@ class Pathname
8
8
  end
9
9
 
10
10
  def video?
11
- file? && extname && %w(.mp4 .mkv .flv .avi .m4v .mov .wmv).include?(extname.downcase)
11
+ file? && extname && %w(.mp4 .mkv .flv .avi .m4v .mov .wmv .mpg).include?(extname.downcase[0..3])
12
12
  end
13
13
 
14
14
  def hidden?
data/lib/videos/update.rb CHANGED
@@ -7,7 +7,7 @@ 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!"
@@ -1,3 +1,3 @@
1
1
  module Videos
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/videos/video.rb CHANGED
@@ -70,11 +70,13 @@ class Videos::Video
70
70
  end
71
71
 
72
72
  def get_metadata
73
- return unless length.nil?
73
+ return unless metadata.keys.empty?
74
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
75
+ output = `mediainfo -f --Output=XML #{path.to_s.shellescape}`
76
+ doc = Nokogiri::XML.parse(output)
77
+ @metadata["length"] = (e = doc.search("File Duration").first) ? e.text.to_i : 0
78
+ @metadata["width"] = (e = doc.search("File Width").first) ? e.text.to_i : 0
79
+ @metadata["height"] = (e = doc.search("File Height").first) ? e.text.to_i : 0
78
80
  end
79
81
 
80
82
  def self.from_hash(videos_package, data)
@@ -89,8 +91,23 @@ class Videos::Video
89
91
  "title" => title,
90
92
  "publishedOn" => path.mtime.to_i,
91
93
  "thumbnailUrl" => thumbnail_url,
92
- "length" => length,
94
+ "length" => (metadata["length"] / 1000.0).round,
95
+ "width" => metadata["width"],
96
+ "height" => metadata["height"],
97
+ "resolution" => approx_resolution,
93
98
  "key" => path_hash
94
99
  }
95
100
  end
101
+
102
+ private
103
+ def approx_resolution
104
+ if metadata["width"] == 1920 && metadata["height"] == 1080
105
+ "1080p"
106
+ elsif
107
+ metadata["width"] == 1280 && metadata["height"] == 720
108
+ "720p"
109
+ else
110
+ "#{metadata["width"]}x#{metadata["height"]}"
111
+ end
112
+ end
96
113
  end
data/lib/videos/videos.rb CHANGED
@@ -3,7 +3,8 @@ class Videos::Videos
3
3
  attr_reader :videos_path
4
4
 
5
5
  def pathname_to_url(path, relative_from)
6
- URI.escape(path.relative_path_from(relative_from).to_s)
6
+ url = path.relative_path_from(relative_from)
7
+ (url.dirname + URI.escape(url.basename.to_s, URI::REGEXP::PATTERN::RESERVED).force_encoding("utf-8")).to_s
7
8
  end
8
9
 
9
10
  def url_to_pathname(url)
data/videos.gemspec CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency "addressable", ">= 2.3.5"
19
19
  s.add_dependency "naturally", ">= 1.0.3"
20
20
  s.add_dependency "rmagick", ">= 2.13.1"
21
+ s.add_dependency "nokogiri", ">= 0"
21
22
 
22
23
  s.files = `git ls-files`.split("\n")
23
24
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
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.2
4
+ version: 0.0.3
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-13 00:00:00.000000000 Z
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.13.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: A collection of videos is a directory (the container) containing both
70
84
  video files and directories that have video files in them. Videos indexes a collection
71
85
  in this format, and generates a HTML/JS Single Page Application (SPA) that allows