From 9055a1e0d0a1f294f61833859ce667be5b40ce57 Mon Sep 17 00:00:00 2001 From: Nick/Nelson Date: Fri, 15 Sep 2017 23:45:39 +0000 Subject: [PATCH] Use File.join for building file paths --- vsco-dl.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vsco-dl.rb b/vsco-dl.rb index 053bae4..f07ac8d 100644 --- a/vsco-dl.rb +++ b/vsco-dl.rb @@ -15,12 +15,17 @@ images.each_with_index do |r, i| print "Image #{i + 1} of #{images.length}\r" $stdout.flush - unless File.exist? "#{user}/#{r['upload_date']}.json" and File.exist? "#{user}/#{r['upload_date']}.jpg" - File.open "#{user}/#{r['upload_date']}.json", 'w' do |file| + jsonPath = File.join user, "#{r['upload_date']}.json" + unless File.exist? jsonPath + File.open jsonPath, 'w' do |file| file.write JSON.pretty_generate r end + end + + jpgPath = File.join user, "#{r['upload_date']}.jpg" + unless File.exist? jpgPath open "https://#{r['responsive_url']}" do |f| - File.open "#{user}/#{r['upload_date']}.jpg", 'wb' do |file| + File.open jpgPath, 'wb' do |file| file.write f.read end end