soundyoink 0.0.4 → 1.0.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 +4 -4
- data/lib/soundyoink/audio.rb +15 -4
- data/lib/soundyoink/downloader.rb +3 -5
- data/lib/soundyoink.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eec0cd3b652fda1750336c78d610dfe14bddf26e
|
4
|
+
data.tar.gz: 6c246193603c0f2aa4bcb574a465ea4632dacd6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc595f9a7118ad868f90529152fb65a135ce7e2b11be197449ac854d09171e9a42c5a59630ccdc652a83198358bc300d6b4eaf64a682d621b012236bcc84319c
|
7
|
+
data.tar.gz: b35137528abfad76258a7cc331f1b4baab3da96617e44f17ed85bebe3346fe93538b1b3b19fffd6ad70def1866cb38e9d7077720edb3fc0502be6a77e0e34567
|
data/lib/soundyoink/audio.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
module Soundyoink
|
2
|
-
|
3
2
|
# Represents an audio post; given only a link, can name the file intelligently
|
4
3
|
# and write it to disk, as well as check whether the file has already been
|
5
4
|
# downloaded.
|
6
5
|
class Audio
|
7
|
-
|
8
6
|
# Drawing the title from the URL is a little uglier than drawing it from
|
9
7
|
# the page text itself, but lets us skip files we already have without
|
10
8
|
# having to request the page. This saves a ton of time on user profiles.
|
@@ -22,10 +20,23 @@ module Soundyoink
|
|
22
20
|
# it already exists and is over 10 KB.
|
23
21
|
def download
|
24
22
|
return nil if already_exists?
|
25
|
-
|
23
|
+
bar = ProgressBar.create(title: 'Downloading',
|
24
|
+
length: 70,
|
25
|
+
format: '%t |%B| %p%')
|
26
|
+
filesize = nil
|
27
|
+
puts @filename
|
28
|
+
target = open(@file_url, 'rb',
|
29
|
+
content_length_proc: -> (size) { filesize = size },
|
30
|
+
progress_proc: lambda do |accumulated|
|
31
|
+
bar.progress = (accumulated.to_f / filesize * 100).to_i
|
32
|
+
end
|
33
|
+
)
|
26
34
|
File.open(@filename, 'wb') do |f|
|
27
|
-
|
35
|
+
while chunk = target.read(1000)
|
36
|
+
f.write(chunk)
|
37
|
+
end
|
28
38
|
end
|
39
|
+
puts "\n"
|
29
40
|
end
|
30
41
|
|
31
42
|
# Check that not only does the file exist, but that it is over 10 KB, so
|
@@ -3,7 +3,7 @@ module Soundyoink
|
|
3
3
|
# create many Audio instances from a user profile link.
|
4
4
|
class Downloader
|
5
5
|
# @param workers [Integer] Number of download threads to run in parallel.
|
6
|
-
def initialize(workers:
|
6
|
+
def initialize(workers: 1)
|
7
7
|
@audios = Queue.new
|
8
8
|
@workers = workers
|
9
9
|
end
|
@@ -23,10 +23,8 @@ module Soundyoink
|
|
23
23
|
# @param profile [String] Link to a user's profile page.
|
24
24
|
def add_profile(profile)
|
25
25
|
open(profile).read
|
26
|
-
|
27
|
-
|
28
|
-
@audios << Audio.new(a)
|
29
|
-
end
|
26
|
+
.scan(%r{(https://[^.]+[.]net/u/[^"]+)})
|
27
|
+
.flatten.map { |a| @audios << Audio.new(a) }
|
30
28
|
end
|
31
29
|
|
32
30
|
# +@workers+ number of threads work on the +@audios+ queue in parallel.
|
data/lib/soundyoink.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soundyoink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Plant
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Command-line utility for downloading SG material, either specific titles
|
14
14
|
or entire user histories.
|