move_media 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +17 -7
- data/bin/move_media +8 -0
- data/lib/mm_util.rb +6 -3
- data/lib/move_media/version.rb +1 -1
- data/lib/move_media.rb +18 -7
- data/move_media.gemspec +1 -1
- data/spec/move_media_spec.rb +2 -2
- metadata +3 -5
- data/exe/move_media +0 -27
- data/spec/status_persistence.txt +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbc3c34febc7c3534bf751850226feae655c2df7e6ed70227b78def5f50f59a0
|
4
|
+
data.tar.gz: a118e19ea6c2cd5bf8419ee28c94a373e34589b30fd35cf3348eaffbfb7a1dbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fff1c59518241eb0f1654c5e1ddeb70453a18123130ba67b1709636aab9e5ca15c51a644a52eebae77e8c63619010f1408391393b5cc25b23e8d3659b8bc5106
|
7
|
+
data.tar.gz: bceca00354765e350da95f24f25bc7a898215796d2a5f8e604201df1819712100793974a7fbbb8fce70daa727622f43bd95ca86ae22b0a3e8d8bc40f6d8fb44a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,19 +4,14 @@
|
|
4
4
|
|
5
5
|
`move_media` moves files from Sony Camera memory cards to permanent storage.
|
6
6
|
|
7
|
-
## Usage
|
8
|
-
|
9
|
-
```
|
10
|
-
move_media
|
11
|
-
```
|
12
|
-
|
13
7
|
|
14
8
|
## Installation
|
15
9
|
|
16
10
|
Modify the following and save as $HOME/.move_media:
|
17
11
|
|
18
12
|
```yaml
|
19
|
-
|
13
|
+
destination_images: /mnt/e/media/staging/THMBNL
|
14
|
+
destination_video: /mnt/e/media/staging/CLIP
|
20
15
|
drive: 'h:'
|
21
16
|
topic: sony
|
22
17
|
```
|
@@ -26,6 +21,21 @@ Install like this:
|
|
26
21
|
$ gem install move_media
|
27
22
|
```
|
28
23
|
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
Check out this project, then run
|
27
|
+
```
|
28
|
+
$ bin/move_media
|
29
|
+
Moving 7.97 GB video from /mnt/h/PRIVATE/M4ROOT/CLIP/C0002.MP4 to /mnt/e/media/staging/CLIP/sony_2022-08-20_0000002.mp4
|
30
|
+
Moving thumbnail from /mnt/h/PRIVATE/M4ROOT/THMBNL/C0002T01.JPG to /mnt/e/media/staging/THMBNL/C0002.jpg
|
31
|
+
Moving 2.37 GB video from /mnt/h/PRIVATE/M4ROOT/CLIP/C0003.MP4 to /mnt/e/media/staging/CLIP/sony_2022-08-20_0000003.mp4
|
32
|
+
Moving thumbnail from /mnt/h/PRIVATE/M4ROOT/THMBNL/C0003T01.JPG to /mnt/e/media/staging/THMBNL/C0003.jpg
|
33
|
+
Moving 1.23 GB video from /mnt/h/PRIVATE/M4ROOT/CLIP/C0004.MP4 to /mnt/e/media/staging/CLIP/sony_2022-08-20_0000004.mp4
|
34
|
+
Moving thumbnail from /mnt/h/PRIVATE/M4ROOT/THMBNL/C0004T01.JPG to /mnt/e/media/staging/THMBNL/C0004.jpg
|
35
|
+
Moving 1.48 GB video from /mnt/h/PRIVATE/M4ROOT/CLIP/C0005.MP4 to /mnt/e/media/staging/CLIP/sony_2022-08-20_0000005.mp4
|
36
|
+
```
|
37
|
+
|
38
|
+
|
29
39
|
## Additional Information
|
30
40
|
More information is available on
|
31
41
|
[Mike Slinn’s website](https://www.mslinn.com/av_studio/210-sony-a7iii.html).
|
data/bin/move_media
ADDED
data/lib/mm_util.rb
CHANGED
@@ -14,8 +14,8 @@ class String
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
Dir[source]
|
17
|
+
def delete_xml_files(source)
|
18
|
+
Dir["#{source}/**/*.XML"].each { |file| File.delete(file) }
|
19
19
|
end
|
20
20
|
|
21
21
|
# @param mount_path [String] contains the mount path to be verified.
|
@@ -44,7 +44,10 @@ end
|
|
44
44
|
|
45
45
|
# @param old_path [String] file to be moved; raises exception if not present
|
46
46
|
def move_and_rename(old_path, new_path)
|
47
|
-
File.
|
47
|
+
raise "Error: #{new_path} already exists." if File.file?(new_path)
|
48
|
+
|
49
|
+
FileUtils.cp(old_path, new_path)
|
50
|
+
File.delete(old_path)
|
48
51
|
end
|
49
52
|
|
50
53
|
# @param source [String] Directory containing videos.
|
data/lib/move_media/version.rb
CHANGED
data/lib/move_media.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
CONFIGURATION_FILE = "#{Dir.home}/.move_media"
|
4
4
|
|
5
|
+
require 'bytesize'
|
5
6
|
require 'date'
|
6
7
|
require_relative 'mm_util'
|
7
8
|
|
@@ -16,7 +17,11 @@ class MoveMedia
|
|
16
17
|
@seq = 1
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
+
def human_file_size(filename)
|
21
|
+
ByteSize.new(File.size(filename)).to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def make_name(fn_fq)
|
20
25
|
date = File.ctime(fn_fq).to_date
|
21
26
|
seq = @seq.to_s.rjust(SIGNIFICANT_DIGITS, '0')
|
22
27
|
"#{@topic}_#{date}_#{seq}"
|
@@ -24,18 +29,24 @@ class MoveMedia
|
|
24
29
|
|
25
30
|
# Move Sony camera thumbnail for video_filename from source to destination
|
26
31
|
# @return new path for thumbnail
|
27
|
-
def
|
32
|
+
def process_thumbnail(fn_fq)
|
33
|
+
video_filename_stem = File.basename(fn_fq, '.*')
|
28
34
|
old_path = sony_thumbnail(@source, video_filename_stem)
|
29
|
-
|
30
|
-
|
35
|
+
return nil if old_path.nil?
|
36
|
+
|
37
|
+
new_thumbnail_name = make_name(fn_fq)
|
38
|
+
new_path = "#{@destination_images}/#{new_thumbnail_name}.jpg"
|
39
|
+
puts "Moving thumbnail from #{old_path} to #{new_path}"
|
31
40
|
move_and_rename(old_path, new_path)
|
32
41
|
new_path
|
33
42
|
end
|
34
43
|
|
35
44
|
# Destination files are yyyy-mm-dd_topic_0001234.{mp4,jpg}
|
36
45
|
def process_video(fn_fq)
|
37
|
-
new_name =
|
46
|
+
new_name = make_name(fn_fq)
|
38
47
|
new_name_fq = "#{@destination_video}/#{new_name}.mp4"
|
48
|
+
|
49
|
+
puts "Moving #{human_file_size(fn_fq)} video from #{fn_fq} to #{new_name_fq}"
|
39
50
|
move_and_rename(fn_fq, new_name_fq)
|
40
51
|
@seq += 1
|
41
52
|
new_name_fq
|
@@ -72,9 +83,9 @@ class MoveMedia
|
|
72
83
|
scan_for_next_seq(@destination_video)
|
73
84
|
video_filenames(@source).each do |fn_fq|
|
74
85
|
process_video(fn_fq)
|
75
|
-
|
76
|
-
move_thumbnail(video_filename_stem)
|
86
|
+
process_thumbnail(fn_fq)
|
77
87
|
end
|
88
|
+
delete_xml_files(@source)
|
78
89
|
unmount_memory_card(@source) unless already_mounted
|
79
90
|
end
|
80
91
|
end
|
data/move_media.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.description = <<~END_OF_DESC
|
11
11
|
Moves files from Sony Camera memory cards to permanent storage.
|
12
12
|
END_OF_DESC
|
13
|
-
spec.bindir = 'exe'
|
13
|
+
# spec.bindir = 'exe'
|
14
14
|
spec.email = ['mslinn@mslinn.com']
|
15
15
|
spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
|
16
16
|
spec.executables = 'move_media'
|
data/spec/move_media_spec.rb
CHANGED
@@ -73,10 +73,10 @@ RSpec.describe(MoveMedia) do # rubocop:disable Metrics/BlockLength
|
|
73
73
|
copy_videos_to_destination
|
74
74
|
mm.scan_for_next_seq(destination_video)
|
75
75
|
file_date = File.ctime(file_to_copy).to_date
|
76
|
-
expect(mm.
|
76
|
+
expect(mm.make_name(file_to_copy)).to eq("sony_#{file_date}_0000042")
|
77
77
|
|
78
78
|
mm.seq = 666
|
79
|
-
expect(mm.
|
79
|
+
expect(mm.make_name(file_to_copy)).to eq("sony_#{file_date}_0000666")
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'processes a video' do
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: move_media
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2022-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
@@ -25,7 +25,7 @@ files:
|
|
25
25
|
- LICENSE.txt
|
26
26
|
- README.md
|
27
27
|
- Rakefile
|
28
|
-
-
|
28
|
+
- bin/move_media
|
29
29
|
- lib/mm_util.rb
|
30
30
|
- lib/move_media.rb
|
31
31
|
- lib/move_media/version.rb
|
@@ -37,7 +37,6 @@ files:
|
|
37
37
|
- spec/fixtures/source/PRIVATE/M4ROOT/THMBNL/C0001T04.JPG
|
38
38
|
- spec/move_media_spec.rb
|
39
39
|
- spec/spec_helper.rb
|
40
|
-
- spec/status_persistence.txt
|
41
40
|
homepage: https://www.mslinn.com/av_studio/210-sony-a7iii.html
|
42
41
|
licenses:
|
43
42
|
- MIT
|
@@ -77,5 +76,4 @@ test_files:
|
|
77
76
|
- spec/fixtures/source/PRIVATE/M4ROOT/THMBNL/C0001T04.JPG
|
78
77
|
- spec/move_media_spec.rb
|
79
78
|
- spec/spec_helper.rb
|
80
|
-
- spec/status_persistence.txt
|
81
79
|
...
|
data/exe/move_media
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'move_media' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
-
|
13
|
-
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
-
|
15
|
-
if File.file?(bundle_binstub)
|
16
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
17
|
-
load(bundle_binstub)
|
18
|
-
else
|
19
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
require "rubygems"
|
25
|
-
require "bundler/setup"
|
26
|
-
|
27
|
-
load Gem.bin_path("move_media", "move_media")
|
data/spec/status_persistence.txt
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
example_id | status | run_time |
|
2
|
-
------------------------------- | ------ | --------------- |
|
3
|
-
./spec/move_media_spec.rb[1:1] | passed | 0.00074 seconds |
|
4
|
-
./spec/move_media_spec.rb[1:2] | passed | 0.00008 seconds |
|
5
|
-
./spec/move_media_spec.rb[1:3] | passed | 0.0214 seconds |
|
6
|
-
./spec/move_media_spec.rb[1:4] | passed | 0.00024 seconds |
|
7
|
-
./spec/move_media_spec.rb[1:5] | passed | 0.00009 seconds |
|
8
|
-
./spec/move_media_spec.rb[1:6] | passed | 0.00054 seconds |
|
9
|
-
./spec/move_media_spec.rb[1:7] | passed | 0.00155 seconds |
|
10
|
-
./spec/move_media_spec.rb[1:8] | passed | 0.00093 seconds |
|
11
|
-
./spec/move_media_spec.rb[1:9] | passed | 0.00036 seconds |
|
12
|
-
./spec/move_media_spec.rb[1:10] | passed | 0.03275 seconds |
|