]> git.mdlowis.com Git - proto/atv.git/commitdiff
fixed up html and ruby to play correctly and stay synced. next up is rudimentary...
authorMike Lowis <mike.lowis@gentex.com>
Mon, 15 Jan 2024 18:19:13 +0000 (13:19 -0500)
committerMike Lowis <mike.lowis@gentex.com>
Mon, 15 Jan 2024 18:19:13 +0000 (13:19 -0500)
atv/Gemfile.lock
atv/Rakefile.rb
atv/assets/index.html
atv/atv.gemspec
atv/bin/atv
atv/lib/atv/channel.rb
atv/lib/atv/database.rb

index 43c18150e8f7e291dabd6d8884532c62b55fb279..0ca4371dd693e974060e9ac0bee45ac551182334 100644 (file)
@@ -1,21 +1,15 @@
+PATH
+  remote: .
+  specs:
+    atv (1.0.0)
+      iodine
+
 GEM
-  remote: https://rubygems.org/
   specs:
     diff-lcs (1.5.0)
     docile (1.4.0)
-    gentex-gems-teamcity_utils (1.13.2)
-      nokogiri (~> 1.6)
-      rexml (~> 3.0)
-    gentex-gpkg (1.29.0)
-      bundler
-      rexml (~> 3.0)
-      yawpa (~> 1.1)
-    json (2.7.1)
-    nokogiri (1.13.8-x86_64-linux)
-      racc (~> 1.4)
-    racc (1.6.0)
+    iodine (0.7.55)
     rake (13.1.0)
-    rexml (3.2.5)
     rspec (3.12.0)
       rspec-core (~> 3.12.0)
       rspec-expectations (~> 3.12.0)
@@ -36,19 +30,16 @@ GEM
     simplecov-html (0.12.3)
     simplecov_json_formatter (0.1.4)
     yard (0.9.34)
-    yawpa (1.3.0)
 
 PLATFORMS
-  x86_64-linux
+  ruby
 
 DEPENDENCIES
-  gentex-gems-teamcity_utils (~> 1.3)
-  gentex-gpkg (>= 1.16, < 99.0)
-  json (~> 2.0)
+  atv!
   rake (~> 13.0)
   rspec (~> 3.0)
   simplecov (~> 0.9)
   yard (~> 0.9)
 
 BUNDLED WITH
-   2.4.7
+   2.1.4
index 7e2048a1e873776645843160845fe7480a4b3cb7..81794f4a8781daa660be12a815a4ff2f69b3bd69 100644 (file)
@@ -6,21 +6,17 @@ rescue Bundler::BundlerError => e
 end
 
 require "rake/clean"
-require "gpkg/rake_tasks"
+require "bundler/gem_tasks"
 require "rspec"
 require "rspec/core/rake_task"
 require "yard"
 require "simplecov"
-require "json"
-require "gentex/gems/teamcity_utils"
 
 CLEAN.include "pkg"
 CLEAN.include "coverage"
 CLOBBER.include ".yardoc"
 CLOBBER.include "doc"
 
-task :default => :spec
-
 RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
   if args.example_string
     ENV["partial_specs"] = "1"
@@ -28,18 +24,6 @@ RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
   end
 end
 
-task :spec do
-  # Report coverage % to TeamCity
-  if Gentex::Gems::TeamcityUtils.server_exec?
-    begin
-      cov_pct = JSON.load(File.read("coverage/.last_run.json"))["result"]["line"]
-      Gentex::Gems::TeamcityUtils.append_build_status(" (cov: #{cov_pct}%)")
-    rescue Exception => e
-      $stderr.puts "Error reporting coverage: #{e.message}"
-    end
-  end
-end
-
 YARD::Rake::YardocTask.new do |yard|
   yard.options = ["--private", "--title", "atv gem"]
   yard.files = ["lib/**/*.rb"]
@@ -54,10 +38,9 @@ task :yard do
   end
 end
 
-task :build_pkg => :yard
+task :build => :yard
 
 task :default => [
   :spec,
-  :yard,
-  :build_pkg,
+  :build,
 ]
index f6bc175e87ab0fefc2f1ea80d566303244699323..cbd7f9087d806fe9425412723d3f2c12284bdc0d 100644 (file)
 </video>
 
 <script>
-const updatePlayer = (data)=>{
-    console.log(data["curr"]);
-    console.log(data["curr"]["duration"])
-    const duration = data["curr"]["duration"];
-    const elapsed = data["time"]
-    if (elapsed > 0 && elapsed < duration)
+let current = {};
+
+const secondsSinceMidnight = ()=>{
+    const now = new Date();
+    const midnight = new Date(
+        now.getFullYear(),
+        now.getMonth(),
+        now.getDate(),
+        0,0,0);
+    return (now.getTime() - midnight.getTime()) / 1000;
+};
+
+const updatePlayer = ()=>{
+    const curr_time = secondsSinceMidnight();
+    if (!current["start_time"])
+    {
+        current["start_time"] = secondsSinceMidnight() - current["time"];
+    }
+    console.log(current);
+    const start_time = current["start_time"];
+    const duration = current["curr"]["duration"];
+    const elapsed = Math.floor(curr_time - start_time);
+    if (elapsed >= 0 && elapsed < duration)
     {
-        Video.src = data["curr"]["path"] + "#t=" + Math.floor(elapsed);
+        Video.src = current["curr"]["path"] + "#t=" + Math.floor(elapsed);
     }
 };
 
 const Cmd = {
     play: (data)=>{
-        console.log(data);
-        updatePlayer(data);
+        current = data;
+        updatePlayer();
     }
 };
 
index b75d78c58263798c6462d81ed8a1774a349d604b..66ab806b2a68da4013f1eb80587cf9871ba1f7ad 100644 (file)
@@ -1,27 +1,22 @@
-# -*- encoding: utf-8 -*-
-require "gpkg/gem_specification"
-lib = File.expand_path("../lib", __FILE__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
+Gem::Specification.new do |s|
+  s.name        = 'atv'
+  s.version     = '1.0.0'
+  s.licenses    = ['MIT']
+  s.summary     = "Websocket server that simulates a TV station"
+  s.description = "Websocket server that simulates a TV station"
+  s.authors     = ["Mike Lowis"]
+  s.email       = 'mike@mdlowis.com'
+  s.files       = Dir.glob(["{bin,assets,lib,doc}/**/*", "*.gemspec"]).select {|f| File.file?(f)}
+#  s.homepage    = 'https://rubygems.org/gems/example'
+#  s.metadata    = { "source_code_uri" => "https://github.com/example/example" }
+  s.bindir = "bin"
+  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
 
-Gpkg.gem_specification do |gpkg|
-  gpkg.name          = "gems/atv"
-  gpkg.version       = "1.0.0"
-  gpkg.authors       = ["Mike Lowis"]
-  gpkg.email         = ["mike@mdlowis.com"]
-  gpkg.summary       = %q{Websocket server that simulates a TV station}
-  gpkg.description   = %q{Websocket server that simulates a TV station}
-  gpkg.homepage      = ""
-  gpkg.licenses      = ["Nonstandard"]
+  s.add_dependency "iodine"
 
-  gpkg.files         = Dir.glob(["{bin,assets,lib,doc}/**/*", "*.gemspec"]).select {|f| File.file?(f)}
+  s.add_development_dependency "rspec", "~> 3.0"
+  s.add_development_dependency "simplecov", "~> 0.9"
+  s.add_development_dependency "yard", "~> 0.9"
+  s.add_development_dependency "rake", "~> 13.0"
 
-  gpkg.executables   = gpkg.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
-  gpkg.test_files    = gpkg.files.grep(%r{^(test|spec|features)/})
-  gpkg.require_paths = ["lib"]
-
-  gpkg.add_development_dependency "json", "~> 2.0"
-  gpkg.add_development_dependency "rspec", "~> 3.0"
-  gpkg.add_development_dependency "simplecov", "~> 0.9"
-  gpkg.add_development_dependency "yard", "~> 0.9"
-  gpkg.add_development_dependency "rake", "~> 13.0"
 end
index 3a04355921e189271645d839c06a2674a91f5df5..9eba39078a5a263722bf95663f11e52c8abff7f7 100755 (executable)
@@ -5,7 +5,7 @@ require 'atv/channel'
 require 'atv/player'
 require 'atv/server'
 
-db = ATV::Database.new(ENV["ETV_ROOT"] || "/var/www/atv")
+db = ATV::Database.new(ENV["ATV_ROOT"] || "/var/www/atv")
 channels = [
   ATV::Channel.new('Everything', db,
     ["Movies", "Shorts", "Shows"])
index 2cbb4c6f6ea9c3efb4a05c49107c11b1318742ca..b9027ed5d62a0fca868be273451b5cc5475b1636 100644 (file)
@@ -8,10 +8,11 @@ module ATV
       @items = selectors.map do |sel|
         files.select {|f| f["path"].start_with? sel }
       end.flatten.shuffle
-      @time = @items[@index]["duration"] - 10
+#      @time = @items[@index]["duration"] - 10
     end
 
     def update(playing)
+      return false if @items.length == 0
       @time += 1 if playing
       item = @items[@index]
       if @time >= item["duration"] then
@@ -29,7 +30,7 @@ module ATV
         @index = 0
       end
       @time = 0
-      @time = @items[@index]["duration"] - 10
+#      @time = @items[@index]["duration"] - 10
     end
 
     def state()
index 7afdceb4640cbe2aeba851aefce3ce7025213254..d675287b33034e07d632416b5816e2f3ce5fbb77 100644 (file)
@@ -14,10 +14,9 @@ module ATV
     def load()
       if File.exist? @path
         @data = JSON.parse(File.read(@path))
-      else
-        scan()
-        save()
       end
+      scan()
+      save()
     end
 
     def save()
@@ -44,10 +43,12 @@ module ATV
     end
 
     def scan()
-      Dir.glob("#{@path}/**/*.{mp4,webm,ogg}").each do |f|
-        next if @data[f]
+      Dir.glob("#{@root}/**/*.{mp4,webm,ogg}").each do |f|
+        short_path = f.sub("#{@root}/", '')
+        next if @data[short_path]
+        puts f
         duration = `#{CMD} \"#{f}\"`.chomp.to_f
-        @data[f] = { "duration" => duration }
+        @data[short_path] = { "duration" => duration }
       end
     end
   end