Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. % Switch-Cam Downloader
  2.  
  3. clc;clear all;close all
  4.  
  5. dirwas = pwd;
  6.  
  7. Endday(1:12)=31;
  8. Endday(2)=28;
  9. Endday(4)=30;
  10. Endday(6)=30;
  11. Endday(9)=30;
  12. Endday(11)=30;
  13.  
  14. ShowImages = 0;
  15.  
  16. for Hour = 06%0:23;
  17. Time = sprintf('%02d',Hour);
  18. cd(dirwas);
  19. SaveDir = [ pwd filesep Time '00' ];
  20. disp([ 'Saving images to ' SaveDir ]);
  21. mkdir(SaveDir);
  22. cd(SaveDir);
  23.  
  24. for Year = 2008:2010
  25. if Year == 2010
  26. Months = 1:8;
  27. else
  28. Months = 1:12;
  29. end
  30. for Month = Months
  31. for Day = 1:Endday(Month)
  32. ImageName = [ 'http://cam.switch.ch/pano/' num2str(Year) '/' num2str(sprintf('%02d',Month)) ...
  33. num2str(sprintf('%02d',Day)) '/zueri_' num2str(Year) num2str(sprintf('%02d',Month)) ...
  34. num2str(sprintf('%02d',Day)) Time '00.jpg'];
  35. TimeString = [ num2str(sprintf('%02d',Day)) '.' num2str(sprintf('%02d',Month)) '.' num2str(Year) '-' num2str(Time) ':00' ];
  36. disp(['Downloading ' TimeString ])
  37. try
  38. Image=imread(ImageName);
  39. Image=imresize(Image,[ NaN 1080]);
  40. if ShowImages == 1
  41. pause(0.01)
  42. imshow(Image)
  43. end
  44. catch ImgNotFound
  45. disp('NOT FOUND, PROCEEDING WITH NEXT')
  46. end
  47. WriteName = [num2str(Year) '-' num2str(sprintf('%02d',Month)) '-' num2str(sprintf('%02d',Day)) '-' num2str(Time) '00.jpg'];
  48. imwrite(Image,WriteName)
  49. %% watermark with date using ImageMagick
  50. %% http://is.gd/eOZ77
  51. WaterMarkCommand = [...
  52. ' convert -size 100x14 xc:none -gravity center '...
  53. '-stroke black -strokewidth 2 -annotate 0 ' ...
  54. TimeString ' ' ...
  55. '-background none -shadow 100x3+0+0 +repage '...
  56. '-stroke none -fill white -annotate 0 ' ...
  57. TimeString ' ' ...
  58. WriteName ' +swap -gravity south -geometry +0-3 '...
  59. '-composite ' WriteName ];
  60. [ status, result] = system(WaterMarkCommand);
  61. %% watermark with date using ImageMagick
  62. end
  63. end
  64. end
  65. end
  66.  
  67. cd(dirwas);