vidload 0.1.10 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3416ba597c831a7d6e1460bc0447fee8577e758279e036e820ccd967d93d46ef
4
- data.tar.gz: a6d4c4c9e5bc8447cf68335029d60ca156c98ef6fc7bacd066b2335ca0e6966b
3
+ metadata.gz: 9f2f19f4a3e68894970ee46251031cabb28592bd242f0e1b7e2ecc8f5d40c3ee
4
+ data.tar.gz: 78b597dba867b0b988021cee4b8d35ea2a42d5df224af9cd052873c92687cada
5
5
  SHA512:
6
- metadata.gz: '0891fcda0f3d59ea64ce309f35fea44456185bf0c6d56765e3c6d6ca60160819d19428e2b065e55c5c14efd3a7ef5dffa712ae02861e4e098c2d6e8bb8fdef75'
7
- data.tar.gz: d5406c2f3e81b23038402e9f249c2359a96dc89edeba437e8274a2c4ada88bf6f1207373ab3205a2c9604bcc88bf0af8d8443e2f483cf93647c5934d780df466
6
+ metadata.gz: a4261172dc43b40d8f652f96103612d286825816c3d0acc57c2819364545158935c358a0b13b3cb7280d0b9281edc966cb8104c019306ad847548cf7de281120
7
+ data.tar.gz: ea0934e1a52dee15f4204a16c5e1bd08580742b634ad02f86cf17f776373b5b60216098ef94e07e4770903d341c482fd0c1f15b8b4bf738ab1614649588e90e9
@@ -0,0 +1,36 @@
1
+ require "thor"
2
+
3
+ class Vidload::Cli < Thor
4
+ desc "mp2t VIDEO_URL", "download a mp2t containerized video"
5
+ method_option :video_name, type: :string, required: false
6
+ method_option :author_name, type: :string, required: false
7
+ method_option :output_dir, type: :string, required: false
8
+ method_option :hls_url, type: :string, required: true
9
+ method_option :master_playlist_name, type: :string, required: true
10
+ method_option :playwright_cli_path, type: :string, required: true
11
+ method_option :video_referer, type: :string, required: true
12
+ method_option :ts_seg_pattern, type: :string, required: true
13
+ method_option :hls_index_pattern, type: :string, required: true
14
+ def mp2t(video_url)
15
+ params = {
16
+ video_url: video_url,
17
+ video_name: options[:video_name],
18
+ hls_url: options[:hls_url],
19
+ master_playlist_name: options[:master_playlist_name],
20
+ playwright_cli_path: options[:playwright_cli_path],
21
+ video_referer: options[:video_referer],
22
+ ts_seg_pattern: options[:ts_seg_pattern],
23
+ hls_index_pattern: options[:hls_index_pattern],
24
+ author_name: options[:author_name],
25
+ output_dir: options[:output_dir],
26
+ }
27
+
28
+ process_mp2t(params)
29
+ end
30
+
31
+ private
32
+
33
+ def process_mp2t(params)
34
+ raise NotImplementedError
35
+ end
36
+ end
@@ -19,13 +19,14 @@ module Vidload::Mp2t::Api
19
19
  def initialize(
20
20
  video_url:,
21
21
  video_name:,
22
+ author_name:,
22
23
  hls_url:,
23
24
  master_playlist_name:,
24
25
  playwright_cli_path:,
25
26
  video_referer:,
26
27
  ts_seg_pattern:,
27
28
  hls_index_pattern:,
28
- author_name:
29
+ output_dir:
29
30
  )
30
31
  raise ArgumentError, "video_url must be provided" unless video_url
31
32
  raise ArgumentError, "hls_url must be provided" unless hls_url
@@ -45,6 +46,7 @@ module Vidload::Mp2t::Api
45
46
  @max_lines = IO.console.winsize[0]
46
47
  @author_name = author_name
47
48
  @video_name = if @author_name then "#{@author_name}_#{video_name}" else nil end
49
+ @output_dir = output_dir || "./"
48
50
  end
49
51
 
50
52
  def self.from_argv
@@ -61,6 +63,20 @@ module Vidload::Mp2t::Api
61
63
  )
62
64
  end
63
65
 
66
+ def self.from_hash(hash)
67
+ new(
68
+ video_url: hash[:video_url],
69
+ author_name: hash[:author_name],
70
+ video_name: hash[:video_name],
71
+ hls_url: hash[:hls_url],
72
+ master_playlist_name: hash[:master_playlist_name],
73
+ playwright_cli_path: hash[:playwright_cli_path],
74
+ video_referer: hash[:video_referer],
75
+ ts_seg_pattern: hash[:ts_seg_pattern],
76
+ hls_index_pattern: hash[:hls_index_pattern],
77
+ )
78
+ end
79
+
64
80
  # main func to be called in your own scripts defined under web/
65
81
  def download_video(video_starter_callbacks: [])
66
82
  Playwright.create(playwright_cli_executable_path: @playwright_cli_path) do |playwright|
@@ -122,7 +138,7 @@ module Vidload::Mp2t::Api
122
138
 
123
139
  def trigger_video_download(video_url, seg_qty)
124
140
  puts "Video starts. Starting download..."
125
- run_cmd(DEMUXER_PATH, video_url, @video_name, @video_referer) do |line|
141
+ run_cmd(DEMUXER_PATH, video_url, "#{@output_dir}#{@video_name}", @video_referer) do |line|
126
142
  if (line.include?("hls @") || line.include?("https @")) && line.match?(/#{@ts_seg_pattern}/i)
127
143
  seg_nb = line.match(/#{@ts_seg_pattern}/i)[:seg_nb]
128
144
  add_line(line)
@@ -130,7 +146,7 @@ module Vidload::Mp2t::Api
130
146
  end
131
147
  end
132
148
  print "\r\e[2K"
133
- puts "✔ Video downloaded successfully! Available in ./#{@video_name}.mp4"
149
+ puts "✔ Video downloaded successfully! Available in #{@output_dir}#{@video_name}.mp4"
134
150
  VIDEO_DOWNLOADED_EVENT_QUEUE << true
135
151
  end
136
152
 
@@ -1,3 +1,3 @@
1
1
  module Vidload
2
- VERSION = "0.1.10"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/vidload.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Vidload
2
2
  require_relative "vidload/version"
3
3
  require_relative "vidload/mp2t"
4
+ require_relative "vidload/cli"
4
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patacode <pata.codegineer@gmail.com>
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +87,7 @@ extensions: []
73
87
  extra_rdoc_files: []
74
88
  files:
75
89
  - lib/vidload.rb
90
+ - lib/vidload/cli.rb
76
91
  - lib/vidload/mp2t.rb
77
92
  - lib/vidload/mp2t/api.rb
78
93
  - lib/vidload/mp2t/remuxer.sh