radikocopy 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1533e1092a18c3b600f09c5ee71740744f3364fe
4
- data.tar.gz: a88eeccc97050581629a8596589640fbe9369d9f
2
+ SHA256:
3
+ metadata.gz: c312d6b5fc43fceefd5f1972b590f9da863d9583df7beaf92a1ce3bced8ab57d
4
+ data.tar.gz: 4fec3d797dc813a65551c51eb0d2005b7d468d7f69eeb9045443b7b6a9d62893
5
5
  SHA512:
6
- metadata.gz: 19620e88d9adea91b6e7d4aa4287a75be2396b101414d8646a5710c8cff42e7be589524f96d8f8d43eccb493d819479f0ca9b6491f407a177a22cb5b11de5c28
7
- data.tar.gz: 43a7c14b14518a14dc678d6f36a766b4e09d1be6f3ed24d166b7f792f09b72eccd6f408645f9b42a390cd694c0ec2810d4dc802620c345c430d4ff23ec5b2954
6
+ metadata.gz: 1abddd0691c300d07bf553b0efabd0804ede4fe371cd600359eaec52fcbeb875653c9ad33b9988895f1a164f11d73b73068d2e295ba5e1f8e6274cfdf34175a5
7
+ data.tar.gz: bd9bca469e2e32745ba4b5a1625b9fa9e5b49f1a74cb944f52feb7ff10c87aef184bd9aeef2a9b6252fa8810a3bf80599b630156dc4e6e6c675f477acbd090a0
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.2
1
+ 2.5.3
@@ -1,3 +1,3 @@
1
1
  module Radikocopy
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/radikocopy.rb CHANGED
@@ -15,9 +15,10 @@ module Radikocopy
15
15
  end
16
16
  dir = File.dirname(File.expand_path(__FILE__))
17
17
  @import_scpt = File.join(dir, "radikoimport.scpt")
18
+ @keep = 10
18
19
  end
19
20
 
20
- attr_reader :remote_host, :remote_dir, :local_dir, :import_scpt
21
+ attr_reader :remote_host, :remote_dir, :local_dir, :import_scpt, :keep
21
22
 
22
23
  def to_s
23
24
  str = ''
@@ -86,6 +87,7 @@ module Radikocopy
86
87
  filenames = copy_files
87
88
  end
88
89
  import_files(filenames)
90
+ expire_local_files
89
91
  puts "##### end radikocopy #####"
90
92
  end
91
93
 
@@ -96,6 +98,7 @@ module Radikocopy
96
98
  result = `#{list_command}`
97
99
  files = []
98
100
  result.each_line do |line|
101
+ # puts line
99
102
  line.chomp!
100
103
  if line =~ /mp3$/ || line =~ /m4a$/
101
104
  if copy_file(line)
@@ -148,6 +151,19 @@ module Radikocopy
148
151
  true
149
152
  end
150
153
 
154
+ def expire_local_files
155
+ #ローカル保存フォルダ内の古いファイルを削除する
156
+ filenames = Dir.glob("#{@config.local_dir}/*.{mp3,m4a}").sort_by {|f| File.mtime(f) }.reverse
157
+ filenames.each_with_index do |filename, index|
158
+ if index < @config.keep
159
+ puts "Keep: #{filename}"
160
+ else
161
+ puts "Delete: #{filename}"
162
+ File.unlink(filename)
163
+ end
164
+ end
165
+ end
166
+
151
167
  def runcmd_and_exit(cmd)
152
168
  unless runcmd(cmd)
153
169
  puts "system error"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radikocopy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - src
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-13 00:00:00.000000000 Z
11
+ date: 2018-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.6.13
101
+ rubygems_version: 2.7.6
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Radiko copy tool