reddit_wallpaper 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/LICENSE +21 -0
- data/README.md +26 -0
- data/bin/reddit_wallpaper +42 -0
- data/lib/reddit_wallpaper.rb +36 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d667c82088bc96a98fa56c43705cb95d2e85d70
|
4
|
+
data.tar.gz: 594877172258873b5e8381937e9d9a5842ce427f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 85bd251a4df07f21664f43cc0efe18128ab0de4af7cf2e793ea6385231dad1a225ab895dbcd8661c2dd3dee1e4301c81238615a7eb502dc05fd6647c37086b0d
|
7
|
+
data.tar.gz: e3433f5e662a9f38a290d1fc6c0268ef1d4f8a2ab831d5fd6f4f222f21eb4a4070a062720817b99a6aeef3324903735d9aef8486334a9e10843ecb647ea0acdb
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Emad Elsaid, Jordan Byron
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Reddit Wallpaper
|
2
|
+
================
|
3
|
+
|
4
|
+
Download images from your favorite subreddit!
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
To get started, first install then gem, then run `reddit_wallpaper`
|
9
|
+
|
10
|
+
```bash
|
11
|
+
$ gem install reddit_wallpaper
|
12
|
+
$ reddit_wallpaper
|
13
|
+
```
|
14
|
+
|
15
|
+
This will download a new image from the
|
16
|
+
[r/earthporn](http://reddit.com/r/earthporn) subreddit into your home directory.
|
17
|
+
You can override both options by passing in additional arguments. For full
|
18
|
+
details type `reddit_wallpaper -h` in your console.
|
19
|
+
|
20
|
+
## Authorship
|
21
|
+
|
22
|
+
Original implementation by [Emad Elsaid][ee] and gemified / enhanced by
|
23
|
+
[Jordan Byron][jb]
|
24
|
+
|
25
|
+
[ee]: https://github.com/blazeeboy
|
26
|
+
[jb]: https://github.com/jordanbyron
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require_relative '../lib/reddit_wallpaper'
|
5
|
+
|
6
|
+
options = {
|
7
|
+
subreddit: 'earthporn',
|
8
|
+
destination: File.join(Dir.home, "background.jpg")
|
9
|
+
}
|
10
|
+
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: reddit_wallpaper [options]"
|
13
|
+
opts.on("-d", "--destination [PATH]", String,
|
14
|
+
"Wallpaper destination file [#{options[:destination]}]") do |destination|
|
15
|
+
options[:destination] = destination
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on("-r", "--subreddit [NAME]", String,
|
19
|
+
"Subreddit to grab images from [#{options[:subreddit]}]") do |subreddit|
|
20
|
+
options[:subreddit] = subreddit
|
21
|
+
end
|
22
|
+
end.parse!
|
23
|
+
|
24
|
+
downloader = RedditWallpaper.new(options[:subreddit], options[:destination])
|
25
|
+
|
26
|
+
loop do
|
27
|
+
downloader.download_new_image
|
28
|
+
puts "#{downloader.downloaded.last} downloaded"
|
29
|
+
|
30
|
+
# Manually reload the background image on OS X
|
31
|
+
# This requires us to set the image to something else, and then back to the
|
32
|
+
# downloaded image
|
33
|
+
if RUBY_PLATFORM[/darwin/]
|
34
|
+
script = ->(file){
|
35
|
+
`osascript -e 'tell application "Finder" to set desktop picture to\
|
36
|
+
"#{file}" as POSIX file'`
|
37
|
+
}
|
38
|
+
script["/Library/Desktop\ Pictures/Solid\ Colors/Solid\ Aqua\ Blue.png"]
|
39
|
+
script[options[:destination]]
|
40
|
+
end
|
41
|
+
sleep 5*60 # wait for 5 minutes
|
42
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'ruby_reddit_api'
|
3
|
+
|
4
|
+
class RedditWallpaper
|
5
|
+
def initialize(subreddit, destination_file)
|
6
|
+
@subreddit = subreddit
|
7
|
+
@path = destination_file
|
8
|
+
@downloaded = []
|
9
|
+
@not_downloaded = []
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :path, :subreddit, :downloaded, :not_downloaded
|
13
|
+
|
14
|
+
def download_new_image
|
15
|
+
posts = reddit.browse(subreddit)
|
16
|
+
posts.each do |post|
|
17
|
+
if post.url.include?('imgur') && !downloaded.include?(post.url)
|
18
|
+
not_downloaded << post.url
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
download_image not_downloaded.shift
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def reddit
|
28
|
+
@reddit ||= Reddit::Api.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def download_image(url)
|
32
|
+
# Append .jpg to ensure we are getting the image file
|
33
|
+
open(path, 'wb') {|file| file << open(url + ".jpg").read }
|
34
|
+
downloaded << url
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: reddit_wallpaper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emad Elsaid
|
8
|
+
- Jordan Byron
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ruby_reddit_api
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.2'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.2'
|
28
|
+
description: Download the latest images from your favorite subreddit and set them
|
29
|
+
as your desktop background
|
30
|
+
email:
|
31
|
+
- blazeeboy@gmail.com
|
32
|
+
- jordan.byron@gmail.com
|
33
|
+
executables:
|
34
|
+
- reddit_wallpaper
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- LICENSE
|
39
|
+
- README.md
|
40
|
+
- bin/reddit_wallpaper
|
41
|
+
- lib/reddit_wallpaper.rb
|
42
|
+
homepage: https://github.com/jordanbyron/reddit_wallpaper
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.2.2
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Auto-changing wallpaper from reddit / imgur images
|
66
|
+
test_files: []
|
67
|
+
has_rdoc:
|