mediafile 0.2.13 → 0.3.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: 1397ae7527dd5d9e250c6213f05c5a34b8ff5a8596405fca0db16dfe0c1f7d54
4
- data.tar.gz: 0bbbaae4d48e9313970d03d802fc3a63bd53bf92af598e1dadda9fcb677d1092
3
+ metadata.gz: 1d13b07db004204da62e828da733ff2e350adea5340efd5dc53d6e6adbf2d8b9
4
+ data.tar.gz: 8a085e9ac0f79ba5a31538531a4f36537ddf295d413039b8d844e452bbe3f960
5
5
  SHA512:
6
- metadata.gz: a4f0764054069b5a754606bae972fccd849625c725f93175a300eeb15ddaee9b0fa08918176776c4c85ad6a8bfafb91d77244044fba6b9174d22d56d034a0f46
7
- data.tar.gz: ef61f10d368e12324aba99ee50fbd7255ae17e85d266394637d6133ec361e3d7422a04a095445507708ec18dfdb265b0807bc5cedfc1926ae45e17af71cb0030
6
+ metadata.gz: dc9392f337144ff23223e9703abca1d3702158088a16d1ae435a8e08b1948b3bed5e6dfa358644ccf77619e34c05bfd8cabb4ecb97bf62fcb01729599576fc89
7
+ data.tar.gz: 6c338249dc18475cd4bd4ae415b376929cb11be6bd8361c350d43145df663f2f944d5c60409fecaec1076dbd7aa699ac235eb997fe83528b4b59d6d3574b51d9
@@ -50,11 +50,13 @@ class MediaFile
50
50
  temp_dest = tmp_path base_dir: dest, typ: transcode_table[@type]
51
51
  debug "temp dest is '#{temp_dest}'"
52
52
 
53
- if File.exist?(destination)
54
- @noop = true
55
- info("File already exists at destination: #{@source} => #{destination}")
56
- return
57
- end
53
+ lock {
54
+ if File.exist?(destination) || File.exist?(temp_dest)
55
+ @noop = true
56
+ info("File already exists at destination: #{@source} => #{destination}")
57
+ end
58
+ }
59
+ return if @noop
58
60
 
59
61
  unless check_transfer(temp_dest)
60
62
  error "Another file is already getting " +
@@ -63,7 +65,10 @@ class MediaFile
63
65
  error "This file: #{@source} => #{temp_dest}"
64
66
  return
65
67
  end
68
+ really_copy(temp_dest, destination, transcode_table)
69
+ end
66
70
 
71
+ def really_copy(temp_dest, destination, transcode_table)
67
72
  debug("Create parent directories at '#{File.dirname destination}'.")
68
73
  FileUtils.mkdir_p File.dirname destination
69
74
  FileUtils.touch temp_dest
@@ -287,7 +292,7 @@ class MediaFile
287
292
  case typ
288
293
  when :m4a
289
294
  TagLib::MP4::File.open(file) do |f|
290
- return true if f.tag.item_list_map['covr'].to_cover_art_list.find do |p|
295
+ return true if f.tag.item_map['covr'].to_cover_art_list.find do |p|
291
296
  p.format == TagLib::MP4::CoverArt::JPEG
292
297
  end
293
298
  end
@@ -324,7 +329,7 @@ class MediaFile
324
329
  case @type
325
330
  when :m4a
326
331
  TagLib::MP4::File.open(@source) do |f|
327
- p = f.tag.item_list_map['covr'].to_cover_art_list.first
332
+ p = f.tag.item_map['covr'].to_cover_art_list.first
328
333
  p.data if p
329
334
  end
330
335
  when :flac
@@ -355,7 +360,7 @@ class MediaFile
355
360
  TagLib::MP4::File.open(file) do
356
361
  c = TagLib::MP4::CoverArt.new(TagLib::MP4::CoverArt::JPEG, cover_art)
357
362
  item = TagLib::MP4::Item.from_cover_art_list([c])
358
- file.tag.item_list_map.insert('covr', item)
363
+ file.tag.item_map.insert('covr', item)
359
364
  file.save
360
365
  end
361
366
  when :flac
@@ -396,7 +401,7 @@ class MediaFile
396
401
  case typ
397
402
  when :m4a
398
403
  TagLib::MP4::File.open(file) do |f|
399
- f.tag.item_list_map.insert("aART",
404
+ f.tag.item_map.insert("aART",
400
405
  TagLib::MP4::Item.from_string_list([@force_album_artist]))
401
406
  f.save
402
407
  end
@@ -476,11 +481,11 @@ class MediaFile
476
481
  case @type
477
482
  when :m4a
478
483
  TagLib::MP4::File.open(@source) do |file|
479
- @disc_number = file.tag.item_list_map["disk"] ?
480
- file.tag.item_list_map["disk"].to_int_pair[0] :
484
+ @disc_number = file.tag.item_map["disk"] ?
485
+ file.tag.item_map["disk"].to_int_pair[0] :
481
486
  nil
482
- @album_artist = file.tag.item_list_map["aART"] ?
483
- file.tag.item_list_map["aART"].to_string_list[0] :
487
+ @album_artist = file.tag.item_map["aART"] ?
488
+ file.tag.item_map["aART"].to_string_list[0] :
484
489
  @album_artist
485
490
  end
486
491
  when :flac
@@ -1,3 +1,3 @@
1
1
  module MediaFile
2
- VERSION = "0.2.13" unless defined?(::MediaFile::VERSION)
2
+ VERSION = "0.3.0" unless defined?(::MediaFile::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediafile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Harvey-Smith