autoaudio 0.0.3 → 0.0.4

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
2
  SHA1:
3
- metadata.gz: cec5b85de4f30b18b7eade498b1461f5c9c15747
4
- data.tar.gz: 369e5d5c2b9b3b0a1d28efb3662390ec1b5b35db
3
+ metadata.gz: 171b6ac2299bc99f246e08efe0f9dcb6cd65c86d
4
+ data.tar.gz: 4ff98406573ab4a6f98041f92e0c50fd7550bb8f
5
5
  SHA512:
6
- metadata.gz: c19f6ac9800dbc959f8809c5b03da6baa1e216406cb24fad5dc8d0899c10df7b612947997ed20ec261bd13ce14037a095e115e34ea41d868cd66e21bd6a17b54
7
- data.tar.gz: 925c4642159d6ab1a7228f62b59027d017a67fa70bbc81a602d7514e99ecfba23e2c11960e176bd80096d7830332a1912f7ee6436b076063ff3ec5e4e7429003
6
+ metadata.gz: f5eb67480752847ebc713230c708cdf36aac0690ed30339380c3fab6820f70a8c11ebc306c0ea951c250754bf3c12786315f2896a3f5bf119e8a5024ebd40046
7
+ data.tar.gz: fe4b1a730c4875c65a98341f72d8366d8d67c4be14acc2e8ba5d14759d7d01c020279aedc1c3096b600b55d3e489b917ac459610081e3a3c2ed4c51ee1cc0495
data/.gitignore CHANGED
@@ -16,13 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
 
19
- *.log
20
- .idea
21
- .DS_Store
22
- .DS_Store?
23
- ._*
24
- .Spotlight-V100
25
- .Trashes
26
- Thumbs.db
27
-
28
- tmp/*
19
+ hold/*
data/README.md CHANGED
@@ -1,43 +1,33 @@
1
1
  # Autoaudio
2
2
 
3
- Autoaudio parses [http://nfodb.net.ru/rss.php](http://nfodb.net.ru/rss.php) for the latest Scene audio releases. Then, it queries [http://nzbindex.nl/](http://nzbindex.nl/) for the release and creates an `.nzb`.
4
3
 
5
- Releases are sorted by genre and album title and folders are created which hold `.nfo` and `.nzb` files for each release. A zip is created of each folder and is uploaded to [https://anonfiles.com/](https://anonfiles.com/). The resulting list is uploaded as an anonymous gist. A file called `download.thor`, which is a tiny robot that parses the anonymous gist and redownloads the files from [https://anonfiles.com/](https://anonfiles.com/), is uploaded with the album links. Finally, the gist url is tweeted.
6
-
7
- ![alt text](https://raw.github.com/GeneLocklin/autoaudio/master/etc/aa.jpg "Autoaudio")
8
-
9
- ## Installation
10
-
11
- $ gem install autoaudio
12
-
13
- ## Usage
4
+ ## THESE INSTRUCTIONS ARE NO LONGER VALID. ```audioaudio list``` for a list of commands. Proper readme coming soon.
14
5
 
15
- Setings can be found in `/lib/autoaudio/settings.rb`. `NZB_DOWNLOAD_LOCATION` is where to set where you want to store your `.nzb` and `.nfo` files. `TWITTER_SETTINGS` has two options. Set `:tweet_nzbs` to true, if you want to tweet your results. And your Twitter username is stored in `:username`.
6
+ ### It's ugly as hell, but it 100% works.
16
7
 
17
- Autoaudio has a set of terminal commands:
8
+ ![alt text](https://raw.github.com/GeneLocklin/autoaudio/master/etc/aa.jpg "Autoaudio")
18
9
 
19
- * `autoaudio setup` Opens the config file in your editor of choice.
20
- * `autoaudio display_configuration_settings` Displays application configuration settings.
21
- * `autoaudio make_feeds` Downloads all feeds into the database.
22
- * `autoaudio display_feeds` Displays all feeds.
23
- * `autoaudio download` Downloads all feeds, creates `.nzb` and `.nfo` files, zips and uploads to [https://anonfiles.com/](https://anonfiles.com/), creates a list of upload urls and tweets an the url of anonymous gist containing the upload urls.
24
- * `autoaudio download_genre GENRE` <- Where GENRE is your chosen genre. This command will open a single genre's `.nzb` files in your chosen newsreader, and update the database to reflect the change.
10
+ Autoaudio parses [http://nfodb.net.ru/rss.php](http://nfodb.net.ru/rss.php) for the latest Scene audio releases. Then, it queries [http://nzbindex.nl/](http://nzbindex.nl/) for the release and creates a `.nzb`.
25
11
 
26
- If you wish to tweet your results, you will need to install and set up [t](https://github.com/sferik/t). Autoaudio will automatically set your Twitter username, before tweeting.
12
+ Releases are sorted by genre and album title and folders are created which hold `.nfo` and `.nzb` files for each release. A zip is created of each folder and is uploaded to [https://anonfiles.com/](https://anonfiles.com/). The resulting list is uploaded as an anonymous gist. A file called `download.thor`, which is a tiny robot that parses the anonymous gist and redownloads the files from [https://anonfiles.com/](https://anonfiles.com/), is uploaded with the album links. Finally, the gist url is tweeted.
27
13
 
28
- ## Gems Used
14
+ ## Gems Used:
29
15
 
30
- * [mongoid](https://github.com/mongoid/mongoid)
31
16
  * [mechanize](https://github.com/sparklemotion/mechanize/)
17
+ * [mongoid](https://github.com/mongoid/mongoid)
32
18
  * [gist](https://github.com/defunkt/gist)
33
19
  * [thor](https://github.com/erikhuda/thor)
34
- * [t](https://github.com/sferik/t)
20
+ * and, indirectly, [t](https://github.com/sferik/t)
21
+
22
+ ## Basic Usage:
23
+
24
+ Run `Thor list` for a list of basic commands.
35
25
 
36
26
  ## To do:
37
27
 
38
28
  * help
39
29
  * write a more understandable readme
40
- * add more thor commands as well as more descriptions
30
+ * add more thor commands as well as more and better descriptions
41
31
  * clean up the code - at the moment, it's a huge ball of crap
42
32
  * error handling
43
33
  * multithreading
@@ -47,7 +37,7 @@ If you wish to tweet your results, you will need to install and set up [t](https
47
37
  * more search and source options
48
38
  * [tor-privoxy](https://github.com/pirj/tor-privoxy)
49
39
 
50
- ## License
40
+ ## License:
51
41
 
52
42
  Copyright (c) 2014 Gene Locklin
53
43
 
@@ -72,7 +62,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
72
62
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
73
63
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
74
64
 
75
- ## Contributing
65
+ ## Contributing:
76
66
 
77
67
  1. Fork it
78
68
  2. Create your feature branch (`git checkout -b my-new-feature`)
data/Thorfile ADDED
@@ -0,0 +1,10 @@
1
+ $:.unshift File.expand_path("../lib", __FILE__)
2
+ $:.unshift File.expand_path("../config", __FILE__)
3
+
4
+ require 'settings'
5
+ require 'autoaudio'
6
+ require 'thor'
7
+
8
+ Dir.glob("./tasks/*.thor") { |name| Thor::Util.load_thorfile(name) }
9
+
10
+
data/autoaudio.gemspec CHANGED
@@ -20,10 +20,11 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = %w[lib]
21
21
 
22
22
  spec.add_dependency 'mechanize'
23
+ spec.add_dependency 'awesome_print'
23
24
  spec.add_dependency 'mongoid'
25
+ spec.add_dependency 'retries'
24
26
  spec.add_dependency 'thor'
25
27
  spec.add_dependency 'gist'
26
- spec.add_dependency 't'
27
28
 
28
29
  spec.add_development_dependency 'bundler', '~> 1.3'
29
30
  spec.add_development_dependency 'rake'
@@ -33,3 +34,6 @@ Gem::Specification.new do |spec|
33
34
  spec.add_development_dependency 'guard-bundler'
34
35
  end
35
36
 
37
+
38
+
39
+
data/bin/autoaudio CHANGED
@@ -2,4 +2,7 @@
2
2
 
3
3
  require 'autoaudio'
4
4
 
5
- Autoaudio::Cli::Application.start(ARGV)
5
+ Autoaudio::Cli.start(ARGV)
6
+
7
+
8
+
data/config/mongoid.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  development:
2
2
  sessions:
3
3
  default:
4
- database: autoaudio
4
+ database: atst2
5
5
  hosts:
6
6
  - localhost:27017
@@ -0,0 +1,13 @@
1
+ require 'autoaudio'
2
+
3
+ module Autoaudio
4
+ Settings.config do
5
+ download_location "#{Dir.home}/Downloads/Test/Albums"
6
+ maximum_retention 900
7
+ nzb_client 'Unison.app'
8
+ zip_files true
9
+ share_files true
10
+ tweet_files true
11
+ twitter_username 'usenetdecoded'
12
+ end
13
+ end
File without changes
File without changes
File without changes
data/lib/autoaudio.rb CHANGED
@@ -1,21 +1,35 @@
1
- require 'mechanize'
1
+ $:.unshift File.expand_path("../../config", __FILE__)
2
+ require 'autoaudio/settings_setup'
3
+ require 'settings'
4
+
5
+ require 'rubygems'
2
6
  require 'open-uri'
7
+ require 'date'
8
+
9
+ require 'thor'
3
10
  require 'mongoid'
4
- require 'gist'
5
- require 't'
11
+ require 'retries'
12
+ require 'nokogiri'
13
+ require 'mechanize'
14
+ require 'awesome_print'
15
+
16
+ require 'gist' if Autoaudio::Settings.share_files
6
17
 
7
18
  require 'autoaudio/version'
8
- require 'autoaudio/settings'
9
- require 'autoaudio/cli/application'
19
+ require 'autoaudio/utils'
20
+ require 'autoaudio/genre'
21
+ require 'autoaudio/release_date'
22
+ require 'autoaudio/release'
10
23
 
11
- require 'autoaudio/utility'
12
- require 'autoaudio/feed'
24
+ require 'autoaudio/setup'
25
+ require 'autoaudio/make'
13
26
  require 'autoaudio/download'
27
+ require 'autoaudio/destroy'
28
+ require 'autoaudio/stats'
29
+ require 'autoaudio/cli'
14
30
 
15
31
  module Autoaudio
16
- extend self
17
- Mongoid.load!("./config/mongoid.yml", :development)
32
+ Mongoid.load!('config/mongoid.yml', :development)
18
33
  end
19
34
 
20
35
 
21
-
@@ -0,0 +1,30 @@
1
+ module Autoaudio
2
+ class Cli < Thor
3
+ include Autoaudio::Utils
4
+
5
+ # unless Settings.initialized
6
+ # Setup.new.setup
7
+ # end
8
+
9
+ desc 'make SUBCOMMAND', 'make'
10
+ subcommand 'make', Autoaudio::Make
11
+
12
+ desc 'download SUBCOMMAND', 'download'
13
+ subcommand 'download', Autoaudio::Download
14
+
15
+ desc 'destroy SUBCOMMAND', 'destroy'
16
+ subcommand 'destroy', Autoaudio::Destroy
17
+
18
+ desc 'stats SUBCOMMAND', 'stats'
19
+ subcommand 'stats', Autoaudio::Stats
20
+
21
+ desc 'setup', 'setup'
22
+ subcommand 'setup', Autoaudio::Setup
23
+
24
+ desc 'list', 'list all autoaudio commands'
25
+ def list
26
+ system('thor list')
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,47 @@
1
+ require 'thor'
2
+
3
+ module Autoaudio
4
+ class Destroy < Thor
5
+
6
+ desc 'everything', 'destroys all genres, releases and release dates'
7
+ def everything
8
+ if yes?("Preparing to destroy Everything. Are you sure? [yN]")
9
+ invoke :genres
10
+ invoke :release_dates
11
+ invoke :releases
12
+ else
13
+ say "That's probably for the best..."
14
+ end
15
+ end
16
+
17
+ desc 'releases', 'destroys all releases'
18
+ def releases
19
+ if yes?("Preparing to destroy all releases. Are you sure? [yN]")
20
+ Release.destroy_all
21
+ say "BOOM!", :red
22
+ else
23
+ say "That's probably for the best..."
24
+ end
25
+ end
26
+
27
+ desc 'genres', 'destroys all genres'
28
+ def genres
29
+ if yes?("Preparing to destroy all genres. Are you sure? [yN]")
30
+ Genre.destroy_all
31
+ say "BOOM!", :red
32
+ else
33
+ say "That's probably for the best..."
34
+ end
35
+ end
36
+
37
+ desc 'release_dates', 'destroys all release dates'
38
+ def release_dates
39
+ if yes?("Preparing to destroy all release dates. Are you sure? [yN]")
40
+ ReleaseDate.destroy_all
41
+ say "BOOM!", :red
42
+ else
43
+ say "That's probably for the best..."
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,126 +1,181 @@
1
- require 'autoaudio/utility'
2
-
3
1
  module Autoaudio
4
- class Download
5
- extend Utility
6
- def self.album(feed)
7
-
8
- hash_regex = Regexp.new('\b[A-Za-z0-9]{32}\b')
9
- psydealer_regex = Regexp.new('PsyDealer')
10
- town_regex = Regexp.new('town\.ag')
11
- flac_regex = Regexp.new('a\.b\.flac|a\.b\.sounds\.flac')
12
-
13
- download_location = "#{Autoaudio::Config::NZB_DOWNLOAD_LOCATION[:directory]}/#{feed.genre_formatted}/#{sanitize_filename(feed.album_title)}"
14
- nzb = "#{download_location}/#{sanitize_filename(feed.album_title)}.nzb"
15
- nfo = "#{download_location}/#{sanitize_filename(feed.album_title)}.nfo"
16
- zip = "#{download_location}/#{sanitize_filename(feed.album_title)}.zip"
17
-
18
- agent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }
19
- cookie = HTTP::Cookie.new(
20
- :domain => 'nzbindex.nl',
21
- :name => "agreed",
22
- :value => "true",
23
- :path => '/',
24
- :expires => (Date.today + 1).to_s)
25
- agent.cookie_jar.add(cookie)
26
-
27
- page = agent.get('http://nzbindex.nl/')
28
- search_form = page.form
29
- search_form.q = feed.album_title
30
- results_page = agent.submit(search_form, search_form.buttons.first)
31
-
32
- if !feed.downloaded && results_page.links_with(:text => 'Download', :href => town_regex).any? do |link|
33
- agent.get(link.click).save! nzb
34
- puts success("Town = #{feed.album_title}")
35
- feed.update_attributes(
36
- downloaded: true,
37
- download_method: "Town",
38
- nzb: nzb
39
- )
2
+ class Download < Thor
3
+ include Autoaudio::Utils
4
+
5
+ desc 'download_releases LOGGER, DOWNLOAD ATTEMPTS', 'download nfo and nzb files LOGGER, DOWNLOAD ATTEMPTS'
6
+ def download_releases(logger="nolog", release_nzb_download_attempts=1)
7
+ if logger == "log"
8
+ if yes?("Do you want to wipe the old .log file? [yN]")
9
+ File.truncate('./log/agent.log', 0)
40
10
  end
41
11
  end
42
- if results_page.links_with(:text => 'Download', :href => hash_regex).any? do |link|
43
- search_term = hash_regex.match(link.href)
44
- page = agent.get("http://nzbindex.nl/groups/alt.binaries.inner-sanctum/?q=#{search_term}")
45
- form = page.form_with(:action => 'http://nzbindex.nl/download/')
46
- form.checkboxes.each { |checkbox| checkbox.check if hash_regex.match(checkbox.text) }
47
- form.submit.save! nzb
48
- puts success("inner-sanctum => #{hash_regex.match(link.href)} = #{feed.album_title}")
49
- feed.update_attributes(
50
- downloaded: true,
51
- download_method: "inner-sanctum #{hash_regex.match(link.href)}",
52
- nzb: nzb
53
- )
12
+ Make.new.releases
13
+ Release.where(release_nzb_downloaded: false, :release_nzb_download_attempts.lte => release_nzb_download_attempts).each do |release|
14
+ with_retries(:max_tries => 20, :base_sleep_seconds => 0.1, :max_sleep_seconds => 6.0) do
15
+ make_release(logger, release)
54
16
  end
55
17
  end
56
- if !feed.downloaded && results_page.links_with(:text => 'Download', :href => hash_regex).any? do |link|
18
+ gist_tweet_releases if Settings.share_files
19
+ say ""
20
+ say "Thank you. Come again.", :white
21
+ end
22
+
23
+ no_commands do
24
+ def make_release(logger, release)
25
+ hash_regex = Regexp.new('\b[A-Za-z0-9]{32}\b')
26
+ psydealer_regex = Regexp.new('PsyDealer')
27
+ town_regex = Regexp.new('town\.ag')
28
+ flac_regex = Regexp.new('a\.b\.flac|a\.b\.sounds\.flac|a\.b\.flacEFNet')
29
+
30
+ download_location = "#{Settings.download_location}/#{release.release_genre_formatted}/#{sanitize_filename(release.release_name)}"
31
+ nzb = "#{download_location}/#{sanitize_filename(release.release_name)}.nzb"
32
+ nfo = "#{download_location}/#{sanitize_filename(release.release_name)}.nfo"
33
+ zip = "#{download_location}/#{sanitize_filename(release.release_name)}.zip"
34
+
35
+ agent = Mechanize.new
36
+ agent.user_agent_alias = 'Mac Safari'
37
+ agent.log = Logger.new('./log/agent.log') if logger == "log"
38
+ cookie = HTTP::Cookie.new(
39
+ :domain => 'nzbindex.nl',
40
+ :name => "agreed",
41
+ :value => "true",
42
+ :path => '/',
43
+ :expires => (Date.today + 1).to_s)
44
+ agent.cookie_jar.add(cookie)
45
+
46
+ page = agent.get('http://nzbindex.nl/')
57
47
  search_form = page.form
58
- search_form.q = hash_regex.match(link.href)
48
+ search_form.q = release.release_name
59
49
  results_page = agent.submit(search_form, search_form.buttons.first)
60
- form = results_page.form_with(:action => 'http://nzbindex.nl/download/')
61
- form.checkboxes.each { |checkbox| checkbox.check if hash_regex.match(checkbox.text) }
62
- form.submit.save! nzb
63
- puts success("#{hash_regex.match(link.href)} = #{feed.album_title}")
64
- feed.update_attributes(
65
- downloaded: true,
66
- download_method: hash_regex.match(link.href),
67
- nzb: nzb
68
- )
50
+
51
+ if !release.release_nzb_downloaded && results_page.links_with(:text => 'Download', :href => hash_regex).any? do |link|
52
+ search_term = hash_regex.match(link.href)
53
+ page = agent.get("http://nzbindex.nl/groups/alt.binaries.inner-sanctum/?q=#{search_term}")
54
+ form = page.form_with(:action => 'http://nzbindex.nl/download/')
55
+ form.checkboxes.each { |checkbox| checkbox.check if hash_regex.match(checkbox.text) }
56
+ form.submit.save! nzb
57
+ say "inner-sanctum => #{hash_regex.match(link.href)} = #{release.release_name}", :green
58
+ release.update_attributes(
59
+ release_nzb_downloaded: true,
60
+ release_nzb_download_method: "inner-sanctum #{hash_regex.match(link.href)}",
61
+ release_nzb_location: nzb
62
+ )
63
+ end
69
64
  end
70
- end
71
- if !feed.downloaded && results_page.links_with(:text => 'Download', :href => psydealer_regex).any? do |link|
72
- agent.get(link.click).save! nzb
73
- puts success("Town = #{feed.album_title}")
74
- feed.update_attributes(
75
- downloaded: true,
76
- download_method: "Psydealer",
77
- nzb: nzb
78
- )
65
+
66
+ if !release.release_nzb_downloaded && results_page.links_with(:text => 'Download', :href => town_regex).any? do |link|
67
+ agent.get(link.click).save! nzb
68
+ say "Town = #{release.release_name}", :green
69
+ release.update_attributes(
70
+ release_nzb_release_nzb_downloaded: true,
71
+ release_nzb_download_method: "Town",
72
+ release_nzb_location: nzb
73
+ )
74
+ end
79
75
  end
80
- end
81
- if !feed.downloaded && results_page.links_with(:text => 'Download', :href => flac_regex).each do |link|
82
- form = results_page.form_with(:action => 'http://nzbindex.nl/download/')
83
- form.checkboxes.each { |checkbox| checkbox.check if flac_regex.match(link.href) }
84
- form.submit.save! nzb
85
- puts success("FLAC = #{feed.album_title}")
86
- feed.update_attributes(
87
- downloaded: true,
88
- download_method: "FLAC",
89
- nzb: nzb
90
- )
76
+
77
+ if !release.release_nzb_downloaded && results_page.links_with(:text => 'Download', :href => hash_regex).any? do |link|
78
+ search_form.q = hash_regex.match(link.href)
79
+ results_page = agent.submit(search_form, search_form.buttons.first)
80
+ form = results_page.form_with(:action => 'http://nzbindex.nl/download/')
81
+ form.checkboxes.each { |checkbox| checkbox.check if hash_regex.match(checkbox.text) }
82
+ form.submit.save! nzb
83
+ say "#{hash_regex.match(link.href)} = #{release.release_name}", :green
84
+ release.update_attributes(
85
+ release_nzb_downloaded: true,
86
+ release_nzb_download_method: "hash_regex #{hash_regex.match(link.href)}",
87
+ release_nzb_location: nzb
88
+ )
89
+ end
90
+ end
91
+
92
+ if !release.release_nzb_downloaded && results_page.links_with(:text => 'Download', :href => psydealer_regex).any? do |link|
93
+ agent.get(link.click).save! nzb
94
+ say "Psydealer = #{release.release_name}", :green
95
+ release.update_attributes(
96
+ release_nzb_downloaded: true,
97
+ release_nzb_download_method: "Psydealer",
98
+ release_nzb_location: nzb
99
+ )
100
+ end
101
+ end
102
+
103
+ if !release.release_nzb_downloaded && results_page.links_with(:text => 'Download', :href => flac_regex).each do |link|
104
+ form = results_page.form_with(:action => 'http://nzbindex.nl/download/')
105
+ form.checkboxes.each { |checkbox| checkbox.check if flac_regex.match(link.href) }
106
+ form.submit.save! nzb
107
+ say "FLAC = #{release.release_name}", :green
108
+ release.update_attributes(
109
+ release_nzb_downloaded: true,
110
+ release_nzb_download_method: "FLAC",
111
+ release_nzb_location: nzb
112
+ )
113
+ end
114
+ end
115
+
116
+ if !release.release_nzb_downloaded
117
+ release.update_attribute(:release_nzb_download_attempts, (release.release_nzb_download_attempts + 1))
118
+ say "NOPE = #{release.release_name}", :red
119
+ end
120
+
121
+ # ToDo: from here down, rewrite.
122
+
123
+ if release.release_nzb_downloaded
124
+ nfo_agent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }
125
+ nfo_page = nfo_agent.get("http://nfodb.net.ru/get_nfo-#{release.release_number}.php")
126
+ nfo_page.save! nfo
127
+ say ".nfo created - #{release.release_name}", :green
128
+ release.update_attributes(
129
+ release_nfo_downloaded: true,
130
+ release_nfo_location: nfo
131
+ )
91
132
  end
92
- end
93
- if !feed.downloaded
94
- feed.update_attribute(:download_attempts, (feed.download_attempts + 1))
95
- puts failure("NOPE = #{feed.album_title}")
96
- end
97
133
 
98
- if feed.downloaded
99
- nfo_agent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }
100
- nfo_page = nfo_agent.get("http://nfodb.net.ru/get_nfo-#{feed.release_number}.php")
101
- nfo_page.save! nfo
102
- puts success(".nfo created - #{feed.album_title}")
103
- feed.update_attribute(:nfo, nfo)
134
+ if release.release_nzb_downloaded && release.release_nfo_downloaded
135
+ system("zip -vjr #{zip} #{download_location}/* -x \"*.DS_Store\"" )
136
+ release.update_attributes(
137
+ release_zip_location: zip,
138
+ release_zip_created: true
139
+ )
140
+ say ".zip created - #{release.release_name}", :green
141
+ end
142
+
143
+ if release.release_zip_created
144
+ reply = './etc/reply.txt'
145
+ system("curl -kF \"file=@#{zip}\" https://anonfiles.com/api/v1/upload -o \"#{reply}\"")
146
+ zip_location = IO.readlines(reply)[0]
147
+ anon_hash = /\b[A-Za-z0-9]{32}\b/.match(zip_location)
148
+ release.update_attribute(:release_zip_uploaded_url, "https://anonfiles.com/file/#{anon_hash}")
149
+ say "#{release.release_name} = https://anonfiles.com/file/#{anon_hash}", :green
150
+ File.open('./etc/gist.txt', 'a') { |f| f.write "* #{release.release_name} = https://anonfiles.com/file/#{anon_hash}\n" }
151
+ File.truncate(reply, 0)
152
+ end
104
153
  end
105
154
 
106
- if feed.nzb && feed.nfo
107
- system("zip -vjr #{zip} #{download_location}/* -x \"*.DS_Store\"" )
108
- feed.update_attribute(:zip, zip)
109
- puts success(".zip created - #{feed.album_title}")
110
-
111
- reply = './log/reply.txt'
112
- system("curl -kF \"file=@#{zip}\" https://anonfiles.com/api/hotlink -o \"#{reply}\"")
113
- zip_location = IO.readlines(reply)[0]
114
- anon_hash = /\b[A-Za-z0-9]{32}\b/.match(zip_location)
115
- feed.update_attribute(:zip_uploaded_url, "https://anonfiles.com/file/#{anon_hash}")
116
- puts success("#{feed.album_title} = https://anonfiles.com/file/#{anon_hash}")
117
- if Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs] == true
118
- write_gist("#{feed.album_title} = https://anonfiles.com/file/#{anon_hash}")
155
+ def gist_tweet_releases
156
+ unless File.zero?('./etc/gist.txt')
157
+ system("gist -c -p -d \"#{DateTime.now}\" -f \"#{DateTime.now}\" './etc/gist.txt' -f download.thor './etc/download.thor'")
158
+ system("t set active \"#{Settings.twitter_username}\"")
159
+ system("t update `pbpaste`")
160
+ File.truncate('./etc/gist.txt', 0)
119
161
  end
120
- File.truncate(reply, 0)
121
162
  end
163
+ end
122
164
 
165
+ desc 'open_nzbs GENRE AUDIO_FORMAT', 'Download a specific genre\'s .nzb\'s. Defaults to FLAC and MP3'
166
+ def open_nzbs(release_genre_formatted, release_audio_format="MP3|FLAC")
167
+ Release.where(
168
+ release_audio_format: %r(#{release_audio_format}),
169
+ release_genre_formatted: release_genre_formatted,
170
+ release_nzb_opened: false
171
+ ).each do |release|
172
+ system("open #{release.release_nzb_location}")
173
+ release.update_attribute(:release_nzb_opened, true)
174
+ say "#{release.release_name}", :cyan
175
+ end
123
176
  end
124
177
 
125
178
  end
126
179
  end
180
+
181
+
@@ -0,0 +1,14 @@
1
+ module Autoaudio
2
+
3
+ class Genre
4
+ include Autoaudio::Utils
5
+ include Mongoid::Document
6
+
7
+ field :genre_name, type: String
8
+ field :genre_name_formatted, type: String, default: -> { format_string(self.genre_name) }
9
+ field :genre_number, type: Integer
10
+ field :genre_url, type: String, default: -> { "http://nfodb.net.ru/index.php?genreid=#{self.genre_number}" }
11
+ field :genre_rss_url, type: String, default: -> { "http://nfodb.net.ru/rss.php?type=#{self.genre_number}" }
12
+ end
13
+
14
+ end
@@ -0,0 +1,102 @@
1
+ module Autoaudio
2
+ class Make < Thor
3
+ include Autoaudio::Utils
4
+
5
+ desc 'releases', 'make all releases'
6
+ method_option :initial, :type => :boolean, :aliases => "-i"
7
+ def releases
8
+ if options.initial?
9
+ if yes?("This could take quite a while. Are you sure? [yN]")
10
+ say "Making Genres...", :white
11
+ say ""
12
+ say ""
13
+ genres
14
+ say "Making Release Dates...", :white
15
+ say ""
16
+ say ""
17
+ release_dates
18
+ say "Making Releases...", :white
19
+ say ""
20
+ say ""
21
+ ReleaseDate.each { |release_date| parse_single_page(release_date.release_date_url) }
22
+ end
23
+ end
24
+ say "Parsing Latest Feed...", :white
25
+ say ""
26
+ say ""
27
+ parse_feed
28
+ if options.initial?
29
+ say "Phew..."
30
+ end
31
+ end
32
+
33
+ desc 'genres', 'makes all genres'
34
+ def genres
35
+ doc = Nokogiri::HTML(open('http://nfodb.net.ru/index.php?genreid=0'))
36
+ doc.xpath('//*[@id="content"]/div[1]/form/select').children.map do |child|
37
+ unless Genre.where(genre_name: child.text).exists?
38
+ genre = Genre.create(
39
+ :genre_name => child.text,
40
+ :genre_number => child['value']
41
+ )
42
+ say "#{genre}", :green
43
+ end
44
+ end
45
+ end
46
+
47
+ desc 'release_dates', 'makes all release dates'
48
+ def release_dates
49
+ doc = Nokogiri::HTML(open("http://nfodb.net.ru/"))
50
+ doc.xpath('//*[@id="content"]/form[2]/select').children.map do |child|
51
+ unless ReleaseDate.where(release_date_string: child.text).exists?
52
+ release_date_string = child.text
53
+ r_date = Date.parse(child.text.gsub(/\./, '-'))
54
+ max_r_date = Date.today - Settings.maximum_retention
55
+ if r_date > max_r_date
56
+ release_date = ReleaseDate.create(
57
+ :release_date_string => release_date_string,
58
+ :release_date => r_date
59
+ )
60
+ say "#{release_date}", :green
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ no_commands do
67
+ def parse_single_page(url="http://nfodb.net.ru/")
68
+ doc = Nokogiri::HTML(open(url))
69
+ release_row = doc.css("html > body > div:nth-of-type(4) > div > table > tr").map do |r|
70
+ unless r.css('td:nth-of-type(2) > a').empty?
71
+ unless Release.where(release_name: r.css('td:nth-of-type(2) > a').text).exists?
72
+ release = Release.create(
73
+ :release_name => r.css('td:nth-of-type(2) > a').text,
74
+ :release_date => Date.parse(r.css('td:nth-of-type(1) > b').text.gsub(/\./, '-')),
75
+ :release_genre => r.css('td:nth-of-type(3) > a').text,
76
+ :release_number => r.css('td:nth-of-type(5) > a').map { |a| a['href'].match(/get_nfo-(.*?)\.php/)[1] }.join
77
+ )
78
+ say "#{release}", :green
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ def parse_feed
85
+ doc = Nokogiri::XML(open("http://nfodb.net.ru/rss.php"))
86
+ doc.search('item').map do |doc_item|
87
+ unless Release.where(release_name: doc_item.at('title').text.gsub(/\[(.*?)\]./, '')).exists?
88
+ release = Release.create(
89
+ :release_name => doc_item.at('title').text.gsub(/\[(.*?)\]./, ''),
90
+ :release_date => Date.parse(doc_item.at('description').text.gsub(/Date:./,'').gsub(/\./, '-')),
91
+ :release_genre => doc_item.at('title').text[/[^\[]+[^\\]\]/].gsub(/[\[(.*?)\]]/,''),
92
+ :release_number => doc_item.at('link').text.match(/(http:\/\/nfodb.net.ru\/nfo-)(.*?)(.html)/)[2]
93
+ )
94
+ say "#{release}", :green
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+
101
+ end
102
+ end
@@ -0,0 +1,30 @@
1
+ module Autoaudio
2
+
3
+ class Release
4
+ include Autoaudio::Utils
5
+ include Mongoid::Document
6
+ include Mongoid::Timestamps
7
+
8
+ field :release_name, type: String
9
+ field :release_date, type: Date
10
+ field :release_genre, type: String
11
+ field :release_genre_formatted, type: String, default: -> { format_string(self.release_genre) }
12
+ field :release_number, type: Integer
13
+ field :release_nfo_url, type: String, default: -> { "http://nfodb.net.ru/get_nfo-#{self.release_number}.php" }
14
+ field :release_audio_format, type: String, default: -> { test_audio_format(self.release_name) }
15
+
16
+ field :release_nfo_downloaded, type: Boolean, default: false
17
+ field :release_nfo_location, type: String, default: nil
18
+
19
+ field :release_nzb_downloaded, type: Boolean, default: false
20
+ field :release_nzb_location, type: String, default: nil
21
+ field :release_nzb_download_method, type: String, default: nil
22
+ field :release_nzb_download_attempts, type: Integer, default: 0
23
+ field :release_nzb_opened, type: Boolean, default: false
24
+
25
+ field :release_zip_location, type: String, default: nil
26
+ field :release_zip_uploaded_url, type: String, default: nil
27
+ field :release_zip_created, type: Boolean, default: false
28
+ end
29
+
30
+ end
@@ -0,0 +1,11 @@
1
+ module Autoaudio
2
+
3
+ class ReleaseDate
4
+ include Mongoid::Document
5
+
6
+ field :release_date_string, type: String
7
+ field :release_date, type: Date
8
+ field :release_date_url, type: String, default: -> { "http://nfodb.net.ru/index.php?rlsday=#{self.release_date_string}&do_search=Show" }
9
+
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ module Autoaudio
2
+
3
+ module Settings
4
+ extend self
5
+
6
+ def parameter(*names)
7
+ names.each do |name|
8
+ attr_accessor name
9
+
10
+ define_method name do |*values|
11
+ value = values.first
12
+ value ? self.send("#{name}=", value) : instance_variable_get("@#{name}")
13
+ end
14
+ end
15
+ end
16
+
17
+ def config(&block)
18
+ instance_eval &block
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ Autoaudio::Settings.config do
25
+ parameter :download_location
26
+ parameter :maximum_retention
27
+ parameter :nzb_client
28
+ parameter :zip_files
29
+ parameter :share_files
30
+ parameter :tweet_files
31
+ parameter :twitter_username
32
+ end
33
+
@@ -0,0 +1,25 @@
1
+ module Autoaudio
2
+ class Setup < Thor
3
+
4
+ desc 'setup', 'initial settings'
5
+ def setup
6
+ if yes?("Autoaudio is not initialized. Do you want to enter settings now? [yN]")
7
+ # say ""
8
+ # say "instructions:"
9
+ # say ""
10
+ # say ""
11
+ # say "Change initialized to true"
12
+ # say ""
13
+ # say "download_location is where your nfo and nzb files will go"
14
+ # say "maximum_retention is how long your usenet provider holds on to files"
15
+ # say "nzb_client is, um, your nzb client"
16
+ # say "zip files, zips files"
17
+ # say "share_files allows your nzbs and nfo files to be gisted and tweeted"
18
+ # say "tweet_files, tweets files"
19
+ # say "twitter_username is your twitter username"
20
+ system("open './config/settings.rb'")
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ module Autoaudio
2
+ class Stats < Thor
3
+
4
+ desc 'audio_format_count', 'audio format count'
5
+ def audio_format_count
6
+ puts "#{Release.count} Releases"
7
+ puts "#{Release.where(release_audio_format: 'MP3').count} MP3 Releases"
8
+ puts "#{Release.where(release_audio_format: 'FLAC').count} FLAC Releases"
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ module Autoaudio
2
+ module Utils
3
+ def write_gist(string)
4
+ File.open('./log/gist.txt', 'a') { |f| f.write "* #{string}\n" }
5
+ end
6
+
7
+ def sanitize_filename(filename)
8
+ fn = filename.split(/(?<=.)\.(?=[^.])(?!.*\.[^.])/m)
9
+ fn.map! { |s| s.gsub( /[^a-z0-9\-]+/i, '_') }
10
+ return fn.join('.')
11
+ end
12
+
13
+ def test_audio_format(string)
14
+ string = string.dup
15
+ string.match(/FLAC/) ? string = "FLAC" : string = "MP3"
16
+ end
17
+
18
+ def format_string(string)
19
+ string = string.dup
20
+ string.gsub!(/&/, '_and_') if string.match(/\w&\w/)
21
+ string.gsub!(/\+/, '_and_')
22
+ string.gsub!(/&/, 'and')
23
+ string.gsub!(/-/, '_')
24
+ string.gsub!(/ / ,'_')
25
+ string.downcase!
26
+ string
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Autoaudio
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/log/.gitkeep ADDED
File without changes
data/tasks/gem.thor ADDED
@@ -0,0 +1,22 @@
1
+ require 'bundler'
2
+
3
+ class Gem < Thor
4
+ include Thor::RakeCompat
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ desc 'build', "Build autoaudio-#{Autoaudio::VERSION}.gem into the pkg directory"
8
+ def build
9
+ Rake::Task['build'].execute
10
+ end
11
+
12
+ desc 'install', "Build and install autoaudio-#{Autoaudio::VERSION}.gem into system gems"
13
+ def install
14
+ Rake::Task['install'].execute
15
+ end
16
+
17
+ desc 'release', "Create tag v#{Autoaudio::VERSION} and build and push autoaudio-#{Autoaudio::VERSION}.gem to Rubygems"
18
+ def release
19
+ Rake::Task['release'].execute
20
+ end
21
+ end
22
+
data/tasks/tests.thor ADDED
@@ -0,0 +1,7 @@
1
+ class Tests < Thor
2
+
3
+ desc 'empty_test', 'empty test'
4
+ def empty_test
5
+ end
6
+
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoaudio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene Locklin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-18 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: awesome_print
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: mongoid
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: thor
56
+ name: retries
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: gist
70
+ name: thor
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: t
84
+ name: gist
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -176,21 +190,31 @@ files:
176
190
  - Gemfile
177
191
  - LICENSE.txt
178
192
  - README.md
179
- - Rakefile
193
+ - Thorfile
180
194
  - autoaudio.gemspec
181
195
  - bin/autoaudio
182
196
  - config/mongoid.yml
183
- - etc/aa.jpg
197
+ - config/settings.rb
184
198
  - etc/download.thor
199
+ - etc/gist.txt
200
+ - etc/reply.txt
201
+ - images/aa.jpg
185
202
  - lib/autoaudio.rb
186
- - lib/autoaudio/cli/application.rb
203
+ - lib/autoaudio/cli.rb
204
+ - lib/autoaudio/destroy.rb
187
205
  - lib/autoaudio/download.rb
188
- - lib/autoaudio/feed.rb
189
- - lib/autoaudio/settings.rb
190
- - lib/autoaudio/utility.rb
206
+ - lib/autoaudio/genre.rb
207
+ - lib/autoaudio/make.rb
208
+ - lib/autoaudio/release.rb
209
+ - lib/autoaudio/release_date.rb
210
+ - lib/autoaudio/settings_setup.rb
211
+ - lib/autoaudio/setup.rb
212
+ - lib/autoaudio/stats.rb
213
+ - lib/autoaudio/utils.rb
191
214
  - lib/autoaudio/version.rb
192
- - log/gist.txt
193
- - log/reply.txt
215
+ - log/.gitkeep
216
+ - tasks/gem.thor
217
+ - tasks/tests.thor
194
218
  homepage: https://github.com/GeneLocklin/autoaudio
195
219
  licenses:
196
220
  - MIT
@@ -211,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
235
  version: '0'
212
236
  requirements: []
213
237
  rubyforge_project:
214
- rubygems_version: 2.1.11
238
+ rubygems_version: 2.2.2
215
239
  signing_key:
216
240
  specification_version: 4
217
241
  summary: Automatically download scene .nfo and .nzb files
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,83 +0,0 @@
1
- require 'thor'
2
-
3
- module Autoaudio
4
- module Cli
5
- class Application < Thor
6
-
7
- desc 'setup', 'Opens the application settings'
8
- def setup
9
- system("open #{File.expand_path("../../settings.rb", __FILE__)}")
10
- end
11
-
12
- desc 'display_configuration_settings', 'Displays the application configuration settings'
13
- def display_configuration_settings
14
- puts "Autoaudio::VERSION = #{Autoaudio::VERSION}"
15
- puts "Download location = #{Autoaudio::Config::NZB_DOWNLOAD_LOCATION[:directory]}"
16
- puts "Tweet = #{Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs]}"
17
- if Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs] == true
18
- puts "Twitter Username = #{Autoaudio::Config::TWITTER_SETTINGS[:username]}"
19
- end
20
- end
21
-
22
- desc 'make_feeds', 'Make all feeds'
23
- def make_feeds
24
- Feed.make
25
- end
26
-
27
- desc 'destroy_feeds', 'Destroy all feeds'
28
- def destroy_feeds
29
- Feed.destroy_all
30
- end
31
-
32
- desc 'count_feeds', 'Count all feeds'
33
- def count_feeds
34
- Feed.count
35
- end
36
-
37
- desc 'display_feeds', 'Display all feeds'
38
- def display_feeds
39
- Feed.each { |f| pp f }
40
- end
41
-
42
- desc 'download', 'Downloads all feeds'
43
- def download
44
- Feed.make
45
- feeds = Feed.where(downloaded: false).each.to_a
46
- i = (feeds.length / 5)
47
- while i > 0
48
- new_array = Array.new
49
- 5.times do
50
- new_array << feeds.pop
51
- end
52
- new_array.each { |feed| Download.album(feed) }
53
- sleep 20
54
- i -= 1
55
- end
56
- unless File.zero?('./log/gist.txt')
57
- system("gist -c -p -d \"#{DateTime.now}\" -f \"#{DateTime.now}\" './log/gist.txt' -f download.thor './etc/download.thor'")
58
- if Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs] == true
59
- system("t set active #{Autoaudio::Config::TWITTER_SETTINGS[:username]}")
60
- system("t update `pbpaste`")
61
- end
62
- end
63
- File.truncate('./log/gist.txt', 0)
64
- end
65
-
66
- desc 'download_genre GENRE', 'Download a specific genre'
67
- def download_genre(genre_formatted)
68
- genre = Feed.where(
69
- # audio_format: "MP3",
70
- genre_formatted: genre_formatted,
71
- nzb_opened: false
72
- )
73
- genre.each do |feed|
74
- if feed.nzb != nil
75
- system("open #{feed.nzb}")
76
- feed.update_attribute(:nzb_opened, true)
77
- end
78
- end
79
- end
80
-
81
- end
82
- end
83
- end
@@ -1,77 +0,0 @@
1
- module Autoaudio
2
- class Feed
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
-
6
- field :release_date, type: DateTime
7
- field :release_number, type: Integer
8
- field :genre, type: String
9
- field :genre_formatted, type: String
10
- field :album_title, type: String
11
- field :downloaded, type: Boolean
12
- field :download_attempts, type: Integer
13
- field :download_method, type: String
14
- field :audio_format, type: String
15
- field :nzb, type: String
16
- field :nzb_opened, type: Boolean
17
- field :nfo, type: String
18
- field :zip, type: String
19
- field :zip_uploaded_url, type: String
20
-
21
- def self.make
22
- feeds = parse
23
- feeds.each do |f|
24
- unless Feed.where(album_title: f[:album]).exists?
25
- feed = Feed.create(
26
- :release_date => f[:date],
27
- :release_number => f[:release_number],
28
- :genre => f[:genre],
29
- :genre_formatted => format_string(f[:genre]),
30
- :album_title => f[:album],
31
- :downloaded => false,
32
- :download_attempts => 0,
33
- :download_method => nil,
34
- :audio_format => test_audio_format(f[:album]),
35
- :nzb => nil,
36
- :nzb_opened => false,
37
- :nfo => nil,
38
- :zip => nil,
39
- :zip_uploaded_url => nil
40
- )
41
- feed.save
42
- end
43
- end
44
- end
45
-
46
- class << self
47
- private
48
-
49
- def parse(feed="http://nfodb.net.ru/rss.php")
50
- doc = Nokogiri::XML(open(feed))
51
- doc.search('item').map do |doc_item|
52
- item = {}
53
- item[:link] = doc_item.at('link').text
54
- item[:album] = doc_item.at('title').text.gsub(/\[(.*?)\]./, '')
55
- item[:genre] = doc_item.at('title').text[/[^\[]+[^\\]\]/].gsub(/[\[(.*?)\]]/,'')
56
- item[:date] = doc_item.at('description').text.gsub(/Date:./,'')
57
- item[:release_number] = doc_item.at('link').text.match(/(http:\/\/nfodb.net.ru\/nfo-)(.*?)(.html)/)[2]
58
- item
59
- end
60
- end
61
- def format_string(string)
62
- string = string.dup
63
- string.gsub!(/&/, '_and_') if string.match(/\w&\w/)
64
- string.gsub!(/\+/, '_and_')
65
- string.gsub!(/&/, 'and')
66
- string.gsub!(/-/, '_')
67
- string.gsub!(/ / ,'_')
68
- string.downcase!
69
- string
70
- end
71
- def test_audio_format(string)
72
- string = string.dup
73
- string.match(/FLAC/) ? string = "FLAC" : string = "MP3"
74
- end
75
- end
76
- end
77
- end
@@ -1,6 +0,0 @@
1
- module Autoaudio
2
- module Config
3
- NZB_DOWNLOAD_LOCATION = {:directory => "#{Dir.home}/Downloads/Albums"}
4
- TWITTER_SETTINGS = {:tweet_nzbs => true, :username => 'usenetdecoded'}
5
- end
6
- end
@@ -1,24 +0,0 @@
1
- require 'autoaudio'
2
-
3
- module Utility
4
-
5
- def success(string)
6
- %Q(\e[32m#{string}\e[0m)
7
- end
8
-
9
- def failure(string)
10
- %Q(\e[1;41;37m#{string}\e[0m)
11
- end
12
-
13
- def write_gist(string)
14
- File.open('./log/gist.txt', 'a') { |f| f.write "* #{string}\n" }
15
- end
16
-
17
- def sanitize_filename(filename)
18
- fn = filename.split(/(?<=.)\.(?=[^.])(?!.*\.[^.])/m)
19
- fn.map! { |s| s.gsub( /[^a-z0-9\-]+/i, '_') }
20
- return fn.join('.')
21
- end
22
-
23
- end
24
-