bingwallpaper 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/bingwallpaper +23 -12
- data/lib/bingwallpaper/image.rb +13 -19
- data/lib/bingwallpaper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmI3M2ZmNDY2ZmUwMWE1NGI1MjA4MzE4MGYyMjQzYWFhZjczMzNhOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjIyZTBlODIyODcyMzY2OTgyMWRkMjM2YjQ0MjQwZmEzYjEyOGI5MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yjk4OGZjNTBkZmFlMDU5YmJmMWIzMGM5OWY0MThhM2YwOWU3ZGFiYmQwMGJj
|
10
|
+
YWI1NDAzZmM5MjNiNTE1ZDE1ZjhlYmNlODU2OGY0ZTVlYWU0ZTdmN2RmYzc4
|
11
|
+
NjRiYmVkMzhmOGI0YmI5MjliZmI2ZDE1NWI5ZjA5YTNjYTlmNmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODBhMDAxZjZiMTRmNDRhOTMwNTgzNTU4NjgzMjM5MTk4NThjYzRhYzEyMmE4
|
14
|
+
ZjdmNDMzZDFiNTliY2U1NmE3ZjM4YmFkZjM4ZDM3YTgzYTA3NTJmM2FmOTk2
|
15
|
+
MDJmYzgxYTRjMzZhZjZkOWQwODUxNDlhZTY4ODU0MzkwNWFhNDg=
|
data/bin/bingwallpaper
CHANGED
@@ -29,20 +29,29 @@ begin
|
|
29
29
|
image_path = bingImage.image_storage_path image_data[0][:file_name]
|
30
30
|
fallback_image_path = bingImage.image_storage_path image_data[0][:fallback_file_name]
|
31
31
|
|
32
|
-
#
|
33
|
-
if !
|
32
|
+
# try the hi-res image
|
33
|
+
if !image_path.exist?
|
34
34
|
|
35
35
|
begin
|
36
|
-
|
37
|
-
bingImage.download_image image_data[0]
|
36
|
+
|
37
|
+
bingImage.download_image image_path, image_data[0][:links][:url]
|
38
38
|
rescue Exception => exception
|
39
|
-
logger.info "
|
39
|
+
logger.info "I couldn't download the hi-resolution image of the day..."
|
40
|
+
logger.info "I couldn't load " + image_data[0][:links][:url]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
# fallback to the low-res image
|
46
|
+
if !image_path.exist? && !fallback_image_path.exist?
|
47
|
+
|
48
|
+
begin
|
49
|
+
|
50
|
+
bingImage.download_image fallback_image_path, image_data[0][:links][:fallback_url]
|
51
|
+
rescue Exception => exception
|
52
|
+
logger.info "I couldn't download the low-resolution image of the day..."
|
40
53
|
logger.info "I couldn't load " + image_data[0][:links][:url]
|
41
|
-
logger.info image_data[0]
|
42
|
-
logger.error "The problem was: " + exception.message
|
43
54
|
end
|
44
|
-
else
|
45
|
-
logger.info "Today's wallpaper already downloaded. ;-)"
|
46
55
|
end
|
47
56
|
|
48
57
|
# set the wallpaper
|
@@ -51,16 +60,18 @@ begin
|
|
51
60
|
# set the wallpaper
|
52
61
|
logger.info "Wallpaper set to #{image_path}"
|
53
62
|
`feh --bg-fill #{image_path}`
|
54
|
-
|
63
|
+
elsif fallback_image_path.exist?
|
55
64
|
|
56
65
|
# set the wallpaper
|
57
|
-
logger.info "
|
66
|
+
logger.info "Only the low-resolution image was available today."
|
58
67
|
logger.info "Wallpaper set to #{image_path}"
|
59
68
|
`feh --bg-fill #{fallback_image_path}`
|
69
|
+
else
|
70
|
+
|
71
|
+
logger.info "Sorry, I couldn't download the Bing Image of the Day. :'("
|
60
72
|
end
|
61
73
|
rescue Exception => exception
|
62
74
|
logger.info "Sorry, I couldn't set today's Bing Image of the Day Wallpaper. :'("
|
63
75
|
logger.error "The problems was: " + exception.message
|
64
|
-
logger.error exception.backtrace
|
65
76
|
exit 1
|
66
77
|
end
|
data/lib/bingwallpaper/image.rb
CHANGED
@@ -87,7 +87,7 @@ module Bingwallpaper
|
|
87
87
|
|
88
88
|
# build our hash of image data
|
89
89
|
{:links => {:url => build_url(image_path),
|
90
|
-
:fallback_url => image_fallback_path,
|
90
|
+
:fallback_url => build_url(image_fallback_path),
|
91
91
|
:copyright_url => image.xpath('copyrightlink').text},
|
92
92
|
:file_name => Pathname.new(image_path).basename.to_s,
|
93
93
|
:fallback_file_name => Pathname.new(image_fallback_path).basename.to_s,
|
@@ -98,33 +98,27 @@ module Bingwallpaper
|
|
98
98
|
# Returns a Pathname with location where the image from the
|
99
99
|
# provided Bing image hash will be stored.
|
100
100
|
#
|
101
|
-
# file_name:: Path to the file storage location
|
101
|
+
# file_name:: Path to the file storage location'
|
102
102
|
def image_storage_path(file_name)
|
103
103
|
Pathname.new @storage_path + "/" + file_name
|
104
104
|
end
|
105
105
|
|
106
|
-
# Downloads the
|
106
|
+
# Downloads the image at the supplied URL and saves it to the
|
107
|
+
# specified file.
|
107
108
|
#
|
108
|
-
#
|
109
|
-
|
109
|
+
# file_path:: Path for the storing image
|
110
|
+
# url:: URL to the image to download
|
111
|
+
def download_image(file_path, url)
|
110
112
|
|
111
113
|
begin
|
112
|
-
open(image_storage_path(image_data[:file_name]), 'wb') do |file|
|
113
|
-
file << open(image_data[:links][:url]).read
|
114
|
-
end
|
115
|
-
rescue Exception => exception
|
116
|
-
|
117
|
-
FileUtils.rm(image_storage_path(image_data[:file_name]))
|
118
114
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
end
|
123
|
-
rescue
|
124
|
-
|
125
|
-
FileUtils.rm(image_storage_path(image_data[:fallback_file_name]))
|
126
|
-
raise exception
|
115
|
+
# download the hi-res image
|
116
|
+
open(file_path, 'wb') do |file|
|
117
|
+
file << open(url).read
|
127
118
|
end
|
119
|
+
rescue Exception => exception
|
120
|
+
file_path.delete
|
121
|
+
raise exception
|
128
122
|
end
|
129
123
|
end
|
130
124
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bingwallpaper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cmiles74
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|