pig-media-server 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pig-media-server/aspect.rb +30 -0
- data/lib/pig-media-server/cli.rb +3 -0
- data/lib/pig-media-server/crawl.rb +1 -0
- data/lib/pig-media-server/kindle_send.rb +1 -1
- data/lib/pig-media-server/model/pig.rb +9 -3
- data/lib/pig-media-server/version.rb +1 -1
- data/lib/pig-media-server/views/feed.builder +19 -0
- data/lib/pig-media-server/views/index.haml +13 -0
- data/lib/pig-media-server/views/meta.coffee +12 -0
- data/lib/pig-media-server/views/meta.haml +4 -1
- data/lib/pig-media-server/views/movie.coffee +1 -0
- data/lib/pig-media-server/views/sub.haml +3 -0
- data/lib/pig-media-server/views/unread.coffee +12 -0
- data/lib/pig-media-server/web.rb +25 -1
- data/pig-media-server.gemspec +1 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d3838bed9086874fdab98b37ac20f6aa302c7a1
|
4
|
+
data.tar.gz: b00909265c215b3040587aa577f86df9378bc683
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9386c31cd75a9fa0f27d2a9364a61778348430506d41042c01530bf72fa7400bdbb77f47ebb462cff07b17aed368770f0f92daf62586545f99c44fee1e39c7a
|
7
|
+
data.tar.gz: 03079c1d8b2c179b37d6c8e9b1538fa971c553b34ea0c258c86efae16a29361adbb62ae08970426f95b3d78e29be10a9d1637fdb366280ebc4d06b15e6a55dd9
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'pig-media-server'
|
2
|
+
require 'pig-media-server/model/pig'
|
3
|
+
|
4
|
+
module PigMediaServer
|
5
|
+
class Aspect
|
6
|
+
def run
|
7
|
+
pit_config = Pit.get 'Pig Media Server'
|
8
|
+
while true
|
9
|
+
GC.start
|
10
|
+
begin
|
11
|
+
q = open("#{pit_config['user_data_path']}/rate/queue.txt").read.split("\n")
|
12
|
+
q.each do |x|
|
13
|
+
next if x == ''
|
14
|
+
key = x.split(' ').first
|
15
|
+
rate = x.split(' ').last
|
16
|
+
pig = Pig.find key
|
17
|
+
if rate == '16:9'
|
18
|
+
system 'MP4Box', '-add', "#{pig.record.path}:par=1:1", '-new', "#{pig.record.path}.MP4"
|
19
|
+
FileUtils.mv "#{pig.record.path}.MP4", pig.record.path
|
20
|
+
end
|
21
|
+
end
|
22
|
+
open("#{pit_config['user_data_path']}/rate/queue.txt", 'w'){|x| x.puts ''}
|
23
|
+
rescue => e
|
24
|
+
p e
|
25
|
+
end
|
26
|
+
sleep 5
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/pig-media-server/cli.rb
CHANGED
@@ -18,6 +18,9 @@ when 'server'
|
|
18
18
|
port = ARGV[1] ? ARGV[1].to_i : 8080
|
19
19
|
require 'pig-media-server/web'
|
20
20
|
PigMediaServer::Web.run! host: '0.0.0.0', port: port
|
21
|
+
when 'aspect'
|
22
|
+
require 'pig-media-server/aspect'
|
23
|
+
PigMediaServer::Aspect.new.run
|
21
24
|
when 'kindle-send'
|
22
25
|
require 'pig-media-server/kindle_send'
|
23
26
|
PigMediaServer::KindleSend.new.run
|
@@ -12,6 +12,7 @@ module PigMediaServer
|
|
12
12
|
array = Dir.glob("#{$config['path']}/**/*").sort
|
13
13
|
end
|
14
14
|
array.each_with_index{|x,i|
|
15
|
+
next unless File.exist?(x)
|
15
16
|
next if File::ftype(x) == 'directory'
|
16
17
|
flag = false
|
17
18
|
$config['exclude_path'].each{|e| flag = true if x =~ /#{e.sub(/\//, '\/')}/ } if $config['exclude_path'].class.to_s == 'Array'
|
@@ -6,10 +6,10 @@ require 'pig-media-server/model/pig'
|
|
6
6
|
module PigMediaServer
|
7
7
|
class KindleSend
|
8
8
|
def run
|
9
|
+
pit_config = Pit.get 'Pig Media Server'
|
9
10
|
while true
|
10
11
|
begin
|
11
12
|
GC.start
|
12
|
-
pit_config = Pit.get 'Pig Media Server'
|
13
13
|
from_hash = Hash[*Dir.glob("#{pit_config['user_data_path']}/*.json").map{|t| JSON.parse open(t).read}.select{|t| t['kindle_to'] and t['kindle_from']}.map{|t| [t['kindle_to'], t['kindle_from']]}.select{|t| t.first != '' and t.last != ''}.flatten]
|
14
14
|
Dir.glob("#{pit_config['user_data_path']}/kindle/queue/*").each{|x|
|
15
15
|
begin
|
@@ -2,6 +2,8 @@
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'pig-media-server/model/migrate'
|
4
4
|
|
5
|
+
CONFIG = Pit.get('Pig Media Server')
|
6
|
+
|
5
7
|
class Pig
|
6
8
|
attr_accessor :record, :config
|
7
9
|
def initialize record
|
@@ -9,7 +11,7 @@ class Pig
|
|
9
11
|
record.size = File::Stat.new(record.path).size.to_s rescue nil
|
10
12
|
end
|
11
13
|
self.record = record
|
12
|
-
self.config =
|
14
|
+
self.config = CONFIG
|
13
15
|
end
|
14
16
|
def key; self.record._key;end
|
15
17
|
def name; self.record.path.split('/').last; end
|
@@ -17,7 +19,7 @@ class Pig
|
|
17
19
|
def size; self.record.size;end
|
18
20
|
def metadata; self.record.metadata;end
|
19
21
|
def srt; self.record.srt;end
|
20
|
-
def url; '/volume' + URI.encode(self.record.path.sub(/#{config['path'].sub(/\//, '\/')}/, ''));end
|
22
|
+
def url; 'http://'+self.config['hostname']+ '/volume' + URI.encode(self.record.path.sub(/#{config['path'].sub(/\//, '\/')}/, ''));end
|
21
23
|
def type
|
22
24
|
case self.name.split('.').last
|
23
25
|
when 'mp4', 'MP4', 'webm'
|
@@ -50,13 +52,17 @@ str.chomp.chomp
|
|
50
52
|
FileUtils.mkdir_p "#{self.config['user_data_path']}/kindle/queue"
|
51
53
|
open("#{self.config['user_data_path']}/kindle/queue/#{self.key}_#{user_id}", 'w'){|x| x.puts ''}
|
52
54
|
end
|
55
|
+
def change_aspect_rate rate
|
56
|
+
FileUtils.mkdir_p "#{self.config['user_data_path']}/rate"
|
57
|
+
open("#{self.config['user_data_path']}/rate/queue.txt", "a"){|x| x.puts "#{self.key} #{rate}"}
|
58
|
+
end
|
53
59
|
|
54
60
|
|
55
61
|
|
56
62
|
def self.find key
|
57
63
|
case key.class.to_s
|
58
64
|
when 'Array'
|
59
|
-
return key.map{|x|
|
65
|
+
return key.map{|x| Groonga['Files'][x]}.select{|x| x}.map{|x| self.new x}
|
60
66
|
when 'String'
|
61
67
|
return self.new Groonga['Files'][key]
|
62
68
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
xml.instruct! :xml, :version => '1.0'
|
2
|
+
xml.rss :version => "2.0" do
|
3
|
+
xml.channel do
|
4
|
+
xml.title "Pig Media Server - feed - '#{h params[:query]}'"
|
5
|
+
xml.description "pig feed"
|
6
|
+
xml.link "http://#{config['hostname']}/feed?query=#{CGI.escape params[:query]}"
|
7
|
+
|
8
|
+
@list.each do |p|
|
9
|
+
xml.item do
|
10
|
+
xml.title p.name
|
11
|
+
xml.link p.url
|
12
|
+
xml.description p.name
|
13
|
+
xml.pubDate p.mtime.rfc822
|
14
|
+
xml.guid p.url
|
15
|
+
xml.enclosure url: p.url, title: 'Podcast'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -23,13 +23,25 @@
|
|
23
23
|
%button Search
|
24
24
|
%a{href: '/latest'} Latest
|
25
25
|
%a{href: '/config'} Config
|
26
|
+
%a#only-new{href: 'javascript:void(0)'} Only New
|
26
27
|
-if config['custom_list'].class == Hash
|
27
28
|
-config['custom_list'].each do |k,v|
|
28
29
|
%a{href: "/custom?name=#{CGI.escape k}"}=k
|
29
30
|
-if @page
|
31
|
+
-if params[:query] and params[:query].empty? == false
|
32
|
+
%p
|
33
|
+
%a{href: "/feed?query=#{CGI.escape params[:query]}&sort=#{params[:sort]}"} Feed
|
34
|
+
%a{href: "/?query=#{CGI.escape params[:query]}"} Sort By Date
|
35
|
+
%a{href: "/?query=#{CGI.escape params[:query]}&sort=name"} Sort By Name
|
36
|
+
- if params[:order] != 'ascending'
|
37
|
+
%a{href: "/?"+params.merge('order' => 'ascending').map{|k,v| URI.encode(k.to_s) + "=" + URI.encode(v.to_s) }.join('&')} Ascending
|
38
|
+
- if params[:order] != 'descending'
|
39
|
+
%a{href: "/?"+params.merge('order' => 'descending').map{|k,v| URI.encode(k.to_s) + "=" + URI.encode(v.to_s) }.join('&')} Descending
|
40
|
+
|
30
41
|
%p.autopagerize_page_element
|
31
42
|
-@list.each do |l|
|
32
43
|
-next unless l.record
|
44
|
+
-next unless l.record.path
|
33
45
|
!=partial :_link, locals: {l: l}
|
34
46
|
%p.pager
|
35
47
|
-if params[:query] and params[:query].empty? == false
|
@@ -37,6 +49,7 @@
|
|
37
49
|
%a{href: "/edit?query=#{CGI.escape params[:query]}"} Edit
|
38
50
|
-elsif params[:sub]
|
39
51
|
%a{href: "/?sub=true&page=#{@page+1}"} Next
|
52
|
+
-elsif @no_paging
|
40
53
|
-else
|
41
54
|
%a{href: "/latest?page=#{@page+1}"} Next
|
42
55
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
## coffee -csb
|
2
|
+
$ ->
|
3
|
+
v = $('video').get(0)
|
4
|
+
v.addEventListener('canplay', ->
|
5
|
+
$('#aspect').text("Aspect Ratio is #{v.videoHeight/v.videoWidth}")
|
6
|
+
if $('#aspect').text() != "Aspect Ratio is 0.5625"
|
7
|
+
$('#aspect').html(
|
8
|
+
$('<a>').attr(href: "/change_aspect_rate/#{$('#key').text()}?rate=16:9").text("Change To 16:9")
|
9
|
+
)
|
10
|
+
)
|
11
|
+
v.load()
|
12
|
+
## vim: set ft=coffee :
|
@@ -13,8 +13,11 @@
|
|
13
13
|
%input{name: 'query', value: params[:query]}
|
14
14
|
%button Search
|
15
15
|
%a{href: '/latest'} Latest
|
16
|
-
%a{href: '/?syobo=true'} Syobocal
|
17
16
|
%a{href: '/config'} Config
|
17
|
+
-if config['custom_list'].class == Hash
|
18
|
+
-config['custom_list'].each do |k,v|
|
19
|
+
%a{href: "/custom?name=#{CGI.escape k}"}=k
|
20
|
+
|
18
21
|
%h2 Metadata
|
19
22
|
%h3=@p.name
|
20
23
|
%h4 Path
|
@@ -46,6 +46,7 @@ watch = (link)->
|
|
46
46
|
recents['movie/'+key] = {time: parseInt((new Date)/1000), type: 'movie'}
|
47
47
|
window.save_recents recents
|
48
48
|
$('.new_flag').text('')
|
49
|
+
$('.main_span').attr('data-new': '')
|
49
50
|
unless $('#action').text() == 'remote'
|
50
51
|
setTimeout ->
|
51
52
|
window.set_new()
|
@@ -15,6 +15,9 @@
|
|
15
15
|
%a{href: '/latest'} Latest
|
16
16
|
%a{href: '/?syobo=true'} Syobocal
|
17
17
|
%a{href: '/config'} Config
|
18
|
+
-if config['custom_list'].class == Hash
|
19
|
+
-config['custom_list'].each do |k,v|
|
20
|
+
%a{href: "/custom?name=#{CGI.escape k}"}=k
|
18
21
|
%h2 Subtext
|
19
22
|
%h3=@p.name
|
20
23
|
.control
|
@@ -5,10 +5,22 @@ window.set_new = ->
|
|
5
5
|
key = this.getAttribute 'key'
|
6
6
|
unless recents[key]
|
7
7
|
$(this).text 'New!'
|
8
|
+
$(this).parent().attr('data-new': true)
|
8
9
|
count += 1
|
9
10
|
if count == 0
|
10
11
|
$('.main_link').css('margin-left', '0')
|
11
12
|
|
12
13
|
$ ->
|
13
14
|
set_new()
|
15
|
+
$('#only-new').click ->
|
16
|
+
if $(this).attr('now') == 'only'
|
17
|
+
for n in $('.main_span')
|
18
|
+
$(n).attr 'style', ''
|
19
|
+
$(this).removeAttr 'now'
|
20
|
+
$(this).text 'Only New'
|
21
|
+
else
|
22
|
+
for n in $('.main_span')
|
23
|
+
$(n).attr 'style', 'display:none !important' if n.dataset.new == undefined
|
24
|
+
$(this).text 'All'
|
25
|
+
$(this).attr 'now', 'only'
|
14
26
|
|
data/lib/pig-media-server/web.rb
CHANGED
@@ -6,6 +6,7 @@ require 'sinatra/flash'
|
|
6
6
|
require 'net/http'
|
7
7
|
require 'sass'
|
8
8
|
require 'haml'
|
9
|
+
require 'builder'
|
9
10
|
require 'fileutils'
|
10
11
|
require 'coffee_script'
|
11
12
|
require 'rack/csrf'
|
@@ -13,6 +14,7 @@ require 'redcarpet'
|
|
13
14
|
require 'json'
|
14
15
|
|
15
16
|
module PigMediaServer
|
17
|
+
CONFIG = Pit.get 'Pig Media Sever'
|
16
18
|
class UserData
|
17
19
|
def self.save json, user_id, path
|
18
20
|
open("#{path}/#{user_id}.json", "w"){|f| f.puts json}
|
@@ -76,11 +78,18 @@ EOF
|
|
76
78
|
haml :index
|
77
79
|
end
|
78
80
|
|
81
|
+
get '/feed' do
|
82
|
+
@list = Pig.search params.merge(page: @page)
|
83
|
+
content_type :xml#'application/rss+xml'
|
84
|
+
builder :feed
|
85
|
+
end
|
86
|
+
|
79
87
|
get '/custom' do
|
80
88
|
c = config['custom_list'][params[:name]]
|
81
89
|
@page = params[:page].to_i < 1 ? 1 : params[:page].to_i
|
82
90
|
@action = 'list'
|
83
91
|
@list = Pig.find JSON.parse(open(c).read)
|
92
|
+
@no_paging = true
|
84
93
|
haml :index
|
85
94
|
end
|
86
95
|
|
@@ -95,6 +104,15 @@ EOF
|
|
95
104
|
get('/meta/:key'){@p = Pig.find(params[:key]);haml :meta}
|
96
105
|
get('/sub/:key'){@p = Pig.find(params[:key]);haml :sub}
|
97
106
|
get('/webvtt/:key'){@p = Pig.find(params[:key]); content_type :text; @p.webvtt}
|
107
|
+
get '/delete/:key' do
|
108
|
+
p = Groonga['Files'][params[:key]]
|
109
|
+
path = "#{config['recycle_path']}/#{Date.today}/"
|
110
|
+
FileUtils.mkdir_p path unless File.exist? path
|
111
|
+
FileUtils.mv p.path, path rescue nil
|
112
|
+
Groonga['Files'].delete params[:key]
|
113
|
+
redirect params[:href]
|
114
|
+
end
|
115
|
+
|
98
116
|
|
99
117
|
get '/read/:key' do
|
100
118
|
if request.xhr?
|
@@ -112,6 +130,11 @@ EOF
|
|
112
130
|
image
|
113
131
|
end
|
114
132
|
|
133
|
+
get "/change_aspect_rate/:key" do
|
134
|
+
Pig.find(params[:key]).change_aspect_rate(params[:rate])
|
135
|
+
redirect "/meta/#{params[:key]}"
|
136
|
+
end
|
137
|
+
|
115
138
|
post '/gyazo' do
|
116
139
|
url = PigMediaServer::Gyazo.post params[:url], params[:point]
|
117
140
|
content_type :json
|
@@ -185,7 +208,8 @@ EOF
|
|
185
208
|
|
186
209
|
helpers do
|
187
210
|
def config
|
188
|
-
Pit.get
|
211
|
+
$config = Pit.get("Pig Media Server") unless $config
|
212
|
+
$config
|
189
213
|
end
|
190
214
|
def h str; CGI.escapeHTML str.to_s; end
|
191
215
|
def partial(template, *args)
|
data/pig-media-server.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pig-media-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ssig33
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rroonga
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - '>='
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: builder
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - '>='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: coffee-script
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,6 +249,7 @@ files:
|
|
235
249
|
- Rakefile
|
236
250
|
- bin/pig-media-server
|
237
251
|
- lib/pig-media-server.rb
|
252
|
+
- lib/pig-media-server/aspect.rb
|
238
253
|
- lib/pig-media-server/book2.erb
|
239
254
|
- lib/pig-media-server/cli.rb
|
240
255
|
- lib/pig-media-server/crawl.rb
|
@@ -256,7 +271,9 @@ files:
|
|
256
271
|
- lib/pig-media-server/views/book2.erb
|
257
272
|
- lib/pig-media-server/views/config.coffee
|
258
273
|
- lib/pig-media-server/views/config.haml
|
274
|
+
- lib/pig-media-server/views/feed.builder
|
259
275
|
- lib/pig-media-server/views/index.haml
|
276
|
+
- lib/pig-media-server/views/meta.coffee
|
260
277
|
- lib/pig-media-server/views/meta.haml
|
261
278
|
- lib/pig-media-server/views/movie.coffee
|
262
279
|
- lib/pig-media-server/views/read.haml
|