md2slides 0.0.2 → 0.0.4

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: c82f7759595882a7bce78e9a46dfd95b91dc784038ad91d7295c62c9d73bd414
4
- data.tar.gz: 76a42b4e8731d1e9888f6ce8534afa876bbe0ed45cae5507dd8caf414af89141
3
+ metadata.gz: 37da571eb1e048ee8704c95778e990564251cc1dfed86fb0e5c92c8d63378227
4
+ data.tar.gz: ef0f3367747ea41eb5e0850ac02a6d844a9b69ca9af8fe1395c3c19484f0fd88
5
5
  SHA512:
6
- metadata.gz: b5a792702ae0716d1b0bd3cadb0de3fcfa0bfc798b05cbdb7bd78e67afed69dc1c9c826c1b837fbcad11c5b61b36148f4347d1144a86bcb0d039396c355b0812
7
- data.tar.gz: f742639e88eff95e7a20af0eb79c6a0f0df19a86c97e6429181a8a1eae2d35262d20e85b67eb3c4de21a663116514c5f373d9bc2eaa6c3bbd5e9df8ed010c3bb
6
+ metadata.gz: 4b65446aa4824038aa84c4f7f9954ed6986d8ae3e7c8107806b803f4e75df8fd199c10061371075c229d5886f767d725b21430f3d2611cbf268b2d7b8dc779bb
7
+ data.tar.gz: 9e0a800ed47263fe9fd3b55a226891f987a2bb91f6eb32396bfe8e8bf6eebdbe01790d23e066ea8cb18e0a369e8c4a56f00cab71b69c5ccca978bc855663163c
data/README.md CHANGED
@@ -3,10 +3,27 @@
3
3
  A video file of a presentation will be also generated, and it may contains narration if supplied.
4
4
  Narration can be given as notes in slides, and the audio will be generated using Google text-to-speech API and ffmpeg.
5
5
 
6
+ ## Installation
7
+
8
+ install by gem:
9
+
10
+ % gem install md2slides
11
+
12
+ Or add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'md2slides'
16
+ ```
17
+
18
+ and then execute:
19
+
20
+ $ bundle
21
+
6
22
  ## Quick start
7
23
  1. Generate your Google API credentials and copy it to credentails.json:
8
24
  ```
9
- % cat >> config/credentials.json
25
+ % mkdir ~/.config/gcloud
26
+ % cat >> ~/.config/gcloud/credentials.json
10
27
  {
11
28
  "type": "service_account",
12
29
  "project_id": "project-id",
@@ -23,14 +40,9 @@ Narration can be given as notes in slides, and the audio will be generated using
23
40
  ```
24
41
  2. install ffmpeg if necessary (if producing video file).
25
42
 
26
- 3. install necessary gems.
27
- ```
28
- % bundle install --path vendor/bundle
29
- ```
30
-
31
- 4. create an empty Google slide.
43
+ 3. create an empty Google slide, share it with **client_email** user, and copy the URL.
32
44
 
33
- 5. write a markdown file.
45
+ 4. write a markdown file.
34
46
  ```
35
47
  cat >> doc/sample.md
36
48
  ---
@@ -52,33 +64,21 @@ narration text...
52
64
  ^D (this means CTRL + D)
53
65
  ```
54
66
 
55
- 6. execute.
67
+ 5. run the script.
56
68
  ```
57
- bundle exec bin/md2slides doc/sample.md
69
+ % md2slides sample.md
58
70
  ```
59
71
 
60
- 7. the Google presentation is updated, and the video is stored in `data/`.
61
-
62
- ## Installation
63
-
64
- Add this line to your application's Gemfile:
65
-
66
- ```ruby
67
- gem 'md2slides'
68
- ```
69
-
70
- And then execute:
71
-
72
- $ bundle
73
-
74
- Or install it yourself as:
75
-
76
- $ gem install md2slides
72
+ the Google presentation is updated, and the video is stored in the current directory.
77
73
 
78
74
  ## Usage
79
75
 
80
76
  TODO: Write usage instructions here
81
77
 
78
+ ## TODO
79
+
80
+ See [TODO.md](https://github.com/ohmori7/md2slides/blob/main/TODO.md "TODO.md")
81
+
82
82
  ## Development
83
83
 
84
84
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -16,7 +16,7 @@ class Presentation
16
16
  attr_reader :id
17
17
 
18
18
  def self.filename_sanitize(s)
19
- s.gsub(/[\/\\:\*\?"<>\|]/, '')
19
+ s&.gsub(/[\/\\:\*\?"<>\|]/, '')
20
20
  end
21
21
 
22
22
  def initialize(url = nil)
@@ -40,7 +40,14 @@ class Presentation
40
40
  @drive_service.authorization = @authorizer
41
41
 
42
42
  if @id
43
- @presentation = @slides_service.get_presentation(@id)
43
+ begin
44
+ @presentation = @slides_service.get_presentation(@id)
45
+ rescue => e
46
+ require 'webrick'
47
+ raise(e, "#{e.message} (#{e.status_code} " +
48
+ "#{WEBrick::HTTPStatus.reason_phrase(e.status_code)})\n" +
49
+ "#{e.full_message}")
50
+ end
44
51
  end
45
52
 
46
53
  @requests = []
@@ -60,7 +67,7 @@ class Presentation
60
67
 
61
68
  def existence_check
62
69
  if ! exists?
63
- raise("presentation (ID: #{@id})does not exists!!!")
70
+ raise("presentation (ID: #{@id}) does not exists!!!")
64
71
  end
65
72
  end
66
73
 
@@ -356,9 +363,7 @@ class Presentation
356
363
  end
357
364
 
358
365
  def __data_path(basedir)
359
- if basedir.nil?
360
- basedir = File.join(BASEDIR, 'data')
361
- end
366
+ basedir = '.' if basedir.nil?
362
367
  title, subtitle = get_title
363
368
  title = self.class.filename_sanitize(title)
364
369
  subtitle = self.class.filename_sanitize(subtitle)
@@ -1,3 +1,3 @@
1
1
  module Md2slides
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,6 +1,9 @@
1
1
  require 'open3'
2
2
 
3
3
  class Presentation
4
+ VIDEO_FRAME_RATE = 1
5
+ VIDEO_ONLY_DURATION = 4
6
+
4
7
  def generate_slide_video(i, dir)
5
8
  img = __data_slide_path(i, '.png', dir)
6
9
  audio = __data_slide_path(i, '.m4a', dir)
@@ -11,11 +14,11 @@ class Presentation
11
14
  timeopt = '-shortest'
12
15
  else
13
16
  audioin = "-f lavfi -i aevalsrc=0"
14
- timeopt = "-vframes 60"
17
+ timeopt = "-vframes #{VIDEO_FRAME_RATE * VIDEO_ONLY_DURATION}"
15
18
  end
16
19
  cmd = <<~CMD
17
20
  ffmpeg -hide_banner -y \
18
- -framerate 15 -loop 1 -i "#{img}" \
21
+ -framerate #{VIDEO_FRAME_RATE} -loop 1 -i "#{img}" \
19
22
  #{audioin} -map 0:v:0 -map 1:a:0 \
20
23
  -c:v libx264 -tune stillimage \
21
24
  -c:a aac -ar #{AUDIO_RATE} -ac 1 \
@@ -36,13 +39,13 @@ class Presentation
36
39
  end
37
40
 
38
41
  print "concatenate video files..."
39
- videolist = File.join(dir, 'video-list.txt')
40
- File.open(videolist, 'w') do |f|
42
+ videolist = 'video-list.txt'
43
+ File.open(File.join(dir, videolist), 'w') do |f|
41
44
  @presentation.slides.each_with_index do |slide, i|
42
45
  f.puts("file #{__data_slide_path(i, '.mp4')}")
43
46
  end
44
47
  end
45
- video = File.join(dir, 'video.mp4')
48
+ video = 'video.mp4'
46
49
  cmd = <<~CMD
47
50
  cd "#{dir}" && \
48
51
  ffmpeg -hide_banner -y -f concat -safe 0 \
data/lib/md2slides.rb CHANGED
@@ -3,7 +3,9 @@ $:.unshift File.dirname(File.dirname(File.realpath(__FILE__)))
3
3
  module Md2slides
4
4
  class Error < StandardError; end
5
5
 
6
- require 'config/config'
6
+ # XXX: platform independent path configuration...
7
+ ENV['GOOGLE_APPLICATION_CREDENTIALS'] ||= File.join(Dir.home, ".config/gcloud/credentials.json")
8
+
7
9
  require 'md2slides/md'
8
10
  require 'md2slides/presentation'
9
11
  require 'md2slides/text_to_speech'
data/md2slides.gemspec CHANGED
@@ -35,11 +35,11 @@ Gem::Specification.new do |spec|
35
35
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
36
  spec.require_paths = ["lib"]
37
37
 
38
- spec.add_development_dependency "googleauth"
39
- # spec.add_development_dependency "google-apis-people_v1"
40
- spec.add_development_dependency "google-apis-slides_v1"
41
- spec.add_development_dependency "google-apis-drive_v3"
42
- spec.add_development_dependency "google-cloud-text_to_speech", "~>0.7.0"
38
+ spec.add_dependency "googleauth"
39
+ # spec.add_dependency "google-apis-people_v1"
40
+ spec.add_dependency "google-apis-slides_v1"
41
+ spec.add_dependency "google-apis-drive_v3"
42
+ spec.add_dependency "google-cloud-text_to_speech", "~>0.7.0"
43
43
  spec.add_development_dependency "bundler", "~> 1.17"
44
44
  spec.add_development_dependency "rake", "~> 10.0"
45
45
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md2slides
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Motoyuki OHMORI
@@ -17,7 +17,7 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- type: :development
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -31,7 +31,7 @@ dependencies:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -45,7 +45,7 @@ dependencies:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :development
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.7.0
62
- type: :development
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -111,7 +111,9 @@ dependencies:
111
111
  description: Generate Google slides and its video file from a markdown file.
112
112
  email:
113
113
  - ohmori@tottori-u.ac.jp
114
- executables: []
114
+ executables:
115
+ - md2slides
116
+ - text2mp3
115
117
  extensions: []
116
118
  extra_rdoc_files: []
117
119
  files:
@@ -123,11 +125,9 @@ files:
123
125
  - Rakefile
124
126
  - TODO.md
125
127
  - bin/console
126
- - bin/md2slides
127
128
  - bin/setup
128
- - bin/text2mp3
129
- - config/.gitignore
130
- - config/config.rb
129
+ - exe/md2slides
130
+ - exe/text2mp3
131
131
  - lib/md2slides.rb
132
132
  - lib/md2slides/audio.rb
133
133
  - lib/md2slides/md.rb
data/config/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- *
2
- !config.rb
3
- !.gitignore
data/config/config.rb DELETED
@@ -1,2 +0,0 @@
1
- BASEDIR = File.dirname(File.dirname(File.realpath(__FILE__)))
2
- ENV['GOOGLE_APPLICATION_CREDENTIALS'] = "#{BASEDIR}/config/credentials.json"
File without changes
File without changes