distorted-jekyll 0.5.7 → 0.6.0

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.
@@ -1,90 +0,0 @@
1
- require 'set'
2
-
3
- require 'distorted/video'
4
- require 'distorted-jekyll/static/state'
5
-
6
- module Jekyll
7
- module DistorteD
8
- module Static
9
- class Video < Jekyll::DistorteD::Static::State
10
-
11
- DRIVER = Cooltrainer::DistorteD::Video
12
-
13
- MEDIA_TYPE = DRIVER::MEDIA_TYPE
14
- MIME_TYPES = DRIVER::MIME_TYPES
15
-
16
- ATTRS = DRIVER::ATTRS
17
- ATTRS_DEFAULT = DRIVER::ATTRS_DEFAULT
18
- ATTRS_VALUES = DRIVER::ATTRS_VALUES
19
-
20
-
21
- # dest: string realpath to `_site_` directory
22
- def write(dest)
23
- orig_dest = destination(dest)
24
-
25
- # TODO: Make this smarter. Need to see if there's an easy way to
26
- # get a list of would-be-generated filenames from GStreamer.
27
- return false if File.exist?(path) && !modified?
28
- self.class.mtimes[path] = mtime
29
-
30
- distorted = DRIVER.new(path, orig_dest, basename)
31
-
32
- distorted.generate
33
- end
34
-
35
- # Return a Set of extant video variations due to inability/unwillingness
36
- # to exactly predict GStreamer's HLS/DASH segment output naming
37
- # even if we are controlling all variables like segment length etc.
38
- # This implementation may give stale segments but will at least speed
39
- # up site generation by not having to regenerate the video every time.
40
- def destinations(dest)
41
- wanted = Set[]
42
- if Dir.exist?(dd_dest(dest))
43
- hls_dir = File.join(dd_dest(dest), "#{basename}.hls")
44
- if Dir.exist?(hls_dir)
45
- wanted.merge(Dir.entries(hls_dir).to_set.map{|f| File.join(hls_dir, f)})
46
- end
47
- end
48
- wanted
49
- end
50
-
51
- def modified?
52
- # We can't use the standard Static::State#modified? here until
53
- # I figure out how to cleanly get a duplicate of what would be
54
- # the generated filenames from GStreamer's sink.
55
- #
56
- # For now for the sake of speeding up my site generation
57
- # I'll assume not-modified that if the output variant (e.g. DASH/HLS)
58
- # container dir exists and contains at least two files:
59
- # the playlist and at least one segment.
60
- #
61
- # Hacky HLS-only right now until dashsink2 lands in upstream Gst.
62
- #
63
- # Assume modified for the sake of freshness :)
64
- modified = true
65
-
66
- site_dest = Jekyll::DistorteD::Floor::config(:destination).to_s
67
- if Dir.exist?(site_dest)
68
-
69
- dd_dest = dd_dest(site_dest)
70
- if Dir.exist?(dd_dest)
71
-
72
- hls_dir = File.join(dd_dest, "#{basename}.hls")
73
- if Dir.exist?(hls_dir)
74
- need_filez = Set["#{basename}.m3u8"]
75
- var_filez = Dir.entries(hls_dir).to_set
76
- if need_filez.subset?(var_filez) and var_filez.count > 2
77
- modified = false
78
- end
79
- end
80
-
81
- end
82
- end
83
- Jekyll.logger.debug("#{@name} modified?", modified)
84
- modified
85
- end
86
-
87
- end # Video
88
- end # Static
89
- end # DistorteD
90
- end # Jekyll