multistockphoto 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ class Zoonar < GenericSite
22
22
  end
23
23
 
24
24
  # TODO: Bild gedreht senden, falls Hochformat
25
- def transfer(photo)
25
+ def transfer(photo,dont_send=false,dont_log=false)
26
26
  # falls nicht in config Datei eingetragen dann nicht senden
27
27
  if @user == nil or @password == nil
28
28
  return
@@ -37,69 +37,76 @@ class Zoonar < GenericSite
37
37
  print "zoonar:#{photo.filename} ... "
38
38
  $stdout.flush
39
39
  # g = `grep "zoonar\t#{photo.filename}" sendeliste.dat` #TODO: will not work for windows
40
- g = grep(SENDELISTE, /zoonar\t#{photo.filename}/)
40
+ g = grep(SENDLIST, /zoonar\t#{photo.filename}/)
41
41
  if g.size > 0
42
42
  puts 'already sent'
43
43
  return :duplicate
44
44
  end
45
- if photo.portrait
46
- photo.drehen
45
+ if rotate_photos
46
+ if photo.portrait?
47
+ photo.drehen
48
+ end
47
49
  end
48
- agent = WWW::Mechanize.new
49
- agent.user_agent_alias = 'Linux Mozilla'
50
- page = agent.get 'http://www.zoonar.de'
50
+ unless dont_send
51
+ agent = WWW::Mechanize.new
52
+ agent.user_agent_alias = 'Linux Mozilla'
53
+ page = agent.get 'http://www.zoonar.de'
51
54
 
52
- form = page.forms[1] #TODO: besser nach Name
53
- form['loginForm[Username]'] = @config[:zoonar][:user]
54
- form['loginForm[Password]'] = @config[:zoonar][:password]
55
+ form = page.forms[1] #TODO: besser nach Name
56
+ form['loginForm[Username]'] = @config[:zoonar][:user]
57
+ form['loginForm[Password]'] = @config[:zoonar][:password]
55
58
 
56
- page = agent.submit form
57
- raise "login error" if ! page.body.include?("Hallo, #{@config[:zoonar][:user]}!")
58
- page = agent.click page.links.text('Bilder hochladen')
59
- raise "nicht auf Upload-Seite" if ! page.body.include?('bertragen Sie Ihre Bilder einzeln mit Hilfe Ihres Internet-Browsers,')
60
- form = page.form('fUploadResource')
61
- form.file_uploads.first.file_name = photo.filename
62
- # puts "form abgeschickt ..."
63
- page = agent.submit form
64
- if page.body.include?("Es ist ein Fehler aufgetreten")
65
- if page.body.include?("Das Bild ist zu klein.")
66
- raise "Bild zu klein. Muss mind. 6 MP sein"
67
- else
68
- @@errors += 1
69
- if @@errors > max_errors
70
- raise "too many errors"
59
+ page = agent.submit form
60
+ raise "login error" if ! page.body.include?("Hallo, #{@config[:zoonar][:user]}!")
61
+ page = agent.click page.links.text('Bilder hochladen')
62
+ raise "nicht auf Upload-Seite" if ! page.body.include?('bertragen Sie Ihre Bilder einzeln mit Hilfe Ihres Internet-Browsers,')
63
+ form = page.form('fUploadResource')
64
+ form.file_uploads.first.file_name = photo.filename
65
+ # puts "form abgeschickt ..."
66
+ page = agent.submit form
67
+ if page.body.include?("Es ist ein Fehler aufgetreten")
68
+ if page.body.include?("Das Bild ist zu klein.")
69
+ raise "Bild zu klein. Muss mind. 6 MP sein"
70
+ else
71
+ @@errors += 1
72
+ if @@errors > max_errors
73
+ raise "too many errors"
74
+ end
75
+ raise UploadException, "Fehler beim Upload"
71
76
  end
72
- raise "Fehler beim Upload"
73
77
  end
74
- end
75
- @@errors = 0
76
- "Es ist ein Fehler aufgetreten!
78
+ @@errors = 0
79
+ "Es ist ein Fehler aufgetreten!
77
80
 
78
81
  Bei der Übertragung des Bildes ist ein Fehler aufgetreten.
79
82
 
80
83
  Das Bild ist zu klein. Bitte übertragen Sie nur Bilder mit mehr als 6,0 MegaPixel.
81
84
 
82
85
  Bitte versuchen Sie es erneut.
83
- "
86
+ "
84
87
 
85
- sonstiger_fehler = "<b>Es ist ein Fehler aufgetreten!</b><br/>\n
88
+ sonstiger_fehler = "<b>Es ist ein Fehler aufgetreten!</b><br/>\n
86
89
  <br/>\n Bei der &Uuml;bertragung des Bildes ist ein Fehler aufgetreten.<br/>\
87
90
  n <br/>\n Die Datei konnte nicht &uuml;bertragen werden.<br/> "
88
- if page.body.include?("Vielen Dank!")
89
- puts "OK"
90
- end
91
- ok="Vielen Dank!
91
+ if page.body.include?("Vielen Dank!")
92
+ puts "OK"
93
+ end
94
+ ok="Vielen Dank!
92
95
 
93
96
  Das Bild wurde vollständig übertragen und wird nun von der Zoonar Bildredaktion geprüft.
94
97
  Wenn das Bild angenommen wird, erscheint es umgehend im Zoonar Portal und ist über die Such-Funktion zu finden.
95
98
  Falls wir das Bild ablehnen sollten, werden Sie eine Benachrichtigung per E-Mail erhalten.
96
- "
97
-
99
+ "
100
+ else
101
+ puts "OK"
102
+ end # dont_send
98
103
  #`echo "zoonar\t#{photo.filename}\t#{Time.now}" >>sendeliste.dat` #TODO:
99
-
100
- File.open(SENDELISTE,'a') {|f|
101
- f.puts "zoonar\t#{photo.filename}\t#{Time.now}"
102
- }
104
+
105
+ unless dont_log
106
+ File.open(SENDLIST,'a') {|f|
107
+ f.puts "zoonar\t#{photo.filename}\t#{Time.now}"
108
+ }
109
+ end
103
110
  true
104
111
  end
105
112
 
@@ -113,17 +120,15 @@ Falls wir das Bild ablehnen sollten, werden Sie eine Benachrichtigung per E-Mail
113
120
  end
114
121
 
115
122
  def already_sent?(photo)
116
- unless photo.class == Photo
117
- raise 'not a Photo object'
118
- end
119
- unless File.exist?(photo.filename)
120
- raise "file #{photo.filename} does not exist"
121
- end
122
- g = grep(SENDELISTE, /zoonar\t#{photo.filename}/)
123
- if g.size > 0
124
- return true
125
- else
126
- return false
127
- end
123
+ already_sent_site?(photo,'zoonar')
124
+ #
125
+ # unless photo.class == Photo
126
+ # raise 'not a Photo object'
127
+ # end
128
+ # unless File.exist?(photo.filename)
129
+ # raise "file #{photo.filename} does not exist"
130
+ # end
131
+ # g = grep(SENDLIST, /zoonar\t#{photo.filename}/)
132
+ # return g.size > 0
128
133
  end
129
134
  end
@@ -1,8 +1,8 @@
1
1
  module Multistockphoto #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 5
5
- TINY = 1
4
+ MINOR = 6
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -9,6 +9,7 @@ require 'multistockphoto/generic_site'
9
9
  require 'multistockphoto/multistockphoto'
10
10
  require 'multistockphoto/photo'
11
11
  #require 'multistockphoto/config'
12
+ require 'multistockphoto/sender'
12
13
 
13
14
  require 'multistockphoto/site_fotolia'
14
15
  require 'multistockphoto/site_zoonar'