Permalink
Browse files

New script and assorted config files.

  • Loading branch information...
dconnolly committed Feb 6, 2014
1 parent 93cd00f commit bb0608b1ad3844d25ace7e162eef4a5be8800ab4
Showing with 191 additions and 0 deletions.
  1. +14 −0 .editorconfig
  2. +4 −0 .gitignore
  3. +14 −0 .jshintrc
  4. +4 −0 .travis.yml
  5. +48 −0 Gruntfile.js
  6. +1 −0 backgrounds.json
  7. +32 −0 package.json
  8. +74 −0 scrape.js
@@ -0,0 +1,14 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# 4 space indentation
[*.js*]
indent_style = space
indent_size = 4
@@ -0,0 +1,4 @@
/node_modules/
npm-debug.log
*~
#*
@@ -0,0 +1,14 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"node": true
}
@@ -0,0 +1,4 @@
language: node_js
node_js:
- '0.10'
- '0.8'
@@ -0,0 +1,48 @@
'use strict';

module.exports = function (grunt) {
// Show elapsed time at the end
require('time-grunt')(grunt);
// Load all grunt tasks
require('load-grunt-tasks')(grunt);

// Project configuration.
grunt.initConfig({
nodeunit: {
files: ['test/**/*_test.js']
},
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['lib/**/*.js']
},
test: {
src: ['test/**/*.js']
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib: {
files: '<%= jshint.lib.src %>',
tasks: ['jshint:lib', 'nodeunit']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'nodeunit']
}
}
});

// Default task.
grunt.registerTask('default', ['jshint', 'nodeunit']);

};
@@ -0,0 +1 @@
[{"url":"https://lh5.googleusercontent.com/-uaGTbkMBysI/R7qYVHTGv6I/AAAAAAAABiQ/IU0yK7OgvYc/s2560/IMG_0213.JPG","author":"Michael Wyszomierski"},{"url":"https://lh5.googleusercontent.com/-cOLDtwfvFrk/UgxevfE7NnI/AAAAAAAAHEg/X4vxKor8iCc/s2560/DSC_3987-2-Edit.JPG","author":"Michael Himawan"},{"url":"https://lh5.googleusercontent.com/-jTHJFPzaDCM/T1F5nO4H8kI/AAAAAAAADbE/IxyGInI2xN0/s2560/shanghai%2Btunnel%2Borange.jpg","author":"Dave Morrow"},{"url":"https://lh4.googleusercontent.com/-FAIPD0L_XLs/UBctAcHLwcI/AAAAAAAAJAo/fsicVZWEcT8/s2560/ConvictLakeSunrise.jpg","author":"Aravind Ravisankar"},{"url":"https://lh5.googleusercontent.com/-f1YF98XfEmY/UVmHsvQBxvI/AAAAAAAAT9g/0Uk7XjxUFCw/s2560/IMG_20130330_120430-Edit.jpg","author":"Alistair Nicol"},{"url":"https://lh6.googleusercontent.com/-mA6_1F0fM7U/TgtZGJt2oII/AAAAAAAF-Wg/XtgbldrGLSg/s2560/3189889363_6357f5f645_o.jpg","author":"Trey Ratcliff"},{"url":"https://lh6.googleusercontent.com/-Gw74paeyBQ0/TouJkmwcg7I/AAAAAAAA3Ys/3Kk-1AovcuE/s2560/Evidence.jpg","author":"Thomas Hawk"},{"url":"https://lh5.googleusercontent.com/-dELtU2dJO3s/UelgDtAVclI/AAAAAAAAZiU/zb5ywUbdfZ0/s2560/theedge.jpg","author":"Alistair Nicol"},{"url":"https://lh5.googleusercontent.com/-JoKkOqJLegk/T7KQORntaBI/AAAAAAAAMXY/mA-N-Ca2pg8/s2560/panthercreek_7509-Edit.jpg","author":"Nicole S. Young"},{"url":"https://lh5.googleusercontent.com/-v_osPPHl71I/Tj_5Wsgr4mI/AAAAAAAAE3c/5yJ3mkXKdlU/s2560/KeeSummer-1920.jpg","author":"Patrick Smith"},{"url":"https://lh5.googleusercontent.com/-ee4PsGvjU6E/T12UiPm3_lI/AAAAAAAAJxk/7iG8ltiRL2Y/s2560/blue4.jpg","author":"Erika Thornes"},{"url":"https://lh3.googleusercontent.com/-1dANL8dJDT0/T6h0JShpn-I/AAAAAAAAIDk/l_dKhWvFXUs/s2560/YosemiteFalls.jpg","author":"Aravind Ravisankar"},{"url":"https://lh6.googleusercontent.com/-n76GULHmI8U/Tg1fNmGyDbI/AAAAAAAAAOA/pNieTMoo0ro/s2560/090911-2088-AngelIslandSky2.jpg","author":"Patrick Smith"},{"url":"https://lh6.googleusercontent.com/-p8gu7w4UaB0/Tg1cD-zJRXI/AAAAAAAAAJw/xKPs4AJ8WTU/s2560/070211-2329-GarrapataSurf1.jpg","author":"Patrick Smith"},{"url":"https://lh6.googleusercontent.com/-dT6mqzdFoxo/UO5TsJMf_yI/AAAAAAAAHBQ/u78KkmtyRyc/s2560/Rockaway%2BSunset%2BSky.jpg","author":"Romain Guy"},{"url":"https://lh6.googleusercontent.com/-pwKZhLAOAHY/TlAwJa0IQwI/AAAAAAAABh8/2QNrMTQubk0/s2560/DryLeaf.jpg","author":"Karen Hutton"},{"url":"https://lh3.googleusercontent.com/-SKcPAkfdiQk/T0K04INc_EI/AAAAAAAACw8/Ag_vz66k_Ag/s2560/David%2BMorrow-1.jpg","author":"Dave Morrow"},{"url":"https://lh3.googleusercontent.com/-Z9mJn5vva2U/T6sVZGdrvgI/AAAAAAAAdAo/rdpy_ia2NS8/s2560/The%2BFickle%2BMistress.jpg","author":"Joe Azure"},{"url":"https://lh6.googleusercontent.com/-8XtMTUCZA9w/UO5Tjv99GgI/AAAAAAAAE84/--Y7_Pr-tIs/s2560/Little%2BBit%2Bof%2BParadise.jpg","author":"Romain Guy"},{"url":"https://lh5.googleusercontent.com/-Bw1ez5kyvxU/UdQKsby_ggI/AAAAAAAAXnY/wrBUUoCk3ZQ/s2560/IMG_20130703_062950.JPG","author":"Alistair Nicol"},{"url":"https://lh4.googleusercontent.com/-lR3vG062kEk/Tg1fjlh053I/AAAAAAAAAOc/Sv1zKPXPkPQ/s2560/091220-2536-TheCurl.jpg","author":"Patrick Smith"},{"url":"https://lh4.googleusercontent.com/-JvGl0iUdb58/UfvkbbsvXtI/AAAAAAAAaJc/1aANEbTHeK4/s2560/DSC_1644-Edit-Edit-Edit-Edit.JPG","author":"Alistair Nicol"},{"url":"https://lh4.googleusercontent.com/-129Q91osfKU/UKsTjV0_Q0I/AAAAAAAAIWs/yQsQqCZLOhE/s2560/IMG_3144-3.jpg","author":"Kushagra Shrivastava"},{"url":"https://lh6.googleusercontent.com/-qd290nJU0FM/UZYXTBbrzeI/AAAAAAAAVhI/gNH2tEzLT80/s2560/Reflection.jpg","author":"Alistair Nicol"},{"url":"https://lh6.googleusercontent.com/-Sg-zeby8vAo/ThJbwzfgG5I/AAAAAAAADyg/_LAL3Ise3U8/s2560/Houston%252C%2B5-28-2011-744.jpg","author":"Thomas Hawk"},{"url":"https://lh5.googleusercontent.com/-b4ZiJXUmZLg/TUCPhc_z2pI/AAAAAAAAAgM/uY37UMRjGsw/s2560/Trippin%2527-3.jpg","author":"Alan Shapiro"},{"url":"https://lh4.googleusercontent.com/-mWoPAMsZ8qM/TgtZECWsZDI/AAAAAAAAKUU/3cvylLAok9E/s2560/1071616194_the%2Bfarm%2Bof%2Beden.jpg","author":"Trey Ratcliff"},{"url":"https://lh4.googleusercontent.com/-V8ifxhq3-Yw/T43ivW-pQgI/AAAAAAAAQrM/OeAQZzV5LcE/s2560/071229-4231-SandstNSky1.jpg","author":"Patrick Smith"},{"url":"https://lh3.googleusercontent.com/-49Av-ZEwnzM/UFni18NCwpI/AAAAAAAAasc/KL-gRtscc4Q/s2560/120917-Coit1920.jpeg","author":"Patrick Smith"},{"url":"https://lh3.googleusercontent.com/-p5_F7m7xK9s/UW3Mgp2DRbI/AAAAAAAANzs/PSivUXeweL8/s2560/Galaxy%2BNumber%2B9%252B.jpg","author":"Dave Morrow"},{"url":"https://lh4.googleusercontent.com/-sy3wa9ofb38/UQtPlF6YOQI/AAAAAAAAJgQ/Oq2_cpjoYlg/s2560/IMGP8993.jpg","author":"Derek Kind"},{"url":"https://lh3.googleusercontent.com/-oM2bHS-0OjU/TyPjUdi6QZI/AAAAAAAADzA/d-XeO0rjka0/s2560/Granite%2Bsectional%2Band%2BSunken%2Blivingroom.jpg","author":"Nate Parker"},{"url":"https://lh6.googleusercontent.com/-DArub5w7veQ/ToyVWFUZ5bI/AAAAAAAABJs/NL4PjtDKI90/s2560/David%2BMorrow-1-28.jpg","author":"Dave Morrow"},{"url":"https://lh3.googleusercontent.com/-8h4vm06cRYo/UZURZQG4KwI/AAAAAAAAPOE/GltqdZojKKE/s2560/Night%2BFalls%2Bon%2BCrater%2BLake%2B-%2BCrater%2BLake%252C%2BOR1.jpg","author":"Dave Morrow"},{"url":"https://lh3.googleusercontent.com/-UDg246afc7Q/UEUifribRBI/AAAAAAAALlo/iOUErvKdRCg/s2560/Sand%2BBeach%2BTexture-4.jpg","author":"Nate Parker"},{"url":"https://lh6.googleusercontent.com/-ZEeXODytQVA/UrX6U_7tVFI/AAAAAAAAioM/th3oeS00c9Y/s2560/DSC_0816-Edit-Edit-Edit-Edit-Edit.JPG","author":"Alistair Nicol"},{"url":"https://lh6.googleusercontent.com/-DfDrf9tZth0/TgtZGBjmXqI/AAAAAAAAL40/VApf1goXEMs/s2560/300928932_3bf6d408df_o.jpg","author":"Trey Ratcliff"},{"url":"https://lh4.googleusercontent.com/-Fz5s5Sq3uSc/UqXO06_DNPI/AAAAAAAAhPw/UNBDEnOdEhs/s2560/DSC_6160-Edit-Edit-Edit.JPG","author":"Alistair Nicol"},{"url":"https://lh5.googleusercontent.com/-vNC6dt9sE5o/UONnMpqPZjI/AAAAAAAAGGA/Q5Q8csXGzgM/s2560/IMGP7317_18_19_20_tonemapped.jpg","author":"Derek Kind"},{"url":"https://lh6.googleusercontent.com/-hXPVBw1iPyc/Tg1gUs9WABI/AAAAAAAAAPU/J-g25o_00Gk/s2560/100804-4696-PololuMorn1.jpg","author":"Patrick Smith"},{"url":"https://lh4.googleusercontent.com/-ePzy0PYNkjY/ToE9F9iPxKI/AAAAAAAABgo/skd2fGsxOBU/s2560/DSC01079%2B%25281%2529.JPG","author":"Gretchen Chappelle"},{"url":"https://lh5.googleusercontent.com/-kIjVQfr42sA/T0igl-kt1oI/AAAAAAAAa3E/v2ZuxXNeLDs/s2560/02202012-01.jpg","author":"Mike Wiacek"},{"url":"https://lh6.googleusercontent.com/-_OVIBu35BFs/UOD9ybxkzmI/AAAAAAAAkNo/YyQXlMNgeEk/s2560/06152012-12.jpg","author":"Mike Wiacek"},{"url":"https://lh6.googleusercontent.com/-qqRE8win5yw/UUafTaPaStI/AAAAAAAAHgo/nfra2_LkeBU/s2560/Bean%2BHollow%2BSunset%2B2048.jpg","author":"Romain Guy"},{"url":"https://lh4.googleusercontent.com/-IPbUv2dc9E4/Ugotamqb0xI/AAAAAAAAbME/zTVKgdkCdRY/s2560/DSC_2018-Edit-Edit.JPG","author":"Alistair Nicol"},{"url":"https://lh5.googleusercontent.com/-YxXTf0j_MTQ/UtTwF4t9yEI/AAAAAAAAPMo/Bm9lerCRaak/s2560/Glacier%2BPoint%2BMilky%2BWay%2BPanorama.jpg","author":"Raja Ramakrishnan"},{"url":"https://lh3.googleusercontent.com/-71rGVgWwPVs/UV2EkSYIYdI/AAAAAAAAjJ0/2jhJTt1iWzU/s2560/20130331-%252809_01_49%2529-yosemite-iq180-16451_HDR.jpg","author":"Aravind Krishnaswamy"},{"url":"https://lh5.googleusercontent.com/-6Ucgze7TOT4/UO5TcOkC0nI/AAAAAAAAI4E/lcuxqzDIvAY/s2560/Foggy%2BSunset.jpg","author":"Romain Guy"},{"url":"https://lh5.googleusercontent.com/-8C6-1R0jdzQ/T_s980NGjLI/AAAAAAAAaw0/zVTp1Vo6dJ8/s2560/060408-1938-GarrapataFlow.jpg","author":"Patrick Smith"},{"url":"https://lh4.googleusercontent.com/-AR4eJKeFOyU/ToywYB2z2XI/AAAAAAAAKM4/0-cLQUp1J-k/s2560/TheMomentAfterSheLeft.jpg","author":"Karen Hutton"},{"url":"https://lh3.googleusercontent.com/-6IrulujJPwU/Tg1d_n1nptI/AAAAAAAAAMc/O4OAV6udX8Y/s2560/080820-5209-MakenaLL.jpg","author":"Patrick Smith"},{"url":"https://lh4.googleusercontent.com/-xjlOWCsBOHg/UL2Bg7-fWJI/AAAAAAAAEQM/_Af3LToQDmg/s2560/IMGP8003.jpg","author":"Derek Kind"},{"url":"https://lh3.googleusercontent.com/-gi8-azW5hAQ/UGdSQqk9G_I/AAAAAAAAJto/inIHRwOCy3c/s2560/TetonShwabacher.jpg","author":"Aravind Ravisankar"},{"url":"https://lh5.googleusercontent.com/-Hhp_SMvb6a0/UOSjNI1cZnI/AAAAAAAAGjU/0XLFokAU-bw/s2560/IMGP4090-Edit.jpg","author":"Derek Kind"},{"url":"https://lh3.googleusercontent.com/-RCFt3utBaXk/UE5kxyUxo6I/AAAAAAAAJWQ/jtgzKjcGfuU/s2560/TetonSnakeOverlook.jpg","author":"Aravind Ravisankar"},{"url":"https://lh6.googleusercontent.com/-5ntl45J8Lxg/UiHZG2mJ1nI/AAAAAAAAb8s/f10TxWDh2zA/s2560/DSC_5165-Edit-Edit.JPG","author":"Alistair Nicol"},{"url":"https://lh4.googleusercontent.com/-HbF8zRNZt-o/UMPHYkBuCMI/AAAAAAAAKUQ/GYFSC7-LVqs/s2560/Group%2BTWO.jpg","author":"Dave Morrow"},{"url":"https://lh3.googleusercontent.com/-NeMzsWIU6RU/UZURZR7U_aI/AAAAAAAAPhA/5FlWwsjbhZo/s2560/8280686512_7820f388dc_k.jpg","author":"Dave Morrow"},{"url":"https://lh4.googleusercontent.com/-Pg1HXtyXBZ0/UGHWhKaSrhI/AAAAAAAASZE/q3omNbvxCJU/s2560/FI4C6008.jpg","author":"Brandon Falls"},{"url":"https://lh6.googleusercontent.com/-CI9_3fghPp8/UcrcsOC7IZI/AAAAAAAAXSQ/EJskXUVPyUY/s2560/DSC_1879-Edit-Edit-Edit-Edit.JPG","author":"Alistair Nicol"},{"url":"https://lh4.googleusercontent.com/-xbaZ1sXXy24/ThTso6EAUgI/AAAAAAAAGgQ/7oRSLDLXFMg/s2560/DSC_0267_8_9_tonemapped-Edit-1.jpg","author":"Raja Ramakrishnan"},{"url":"https://lh4.googleusercontent.com/-31H2j9KKMi0/UTpeMK5JrEI/AAAAAAAAPHo/4QOl-12J750/s2560/Hooded%2BLady%2Bof%2Bthe%2BValley.jpg","author":"Dave Morrow"},{"url":"https://lh6.googleusercontent.com/-b_ZyO6A8eec/UNcwXdvdtMI/AAAAAAAAR4k/YcThGSa1EHE/s2560/DSC_0300.jpg","author":"Alistair Nicol"},{"url":"https://lh3.googleusercontent.com/-wFqcH25l4-k/T9iiAqxUuMI/AAAAAAAAXhY/yo1c2xFs75g/s2560/050518-2044-KeeEvening.jpg","author":"Patrick Smith"},{"url":"https://lh4.googleusercontent.com/-FDe6_2rxtEs/UkBgjq9ZJmI/AAAAAAAAELo/zT29ZhT2NAA/s2560/Salt_Point.jpg","author":"Mason Cummings"},{"url":"https://lh3.googleusercontent.com/-8KDJntL6YEw/UT3FHch4HiI/AAAAAAAATTs/C4ItuhGEYbA/s2560/Ice%2BWaterfall.jpg","author":"Alistair Nicol"},{"url":"https://lh5.googleusercontent.com/-xOVjmeJjM3o/TqtYP_buAoI/AAAAAAAAFlA/xUHqJSkr-MU/s2560/IMG_0684.JPG","author":"Aravind Ravisankar"},{"url":"https://lh5.googleusercontent.com/-icxfSWCdca0/Ulc-bdE4s2I/AAAAAAAAOcc/EBbQR8PNBSY/s2560/BeautyCreek.jpg","author":"Aravind Ravisankar"},{"url":"https://lh5.googleusercontent.com/-cDUuqa-AcvM/Txz_UPWEhOI/AAAAAAAALgc/39baWFTrOtA/s2560/110429-7971-Faultlines.jpg","author":"Patrick Smith"},{"url":"https://lh6.googleusercontent.com/-OfMrsi0J6OE/TvNVvRo18YI/AAAAAAAAKVU/2ujQTeUYDtA/s2560/060518-0179-TamRedwoods.jpg","author":"Patrick Smith"},{"url":"https://lh6.googleusercontent.com/-GQv4Q_NZKH8/UDZ1v6AEcSI/AAAAAAAA6ik/i90ZeH2jexc/s2560/IMG_4460.jpg","author":"Michal Pecek"},{"url":"https://lh4.googleusercontent.com/-4fN6GrHUn3w/UUKwgYRk6AI/AAAAAAAAHc0/S7Wpashpz_Y/s2560/Sailing%2BStones.jpg","author":"Romain Guy"},{"url":"https://lh4.googleusercontent.com/-dKrL8_a8MmE/UrWktdbZX_I/AAAAAAAAilY/2Ce0qzN9r3s/s2560/DSC_0816-Edit-Edit-Edit-Edit-Edit.JPG","author":"Alistair Nicol"},{"url":"https://lh3.googleusercontent.com/-Lgovjq61QJU/ULYz4W5rQQI/AAAAAAAAQVA/MnFx_4QgSuw/s2560/Changing%2BLight%2BOver%2BGarrapata%2BBeach.jpg","author":"Ivan Makarov"},{"url":"https://lh3.googleusercontent.com/-zabx6mtDOEg/UtrJztwa_YI/AAAAAAAAPgM/luQQofYop3w/s2560/Mysore%2BPalace.jpg","author":"Raja Ramakrishnan"},{"url":"https://lh6.googleusercontent.com/-DVLhwntrByk/UHWaN49pObI/AAAAAAAAQ5E/OeeF4jq71GY/s2560/DSC_0540_39_41-Edit.jpg","author":"Alistair Nicol"},{"url":"https://lh3.googleusercontent.com/-ciHScPkPIjY/USd_CK03c5I/AAAAAAAAS0E/9dNLc85HgDU/s2560/RayofHope.jpg","author":"Alistair Nicol"},{"url":"https://lh3.googleusercontent.com/-8kQQYYzz_l8/UZSathUsJGI/AAAAAAAAsUM/3Z4WK9CG8wE/s2560/07_20090416.jpg","author":"Mike Wiacek"},{"url":"https://lh6.googleusercontent.com/-GGY-AaDQgJc/UgG4BcMHLWI/AAAAAAAAPfQ/QB7UajJfiWo/s2560/20130805_mit_and_river_00001-2.jpg","author":"Robbie Shade"},{"url":"https://lh6.googleusercontent.com/-PhwGGpwHldU/UlhL9kOnwoI/AAAAAAAAGeU/ewNH2L2o1PE/s2560/tree.jpg","author":"Jesse Summers"},{"url":"https://lh4.googleusercontent.com/-b65_YEujdhY/T52ry34XssI/AAAAAAAAH3U/LqcDkhK7-PM/s2560/final%2Bcopy%2BSecond%2BBeach.jpg","author":"Dave Morrow"},{"url":"https://lh5.googleusercontent.com/-Y07dlcuKTrY/ThY_WrUE-JI/AAAAAAAAAv8/2IG-X24HUnQ/s2560/071229-4276-LaJollaFalls.jpg","author":"Patrick Smith"},{"url":"https://lh6.googleusercontent.com/-vZdfIWcvnhY/TnyLvq6DPpI/AAAAAAAAgiQ/NKRZZvFKvR0/s2560/One%2BTrick%2BPony.jpg","author":"Thomas Hawk"},{"url":"https://lh4.googleusercontent.com/-yYJUfqBHHXw/UoffDIFgJOI/AAAAAAAARpQ/M7Nskp7pTDg/s2560/DSC_7222-Edit-2.jpg","author":"Amarpreet Singh"},{"url":"https://lh4.googleusercontent.com/-InCrrvmnv6E/ToZiCHNNfZI/AAAAAAAAatw/xVhbARMaaLM/s2560/060518-0190-TamBreeze.jpg","author":"Patrick Smith"},{"url":"https://lh6.googleusercontent.com/-jGFm3VEUfWs/T8ZYvGvjuhI/AAAAAAAAOeg/pNzaz3TXxX0/s2560/DSC_0645_3_4-Edit.jpg","author":"Alistair Nicol"},{"url":"https://lh5.googleusercontent.com/-VGh9JQ9DCzM/Tg1cKU7qBRI/AAAAAAAAAJ4/Dyi6MrlgffU/s2560/070319-2657-PathToLight.jpg","author":"Patrick Smith"},{"url":"https://lh3.googleusercontent.com/-l87Wq35DtwM/UZyzIUuVM1I/AAAAAAAAVrI/LfYaBdsYElk/s2560/Outflow.jpg","author":"Alistair Nicol"},{"url":"https://lh4.googleusercontent.com/-cn-CS-vxFn4/UtTvqLzjmrI/AAAAAAAAPPc/MW1xacvvfSE/s2560/DSC_5300.jpg","author":"Raja Ramakrishnan"},{"url":"https://lh5.googleusercontent.com/-0EQ-4alz8RY/S9aXij2EEzI/AAAAAAAAMsc/HAseb_H1Hlk/s2560/20090411_132734_.jpg","author":"Mike Wiacek"},{"url":"https://lh3.googleusercontent.com/-5lm5qxI06OU/TqkYjHdt_lI/AAAAAAAAKOc/Eqb40U2Jsiw/s2560/CrackedIsSometimesGood.jpg","author":"Karen Hutton"},{"url":"https://lh6.googleusercontent.com/-qZwZs4YWpuw/UZURZUT7S1I/AAAAAAAAPSg/dH9BN4HYfXw/s2560/G%252B.jpg","author":"Dave Morrow"},{"url":"https://lh5.googleusercontent.com/-GC7USQu7t-8/UPSscZYnrUI/AAAAAAAAB5w/DHTn38KC8Ng/s2560/POD%2B2013-01-13.jpg","author":"J.F. Unson"},{"url":"https://lh6.googleusercontent.com/-BTVdYl7cQqQ/UrIOEKZzzOI/AAAAAAAAHmQ/Dd6NXdNjT6c/s2560/iJQAXfNjtKoqS.jpg","author":"Jesse Summers"},{"url":"https://lh6.googleusercontent.com/-08NVs0omPPw/TgtZEFlihuI/AAAAAAAAROU/k4VwPR_03X4/s2560/1134103121_gateway%2Bto%2Bthe%2Btemple%2Bof%2Bheaven.jpg","author":"Trey Ratcliff"},{"url":"https://lh4.googleusercontent.com/-SUKN-r5lw5A/Tg1fNM6yIEI/AAAAAAAAAN8/PULlaJpHBkI/s2560/090810-1930-NeedleAndHaystack.jpg","author":"Patrick Smith"},{"url":"https://lh5.googleusercontent.com/-z272JLnBwVM/UIQg3eD_V7I/AAAAAAAAQ08/-OhdRMZfqNA/s2560/G%252B.jpg","author":"Dave Morrow"},{"url":"https://lh5.googleusercontent.com/-qblqQRK-QW4/UMFUCEQ3zeI/AAAAAAAAEec/ADvGMU36sj8/s2560/2012%2B-%2B1","author":"Derek Kind"},{"url":"https://lh5.googleusercontent.com/-5vOp8Qd9Cr0/UZURZbC6EvI/AAAAAAAAPmQ/SW-6Wryik-Y/s2560/In%2Ba%2BForeign%2BLand%2B-%2BWest%2BFjords%252C%2BIceland.jpg","author":"Dave Morrow"},{"url":"https://lh4.googleusercontent.com/-3Swi7wFMOME/UO5TfJnFHEI/AAAAAAAAE7w/E-dFl6rGAro/s2560/Horseshoe%2BBend%2BSunset.jpg","author":"Romain Guy"}]
@@ -0,0 +1,32 @@
{
"name": "chromecast-backgrounds",
"version": "0.0.0",
"main": "lib/chromecast-backgrounds.js",
"description": "Get all those beautiful backgrounds images from the Chromecast home view.",
"homepage": "https://github.com/dconnolly/chromecast-backgrounds",
"bugs": "https://github.com/dconnolly/chromecast-backgrounds/issues",
"author": {
"name": "Deirdre Connolly",
"email": "durumcrustulum@gmail.com"
},
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/dconnolly/chromecast-backgrounds"
},
"licenses": [{
"type": "MIT"
}],
"devDependencies": {
"grunt-contrib-jshint": "~0.7.0",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-watch": "~0.5.0",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.0",
"jshint-stylish": "~0.1.3"
},
"dependencies": {
"request": "~2.33.0",
"lodash": "~2.4.1"
}
}
@@ -0,0 +1,74 @@
#!/usr/bin/env node

var fs = require('fs');
var request = require('request');
var _ = require('lodash');

var chromecastHomeURL = "https://clients3.google.com/cast/chromecast/home/v/c9541b08";
var initJSONStateRegex = /(JSON\.parse\(.+'\))/;
var backgroundsJSONFile = "backgrounds.json";

var parseChromecastHome = function(htmlString) {

var JSONParse = htmlString.match(initJSONStateRegex)[1];
var initState = eval(JSONParse); // I don't know why this is ok but JSON.parse fails.

var parsedBackgrounds = [];
for (var i in initState[1]) {
var backgroundEntry = {
url: initState[1][i][1],
author: initState[1][i][2]
};
parsedBackgrounds.push(backgroundEntry);
}
return parsedBackgrounds;
};

var updateSize = function(sizeString, backgrounds) {
var sizeRegex = /\/s\d+.*?\//;
_(backgrounds).each(function(backgroundEntry) {
backgroundEntry.url = backgroundEntry.url.replace(sizeRegex, "/"+sizeString+"/");
});
};

var saveToFile = function(filename, content) {
var jsonString = JSON.stringify(content);
fs.writeFile(filename, jsonString, function(err, data) {
if (err) {
return console.log(err);
}
if (data) {
console.log(data);
}
});
};

var getFilenames = function(backgrounds) {
_.each(_.pluck(backgrounds, 'url'), function(url) {
return _.last(url.split('/'));
});
};

var diffBackgrounds = function(A, B) {
return _.difference(getFilenames(A), getFilenames(B));
};

var scrapeChromecastBackgrounds = function() {
var backgrounds = fs.readFile(backgroundsJSONFile);

request(chromecastHomeURL, function (error, response, body) {
if (!error && response.statusCode == 200) {
var parsedBackgrounds = parseChromecastHome(body);
if (diffBackgrounds(backgrounds, parsedBackgrounds)) {
console.log("No new backgrounds.");
return;
}
backgrounds = _.union(parsedBackgrounds);
updateSize('s2560', backgrounds);
console.log("Writing: ", backgrounds);
saveToFile(backgroundsJSONFile, backgrounds);
}
});
};

scrapeChromecastBackgrounds();

0 comments on commit bb0608b

Please sign in to comment.