autoaudio 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +86 -0
- data/Thorfile +29 -0
- data/autoaudio.gemspec +35 -0
- data/bin/autoaudio +5 -0
- data/config/mongoid.yml +6 -0
- data/etc/aa.jpg +0 -0
- data/etc/download.thor +24 -0
- data/lib/autoaudio.rb +21 -0
- data/lib/autoaudio/cli/application.rb +73 -0
- data/lib/autoaudio/download.rb +126 -0
- data/lib/autoaudio/feed.rb +77 -0
- data/lib/autoaudio/settings.rb +6 -0
- data/lib/autoaudio/utility.rb +24 -0
- data/lib/autoaudio/version.rb +3 -0
- data/log/gist.txt +0 -0
- data/log/reply.txt +0 -0
- metadata +218 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f246e56c1fb76a81a197843e8701ba0be372a443
|
4
|
+
data.tar.gz: 1cefafcdbbe19f503e1011400ae26d6055f02f0e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b99ffc1308814a18ae8eb3c5eaf161df25cbb94788bf45a7b6372709c89874f5b1f2628e973d968e9ee764ffa8b78ef4be334614c4f959248e46913d8b7d6d9
|
7
|
+
data.tar.gz: 0c3945c6592fa8ca79e02aa98e97dd2973ff41e4ff252cfbc44ed61f4bbcd7e93983276c3ceeb5c87648a3b44531b2a2014481c612a8d1a1f0530f4c77b4142e
|
data/.gitignore
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
|
19
|
+
*.log
|
20
|
+
.idea
|
21
|
+
.DS_Store
|
22
|
+
.DS_Store?
|
23
|
+
._*
|
24
|
+
.Spotlight-V100
|
25
|
+
.Trashes
|
26
|
+
Thumbs.db
|
27
|
+
|
28
|
+
tmp/*
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Gene Locklin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Autoaudio
|
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
|
+
|
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
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'autoaudio'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install autoaudio
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
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`.
|
24
|
+
|
25
|
+
Autoaudio has a set of terminal commands:
|
26
|
+
|
27
|
+
* `display_configuration_settings` Displays application configuration settings
|
28
|
+
* `make_feeds` Downloads all feeds into the database
|
29
|
+
* `display_feeds` Displays all feeds
|
30
|
+
* `destroy_feeds` Destroys all feeds
|
31
|
+
* `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.
|
32
|
+
* `download_genre GENRE` This command will open a single genre's `.nzb` files in your chosen newsreader, and update the database to reflect the change.
|
33
|
+
|
34
|
+
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.
|
35
|
+
|
36
|
+
## Gems Used
|
37
|
+
* [mongoid](https://github.com/mongoid/mongoid)
|
38
|
+
* [mechanize](https://github.com/sparklemotion/mechanize/)
|
39
|
+
* [gist](https://github.com/defunkt/gist)
|
40
|
+
* [thor](https://github.com/erikhuda/thor)
|
41
|
+
* [t](https://github.com/sferik/t)
|
42
|
+
|
43
|
+
## To do:
|
44
|
+
|
45
|
+
* write a more understandable readme
|
46
|
+
* clean up the code - at the moment, it's a huge ball of crap
|
47
|
+
* error handling
|
48
|
+
* multithreading
|
49
|
+
* tests
|
50
|
+
* include a launchd plst for for running locally
|
51
|
+
* more upload options
|
52
|
+
* more search and source options
|
53
|
+
* [tor-privoxy](https://github.com/pirj/tor-privoxy)
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
Copyright (c) 2014 Gene Locklin
|
58
|
+
|
59
|
+
MIT License
|
60
|
+
|
61
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
62
|
+
a copy of this software and associated documentation files (the
|
63
|
+
"Software"), to deal in the Software without restriction, including
|
64
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
65
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
66
|
+
permit persons to whom the Software is furnished to do so, subject to
|
67
|
+
the following conditions:
|
68
|
+
|
69
|
+
The above copyright notice and this permission notice shall be
|
70
|
+
included in all copies or substantial portions of the Software.
|
71
|
+
|
72
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
73
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
74
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
75
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
76
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
77
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
78
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
1. Fork it
|
83
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
84
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
85
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
86
|
+
5. Create new Pull Request
|
data/Thorfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
require 'thor/rake_compat'
|
5
|
+
|
6
|
+
class Default < Thor
|
7
|
+
include Thor::RakeCompat
|
8
|
+
Bundler::GemHelper.install_tasks
|
9
|
+
|
10
|
+
desc 'build', "Build autoaudio-#{Autoaudio::VERSION}.gem into the pkg directory"
|
11
|
+
def build
|
12
|
+
Rake::Task['build'].execute
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'install', "Build and install autoaudio-#{Autoaudio::VERSION}.gem into system gems"
|
16
|
+
def install
|
17
|
+
Rake::Task['install'].execute
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'release', "Create tag v#{Autoaudio::VERSION} and build and push autoaudio-#{Autoaudio::VERSION}.gem to Rubygems"
|
21
|
+
def release
|
22
|
+
Rake::Task['release'].execute
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'spec', 'Run RSpec code examples - These don\'t exist yet...'
|
26
|
+
def spec
|
27
|
+
exec 'rspec spec'
|
28
|
+
end
|
29
|
+
end
|
data/autoaudio.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'autoaudio/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'autoaudio'
|
8
|
+
spec.version = Autoaudio::VERSION
|
9
|
+
spec.authors = ['Gene Locklin']
|
10
|
+
spec.email = ['gene.locklin@gmail.com']
|
11
|
+
spec.description = %q{Automatically download scene .nfo and .nzb files}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = 'https://github.com/GeneLocklin/autoaudio'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
# spec.post_install_message = ''
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = %w[lib]
|
21
|
+
|
22
|
+
spec.add_dependency 'mechanize'
|
23
|
+
spec.add_dependency 'mongoid'
|
24
|
+
spec.add_dependency 'thor'
|
25
|
+
spec.add_dependency 'gist'
|
26
|
+
spec.add_dependency 't'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
29
|
+
spec.add_development_dependency 'rake'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
spec.add_development_dependency 'guard'
|
32
|
+
spec.add_development_dependency 'guard-rspec'
|
33
|
+
spec.add_development_dependency 'guard-bundler'
|
34
|
+
end
|
35
|
+
|
data/bin/autoaudio
ADDED
data/config/mongoid.yml
ADDED
data/etc/aa.jpg
ADDED
Binary file
|
data/etc/download.thor
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'mechanize'
|
4
|
+
require 'thor'
|
5
|
+
|
6
|
+
# ---------------------------------------------
|
7
|
+
|
8
|
+
class Download < Thor
|
9
|
+
desc "anonymous_gist GIST_HASH", "Example: thor download:anonymous_gist 7da2f5e6bf31b3ec4eee"
|
10
|
+
|
11
|
+
def anonymous_gist(gist_hash)
|
12
|
+
anon_regex = /https:\/\/anonfiles.com\/file\/\b[A-Za-z0-9]{32}\b/
|
13
|
+
agent = Mechanize.new
|
14
|
+
page = agent.get("https://gist.github.com/anonymous/#{gist_hash}/raw/")
|
15
|
+
song_links = page.body.scan(anon_regex)
|
16
|
+
|
17
|
+
song_links.each do |link|
|
18
|
+
page = agent.get(link)
|
19
|
+
download_link = page.link_with(:class => /download_button/, :text => /Download/)
|
20
|
+
title = page.title.gsub('AnonFiles.com - ', '')
|
21
|
+
download_link.click.save! "#{Dir.home}/Downloads/AnonNZB/#{title}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/autoaudio.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'mongoid'
|
4
|
+
require 'gist'
|
5
|
+
require 't'
|
6
|
+
|
7
|
+
require 'autoaudio/version'
|
8
|
+
require 'autoaudio/settings'
|
9
|
+
require 'autoaudio/cli/application'
|
10
|
+
|
11
|
+
require 'autoaudio/utility'
|
12
|
+
require 'autoaudio/feed'
|
13
|
+
require 'autoaudio/download'
|
14
|
+
|
15
|
+
module Autoaudio
|
16
|
+
extend self
|
17
|
+
Mongoid.load!("config/mongoid.yml", :development)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Autoaudio
|
4
|
+
module Cli
|
5
|
+
class Application < Thor
|
6
|
+
|
7
|
+
desc 'display_configuration_settings', 'Displays the application configuration settings'
|
8
|
+
def display_configuration_settings
|
9
|
+
puts "Autoaudio::VERSION = #{Autoaudio::VERSION}"
|
10
|
+
puts "Download location = #{Autoaudio::Config::NZB_DOWNLOAD_LOCATION[:directory]}"
|
11
|
+
puts "Tweet = #{Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs]}"
|
12
|
+
if Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs] == true
|
13
|
+
puts "Twitter Username = #{Autoaudio::Config::TWITTER_SETTINGS[:username]}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'make_feeds', 'Make all feeds'
|
18
|
+
def make_feeds
|
19
|
+
Feed.make
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'display_feeds', 'Display all feeds'
|
23
|
+
def display_feeds
|
24
|
+
Feed.each { |f| pp f }
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'destroy_feeds', 'Destroy all feeds'
|
28
|
+
def destroy_feeds
|
29
|
+
Feed.each { |f| f.destroy }
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'download', 'Downloads all feeds'
|
33
|
+
def download
|
34
|
+
Feed.make
|
35
|
+
feeds = Feed.where(downloaded: false).each.to_a
|
36
|
+
i = (feeds.length / 5)
|
37
|
+
while i > 0
|
38
|
+
new_array = Array.new
|
39
|
+
5.times do
|
40
|
+
new_array << feeds.pop
|
41
|
+
end
|
42
|
+
new_array.each { |feed| Download.album(feed) }
|
43
|
+
sleep 20
|
44
|
+
i -= 1
|
45
|
+
end
|
46
|
+
unless File.zero?('./log/gist.txt')
|
47
|
+
system("gist -c -p -d \"#{DateTime.now}\" -f \"#{DateTime.now}\" './log/gist.txt' -f download.thor './etc/download.thor'")
|
48
|
+
if Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs] == true
|
49
|
+
system("t set active #{Autoaudio::Config::TWITTER_SETTINGS[:username]}")
|
50
|
+
system("t update `pbpaste`")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
File.truncate('./log/gist.txt', 0)
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'download_genre GENRE', 'Download a specific genre'
|
57
|
+
def download_genre(genre_formatted)
|
58
|
+
genre = Feed.where(
|
59
|
+
# audio_format: "MP3",
|
60
|
+
genre_formatted: genre_formatted,
|
61
|
+
nzb_opened: false
|
62
|
+
)
|
63
|
+
genre.each do |feed|
|
64
|
+
if feed.nzb != nil
|
65
|
+
system("open #{feed.nzb}")
|
66
|
+
feed.update_attribute(:nzb_opened, true)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'autoaudio/utility'
|
2
|
+
|
3
|
+
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
|
+
)
|
40
|
+
end
|
41
|
+
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
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
if !feed.downloaded && results_page.links_with(:text => 'Download', :href => hash_regex).any? do |link|
|
57
|
+
search_form = page.form
|
58
|
+
search_form.q = hash_regex.match(link.href)
|
59
|
+
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
|
+
)
|
69
|
+
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
|
+
)
|
79
|
+
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
|
+
)
|
91
|
+
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
|
+
|
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)
|
104
|
+
end
|
105
|
+
|
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}")
|
119
|
+
end
|
120
|
+
File.truncate(reply, 0)
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,77 @@
|
|
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
|
@@ -0,0 +1,24 @@
|
|
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
|
+
|
data/log/gist.txt
ADDED
File without changes
|
data/log/reply.txt
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: autoaudio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gene Locklin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mechanize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mongoid
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gist
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: t
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: guard-rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: guard-bundler
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: Automatically download scene .nfo and .nzb files
|
168
|
+
email:
|
169
|
+
- gene.locklin@gmail.com
|
170
|
+
executables:
|
171
|
+
- autoaudio
|
172
|
+
extensions: []
|
173
|
+
extra_rdoc_files: []
|
174
|
+
files:
|
175
|
+
- ".gitignore"
|
176
|
+
- Gemfile
|
177
|
+
- LICENSE.txt
|
178
|
+
- README.md
|
179
|
+
- Thorfile
|
180
|
+
- autoaudio.gemspec
|
181
|
+
- bin/autoaudio
|
182
|
+
- config/mongoid.yml
|
183
|
+
- etc/aa.jpg
|
184
|
+
- etc/download.thor
|
185
|
+
- lib/autoaudio.rb
|
186
|
+
- lib/autoaudio/cli/application.rb
|
187
|
+
- lib/autoaudio/download.rb
|
188
|
+
- lib/autoaudio/feed.rb
|
189
|
+
- lib/autoaudio/settings.rb
|
190
|
+
- lib/autoaudio/utility.rb
|
191
|
+
- lib/autoaudio/version.rb
|
192
|
+
- log/gist.txt
|
193
|
+
- log/reply.txt
|
194
|
+
homepage: https://github.com/GeneLocklin/autoaudio
|
195
|
+
licenses:
|
196
|
+
- MIT
|
197
|
+
metadata: {}
|
198
|
+
post_install_message:
|
199
|
+
rdoc_options: []
|
200
|
+
require_paths:
|
201
|
+
- lib
|
202
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - ">="
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - ">="
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: '0'
|
212
|
+
requirements: []
|
213
|
+
rubyforge_project:
|
214
|
+
rubygems_version: 2.1.11
|
215
|
+
signing_key:
|
216
|
+
specification_version: 4
|
217
|
+
summary: Automatically download scene .nfo and .nzb files
|
218
|
+
test_files: []
|