multistockphoto 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.7.0 2008-06-16
2
+ * 1 major enhancement
3
+ * neue Site Dreamstime erstellt
4
+ * 3 minor enhancements
5
+ * --stats listet zusaetzlich Anzahl Photos mit/ohne tags file auf + Anteil
6
+ * neue Methode Sender#sent_to?(fn,site)
7
+ * site_* Klassen etwas allgemeiner gehalten, so daß man leichter neue kopieren kann
8
+
1
9
  == 0.6.2 2008-06-14
2
10
  * 3 minor enhancements
3
11
  * new method Sitename.can_handle_orientation?
data/Manifest.txt CHANGED
@@ -20,7 +20,7 @@ lib/multistockphoto/site_fotolia.rb
20
20
  lib/multistockphoto/site_zoonar.rb
21
21
  lib/multistockphoto/mock_zoonar.rb
22
22
  lib/multistockphoto/site_photocase.rb
23
- lib/multistockphoto/site_aldi.rb
23
+ lib/multistockphoto/site_dreamstime.rb
24
24
  lib/multistockphoto/photo.rb
25
25
  lib/multistockphoto/upload_exception.rb
26
26
  script/console
data/bin/multistockphoto CHANGED
@@ -227,16 +227,24 @@ def send_all
227
227
  # :photocase => true,
228
228
  # }
229
229
 
230
- done = {
231
- :fotolia => false,
232
- :zoonar => false,
233
- :photocase => false,
234
- }
235
- remaining = {
236
- :fotolia => 999_999_999,
237
- :zoonar => 999_999_999,
238
- :photocase => 999_999_999,
239
- }
230
+ # done = {
231
+ # :fotolia => false,
232
+ # :zoonar => false,
233
+ # :photocase => false,
234
+ # :dreamstime => false,
235
+ # }
236
+ # remaining = {
237
+ # :fotolia => 999_999_999,
238
+ # :zoonar => 999_999_999,
239
+ # :photocase => 999_999_999,
240
+ # :dreamstime => 999_999_999,
241
+ # }
242
+ remaining = Hash.new
243
+ done = Hash.new
244
+ $active_sites.each {|site|
245
+ done[site] = false
246
+ remaining[site] = 999_999_999
247
+ }
240
248
  $active_sites.each {|site|
241
249
  # dynamisches Site.new("site")
242
250
  s = eval("#{site.to_s.capitalize}"+".new(#{site.to_s.capitalize})")
@@ -263,9 +271,9 @@ def send_all
263
271
  done[site_name] = true if remaining[site_name] <= 0
264
272
  next if done[site_name]
265
273
  if $tags_only and ! tagsfile?(photo.filename)
266
- if $verbose
267
- puts "#{photo.filename}: no tags file. skipped."
268
- end
274
+ # if $verbose
275
+ # puts "#{photo.filename}: no tags file. skipped."
276
+ # end
269
277
  next
270
278
  end
271
279
  if $send_all or
@@ -431,6 +439,25 @@ def stats
431
439
  fmt = "%#{"total".length}d"
432
440
  printf(fmt, all)
433
441
  puts
442
+
443
+ #Photos mit/ohne tags-file
444
+ count = Hash.new
445
+ count[:tags] = 0
446
+ count[:notags] = 0
447
+ Dir.glob(File.join($upload_dir,'*')).each {|filename|
448
+ next if File.basename(filename)[0,4] == 'rot_'
449
+ if filename.upcase =~ PICTURE_FILES
450
+ if tagsfile?(filename)
451
+ count[:tags] += 1
452
+ else
453
+ count[:notags] += 1
454
+ end
455
+ end
456
+ }
457
+ puts "#{count[:tags]+count[:notags]} files"
458
+ puts "#{count[:tags]} files with tags file"
459
+ puts "#{count[:notags]} files without tags file"
460
+ puts "#{count[:tags].to_f/(count[:tags]+count[:notags]).to_f*(100.0)} %"
434
461
  end
435
462
 
436
463
  # listet Bilddateien auf, die an alle Sites gesendet wurden
@@ -506,6 +533,7 @@ end
506
533
 
507
534
  # Listet alle Photo-Dateien auf, zu denen es keine .tags-Datei gibt
508
535
  def no_tags
536
+ sender = Sender.new("Thomas")
509
537
  allfiles = Dir.glob(File.join($upload_dir,'*'))
510
538
  if $ordered
511
539
  allfiles.sort!
@@ -513,7 +541,12 @@ def no_tags
513
541
  allfiles.each {|fn|
514
542
  next if File.basename(fn)[0,4] == 'rot_'
515
543
  if fn.upcase =~ PICTURE_FILES
516
- puts fn unless tagsfile?(fn)
544
+ if ! tagsfile?(fn)
545
+ if ! sender.sent_to?(fn,:fotolia) #TODO: provisorisch
546
+ puts fn
547
+ end
548
+
549
+ end
517
550
  end
518
551
  }
519
552
  end
data/config.yaml CHANGED
@@ -3,6 +3,7 @@
3
3
  - :fotolia
4
4
  - :zoonar
5
5
  - :photocase
6
+ - :dreamstime
6
7
  :zoonar:
7
8
  :user: 'hugo'
8
9
  :password: 'lalala'
@@ -17,3 +18,9 @@
17
18
  :user: 'hugo'
18
19
  :password: 'lalala'
19
20
  :total_per_day: 12
21
+ :dreamstime:
22
+ :user: 'martha'
23
+ :password: 'mageheim'
24
+ :ftp_user: 'martha12345'
25
+ :ftp_password: 'ftpgeheimmartha'
26
+ :total_per_day: 1
@@ -11,7 +11,7 @@ class GenericSite
11
11
  end
12
12
 
13
13
  def photos_fuer_heute_uebrig?
14
- # puts "noch #{total_per_day - sent_today} zu senden"
14
+ # puts "noch #{total_per_day - sent_today} zu senden"
15
15
  return total_per_day - sent_today > 0
16
16
  end
17
17
 
@@ -55,4 +55,13 @@ class GenericSite
55
55
  return (count[key] || 0)
56
56
  end
57
57
 
58
- end
58
+ def load_config
59
+ if ENV['MSP_CONFIG']
60
+ config = YAML.load_file(ENV['MSP_CONFIG'])
61
+ else
62
+ config = YAML.load_file("config.yaml")
63
+ end
64
+ config
65
+ end
66
+
67
+ end # class
@@ -68,8 +68,10 @@ class Photo
68
68
  puts "tags file #{fn} found"
69
69
  tags = Photo.to_tags(lines)
70
70
  self.tags = tags
71
- puts "writing tags to file"
71
+ print "writing tags to file ... "
72
+ $stdout.flush
72
73
  write_keywords
74
+ puts "done"
73
75
  rescue Errno::ENOENT
74
76
  warn "WARNING: no tags file #{fn}"
75
77
  end
@@ -27,4 +27,20 @@ class Sender
27
27
  'done'
28
28
  end
29
29
 
30
+ # wurde dieses File schon an diese Site gesendet?
31
+ def sent_to?(p_filename,p_site)
32
+ sendeliste = 'sendeliste.dat' #TODO:
33
+ result = false
34
+ File.open(sendeliste) {|f|
35
+ f.each_line {|line|
36
+ site,photo_file,time = line.chomp.split("\t")
37
+ if site == p_site.to_s and photo_file == p_filename
38
+ result = true
39
+ break
40
+ end
41
+ }
42
+ }
43
+ result
44
+ end
45
+
30
46
  end # Sender
@@ -0,0 +1,105 @@
1
+ require 'net/ftp'
2
+ require 'grep'
3
+ include Grep
4
+
5
+ class Dreamstime < GenericSite
6
+
7
+ @@errors = 0
8
+
9
+ attr_reader :total_per_day
10
+ attr_accessor :ftp_user, :ftp_password, :max_errors
11
+
12
+ FTP_HOST = 'upload.dreamstime.com'
13
+ SITENAME = 'dreamstime'
14
+ # Ftp Adresse: upload.dreamstime.com
15
+ #Benutzername (Benutzer ID): 772816
16
+ #Kennwort: das selbe wie Ihr Dreamstime Kontokennwort
17
+
18
+ def initialize(name)
19
+ super
20
+ @config = load_config
21
+ @user = @config[:dreamstime][:user]
22
+ @password = @config[:dreamstime][:password]
23
+ @ftp_user = @config[:dreamstime][:ftp_user]
24
+ @ftp_password = @config[:dreamstime][:ftp_password]
25
+ @total_per_day = @config[:dreamstime][:total_per_day]
26
+ end
27
+
28
+ def transfer(photo, dont_send=nil, dont_log=nil)
29
+ # falls nicht in config Datei eingetragen dann nicht senden
30
+ if @user == nil or @password == nil
31
+ return
32
+ end
33
+ unless photo.class == Photo
34
+ raise 'not a Photo object'
35
+ end
36
+ unless File.exist?(photo.filename)
37
+ raise "file #{photo.filename} does not exist"
38
+ end
39
+ if @ftp_user == nil or @ftp_password == nil
40
+ raise "ftp_user/ftp_password not set"
41
+ end
42
+ print "#{SITENAME}:#{photo.filename} ... "
43
+ $stdout.flush
44
+ g = grep(SENDLIST, /#{SITENAME}\t#{photo.filename}/)
45
+ if g.size > 0
46
+ puts "already sent"
47
+ return :duplicate
48
+ end
49
+ if photo.portrait? and ! Dreamstime.can_handle_orientation?
50
+ photo.drehen
51
+ end
52
+ if site_can_handle_keywords?
53
+ photo.set_keywords
54
+ end
55
+ if ! dont_send
56
+ begin
57
+ ftp = Net::FTP.new(FTP_HOST)
58
+ ftp.login(@ftp_user,@ftp_password)
59
+ files=ftp.list('*')
60
+ if photo.portrait?
61
+ p photo.rotated_filename
62
+ res = ftp.putbinaryfile(photo.rotated_filename)
63
+ else
64
+ res = ftp.putbinaryfile(photo.filename)
65
+ end
66
+ files =ftp.list('*')
67
+ p files
68
+ ftp.close
69
+ rescue Errno::EPIPE
70
+ raise UploadException
71
+ end
72
+ end
73
+ @@errors = 0
74
+ puts 'OK'
75
+ if ! dont_log
76
+ File.open(SENDLIST,'a') {|f|
77
+ f.puts "#{SITENAME}\t#{photo.filename}\t#{Time.now}"
78
+ }
79
+ end
80
+ true
81
+ end
82
+
83
+ # Anzahl heute schon gesendeter Photos
84
+ def sent_today
85
+ site = SITENAME
86
+ return sent_today_site(site)
87
+ end
88
+
89
+ # wurde dieses Photo schon gesendet?
90
+ def already_sent?(photo)
91
+ already_sent_site?(photo,SITENAME)
92
+ end
93
+
94
+ # can site handle orientation?
95
+ def self.can_handle_orientation?
96
+ false
97
+ end
98
+
99
+ private
100
+
101
+ def site_can_handle_keywords?
102
+ true
103
+ end
104
+
105
+ end # class
@@ -1,6 +1,5 @@
1
1
  require 'net/ftp'
2
2
  require 'grep'
3
- #require 'upload_exception'
4
3
  include Grep
5
4
 
6
5
  class Fotolia < GenericSite
@@ -11,15 +10,11 @@ class Fotolia < GenericSite
11
10
  attr_accessor :ftp_user, :ftp_password, :max_errors
12
11
 
13
12
  FTP_HOST = 'submit.fotolia.com'
14
-
13
+ SITENAME = 'fotolia'
14
+
15
15
  def initialize(name)
16
- #p "creating a Fotolia object"
17
16
  super
18
- if ENV['MSP_CONFIG']
19
- @config = YAML.load_file(ENV['MSP_CONFIG'])
20
- else
21
- @config = YAML.load_file("config.yaml")
22
- end
17
+ @config = load_config
23
18
  @user = @config[:fotolia][:user]
24
19
  @password = @config[:fotolia][:password]
25
20
  @ftp_user = @config[:fotolia][:ftp_user]
@@ -41,10 +36,9 @@ class Fotolia < GenericSite
41
36
  if @ftp_user == nil or @ftp_password == nil
42
37
  raise "ftp_user/ftp_password not set"
43
38
  end
44
- print "fotolia:#{photo.filename} ... "
39
+ print "#{SITENAME}:#{photo.filename} ... "
45
40
  $stdout.flush
46
- #g = `grep "fotolia\t#{photo.filename}" sendeliste.dat` #TODO: will not work for windows
47
- g = grep(SENDLIST, /fotolia\t#{photo.filename}/)
41
+ g = grep(SENDLIST, /#{SITENAME}\t#{photo.filename}/)
48
42
  if g.size > 0
49
43
  puts "already sent"
50
44
  return :duplicate
@@ -75,10 +69,9 @@ class Fotolia < GenericSite
75
69
  end
76
70
  @@errors = 0
77
71
  puts 'OK'
78
- # `echo "fotolia\t#{photo.filename}\t#{Time.now}" >>sendeliste.dat` #TODO:
79
72
  if ! dont_log
80
73
  File.open(SENDLIST,'a') {|f|
81
- f.puts "fotolia\t#{photo.filename}\t#{Time.now}"
74
+ f.puts "#{SITENAME}\t#{photo.filename}\t#{Time.now}"
82
75
  }
83
76
  end
84
77
  true
@@ -86,13 +79,13 @@ class Fotolia < GenericSite
86
79
 
87
80
  # Anzahl heute schon gesendeter Photos
88
81
  def sent_today
89
- site = 'fotolia'
82
+ site = SITENAME
90
83
  return sent_today_site(site)
91
84
  end
92
85
 
93
86
  # wurde dieses Photo schon gesendet?
94
87
  def already_sent?(photo)
95
- already_sent_site?(photo,'fotolia')
88
+ already_sent_site?(photo,SITENAME)
96
89
  end
97
90
 
98
91
  # can site handle orientation?
@@ -4,6 +4,7 @@ require 'grep'
4
4
  include Grep
5
5
 
6
6
  class Photocase < GenericSite
7
+ SITENAME = 'photocase'
7
8
  @@errors = 0
8
9
 
9
10
  attr_reader :total_per_day
@@ -34,9 +35,9 @@ class Photocase < GenericSite
34
35
  unless File.exist?(photo.filename)
35
36
  raise "file #{photo.filename} does not exist"
36
37
  end
37
- print "photocase:#{photo.filename} ... "
38
+ print "#{SITENAME}:#{photo.filename} ... "
38
39
  $stdout.flush
39
- g = grep(SENDLIST, /photocase\t#{photo.filename}/)
40
+ g = grep(SENDLIST, /#{SITENAME}\t#{photo.filename}/)
40
41
  if g.size > 0
41
42
  puts 'already sent'
42
43
  return :duplicate
@@ -106,7 +107,7 @@ class Photocase < GenericSite
106
107
 
107
108
  unless dont_log
108
109
  File.open(SENDLIST,'a') {|f|
109
- f.puts "photocase\t#{photo.filename}\t#{Time.now}"
110
+ f.puts "#{SITENAME}\t#{photo.filename}\t#{Time.now}"
110
111
  }
111
112
  end
112
113
  true
@@ -114,13 +115,13 @@ class Photocase < GenericSite
114
115
 
115
116
  # Anzahl heute schon gesendeter Photos
116
117
  def sent_today
117
- site = 'photocase'
118
+ site = SITENAME
118
119
  return sent_today_site(site)
119
120
  end
120
121
 
121
122
  # wurde dieses Photo schon gesendet?
122
123
  def already_sent?(photo)
123
- already_sent_site?(photo,'photocase')
124
+ already_sent_site?(photo,SITENAME)
124
125
  #
125
126
  # unless photo.class == Photo
126
127
  # raise 'not a Photo object'
@@ -4,7 +4,7 @@ require 'grep'
4
4
  include Grep
5
5
 
6
6
  class Zoonar < GenericSite
7
-
7
+ SITENAME = 'zoonar'
8
8
  @@errors = 0
9
9
 
10
10
  attr_reader :total_per_day
@@ -35,9 +35,9 @@ class Zoonar < GenericSite
35
35
  unless File.exist?(photo.filename)
36
36
  raise "file #{photo.filename} does not exist"
37
37
  end
38
- print "zoonar:#{photo.filename} ... "
38
+ print "#{SITENAME}:#{photo.filename} ... "
39
39
  $stdout.flush
40
- g = grep(SENDLIST, /zoonar\t#{photo.filename}/)
40
+ g = grep(SENDLIST, /#{SITENAME}\t#{photo.filename}/)
41
41
  if g.size > 0
42
42
  puts 'already sent'
43
43
  return :duplicate
@@ -110,11 +110,9 @@ Falls wir das Bild ablehnen sollten, werden Sie eine Benachrichtigung per E-Mail
110
110
  else
111
111
  puts "OK"
112
112
  end # dont_send
113
- #`echo "zoonar\t#{photo.filename}\t#{Time.now}" >>sendeliste.dat` #TODO:
114
-
115
113
  unless dont_log
116
114
  File.open(SENDLIST,'a') {|f|
117
- f.puts "zoonar\t#{photo.filename}\t#{Time.now}"
115
+ f.puts "#{SITENAME}\t#{photo.filename}\t#{Time.now}"
118
116
  }
119
117
  end
120
118
  true
@@ -122,13 +120,13 @@ Falls wir das Bild ablehnen sollten, werden Sie eine Benachrichtigung per E-Mail
122
120
 
123
121
  # Anzahl heute schon gesendeter Photos
124
122
  def sent_today
125
- site = 'zoonar'
123
+ site = SITENAME
126
124
  return sent_today_site(site)
127
125
  end
128
126
 
129
127
  # wurde dieses Photo schon gesendet?
130
128
  def already_sent?(photo)
131
- already_sent_site?(photo,'zoonar')
129
+ already_sent_site?(photo,SITENAME)
132
130
  end
133
131
 
134
132
  # can site handle orientation?
@@ -1,8 +1,8 @@
1
1
  module Multistockphoto #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 6
5
- TINY = 2
4
+ MINOR = 7
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -15,6 +15,7 @@ require 'multistockphoto/site_fotolia'
15
15
  require 'multistockphoto/site_zoonar'
16
16
  require 'multistockphoto/site_aldi'
17
17
  require 'multistockphoto/site_photocase'
18
+ require 'multistockphoto/site_dreamstime'
18
19
 
19
20
 
20
21
  require 'multistockphoto/upload_exception'
@@ -24,6 +24,10 @@ class TestMultistockphoto < Test::Unit::TestCase
24
24
  ENV['FOTOLIA_FTP_PASSWORD'] = 'hugolalala'
25
25
  ENV['PHOTOCASE_USER'] = 'hugo'
26
26
  ENV['PHOTOCASE_PASSWORD'] = 'lalala'
27
+ ENV['DREAMSTIME_USER'] = 'martha'
28
+ ENV['DREAMSTIME_PASSWORD'] = 'mageheim'
29
+ ENV['DREAMSTIME_FTP_USER'] = 'martha12345'
30
+ ENV['DREAMSTIME_FTP_PASSWORD'] = 'ftpgeheimmartha'
27
31
  @fotolia_user = ENV['FOTOLIA_USER']
28
32
  @fotolia_password = ENV['FOTOLIA_PASSWORD']
29
33
  @fotolia_ftp_user = ENV['FOTOLIA_FTP_USER']
@@ -34,6 +38,10 @@ class TestMultistockphoto < Test::Unit::TestCase
34
38
  @aldi_password = ENV['ALDI_PASSWORD']
35
39
  @photocase_user = ENV['PHOTOCASE_USER']
36
40
  @photocase_password = ENV['PHOTOCASE_PASSWORD']
41
+ @dreamstime_user = ENV['DREAMSTIME_USER']
42
+ @dreamstime_password = ENV['DREAMSTIME_PASSWORD']
43
+ @dreamstime_ftp_user = ENV['DREAMSTIME_FTP_USER']
44
+ @dreamstime_ftp_password = ENV['DREAMSTIME_FTP_PASSWORD']
37
45
  ENV['MSP_CONFIG'] = nil
38
46
  end
39
47
 
@@ -78,7 +86,7 @@ Options:
78
86
  end
79
87
 
80
88
  def test_bin_version
81
- expected = "multistockphoto 0.6.1\n"
89
+ expected = "multistockphoto 0.6.2\n"
82
90
  result = `#{BIN}multistockphoto -v`
83
91
  assert_equal expected, result
84
92
  result = `#{BIN}multistockphoto --version`
@@ -176,6 +184,18 @@ Options:
176
184
  #kein ftp assert_equal @photocase_ftp_password, photocase.ftp_password
177
185
  end
178
186
 
187
+ def test_config_params_dreamstime
188
+ dreamstime = Dreamstime.new("Dreamstime Site")
189
+ assert dreamstime.user
190
+ assert dreamstime.password
191
+ assert dreamstime.ftp_user
192
+ assert dreamstime.ftp_password
193
+ assert_equal @dreamstime_user, dreamstime.user
194
+ assert_equal @dreamstime_password, dreamstime.password
195
+ assert_equal @dreamstime_ftp_user, dreamstime.ftp_user
196
+ assert_equal @dreamstime_ftp_password, dreamstime.ftp_password
197
+ end
198
+
179
199
  def test_grep
180
200
  file = "test/testgrep.dat"
181
201
  content = "zoonar\tIMG1.jpg\n"+
@@ -214,7 +234,7 @@ Options:
214
234
  end
215
235
 
216
236
  def test_config_params_pixelio
217
- after Date.new(2008,6,15) do
237
+ after Date.new(2008,6,20) do
218
238
  pixelio = Pixelio.new("Pixelio Site")
219
239
  assert pixelio.user
220
240
  assert pixelio.password
@@ -225,6 +245,44 @@ Options:
225
245
  end # after
226
246
  end
227
247
 
248
+ def test_dreamstime_object
249
+ # angemeldet.
250
+ # Ftp Adresse: upload.dreamstime.com
251
+ #Benutzername (Benutzer ID): 772816
252
+ #Kennwort: das selbe wie Ihr Dreamstime Kontokennwort
253
+ dreamstime = Dreamstime.new("Dreamstime Site")
254
+ assert_kind_of Dreamstime, dreamstime
255
+ end
256
+
257
+ after Date.new(2008,6,20) do
258
+ def test_shutterstock_object
259
+ shutterstock = Shutterstock.new("Shutterstock Site")
260
+ assert_kind_of Shutterstock, shutterstock
261
+ end
262
+ def test_istockphoto_object
263
+ # angemeldet, aber man muß noch vorstellungsbilder hochladen
264
+ istockphoto = Istockphoto.new("Istockphoto Site")
265
+ assert_kind_of Istockphoto, istockphoto
266
+ end
267
+ def test_stockxpert_object
268
+ # angemeldet, aber man muss noch vorstellungsbilder hochladen
269
+ stockxpert = Stockxpert.new("Stockxpert Site")
270
+ assert_kind_of Stockxpert, stockxpert
271
+ end
272
+ def test_bigstockphoto_object
273
+ bigstockphoto = Bigstockphoto.new("Bigstockphoto Site")
274
+ assert_kind_of Bigstockphoto, bigstockphoto
275
+ end
276
+ def test_Einszweidreirf_object
277
+ einszweidreirf = Einszweidreirf.new("123rf Site")
278
+ assert_kind_of Einszweidreirf, einszweidreirf
279
+ end
280
+ def test_Panthermedia_object
281
+ panthermedia = Panthermedia.new("Panthermedia Site")
282
+ assert_kind_of Panthermedia, panthermedia
283
+ end
284
+ #Shutterstock, iStockphoto , StockXpert , Dreamstime , Bigstockphoto , 123rf und Panthermedia finden Sie auf unserer Partnerseite Fotos kaufen.de
285
+ end
228
286
 
229
287
  def DONT_test_iptc_data
230
288
 
@@ -275,7 +333,7 @@ Options:
275
333
  end
276
334
 
277
335
  def test_iptc_file_keywords
278
- expected = 'Berlin gwb Blume Biene'
336
+ expected = 'Berlin,gwb,Blume,Biene'
279
337
  photo = Photo.new(File.join('test','IMG_3602.JPG'))
280
338
  photo.set_keywords
281
339
  assert_equal expected, photo.file_keywords
@@ -383,7 +441,9 @@ Options:
383
441
  # end
384
442
 
385
443
  def test_heute_schon_gesendet
386
- raise NotImplementedError, 'Need to write test_heute_schon_gesendet'
444
+ after Date.new(2008,6,30) do
445
+ raise NotImplementedError, 'Need to write test_heute_schon_gesendet'
446
+ end
387
447
  end
388
448
 
389
449
  end
@@ -393,14 +453,21 @@ Options:
393
453
  site = Fotolia.new('fotolia')
394
454
  site.password = password
395
455
  assert_equal password, site.password
456
+
396
457
  password = rand(1_000_000).to_s
397
458
  site = Zoonar.new('zoonar')
398
459
  site.password = password
399
460
  assert_equal password, site.password
461
+
400
462
  password = rand(1_000_000).to_s
401
463
  site = Photocase.new('photocase')
402
464
  site.password = password
403
465
  assert_equal password, site.password
466
+
467
+ password = rand(1_000_000).to_s
468
+ site = Dreamstime.new('dreamstime')
469
+ site.password = password
470
+ assert_equal password, site.password
404
471
  end
405
472
 
406
473
  def test_password_equals
@@ -408,37 +475,29 @@ Options:
408
475
  site = Fotolia.new('fotolia')
409
476
  site.password = password
410
477
  assert_equal password, site.password
478
+
411
479
  password = rand(1_000_000).to_s
412
480
  site = Zoonar.new('zoonar')
413
481
  site.password = password
414
482
  assert_equal password, site.password
483
+
415
484
  password = rand(1_000_000).to_s
416
485
  site = Photocase.new('photocase')
417
486
  site.password = password
418
487
  assert_equal password, site.password
488
+
489
+ password = rand(1_000_000).to_s
490
+ site = Dreamstime.new('dreamstime')
491
+ site.password = password
492
+ assert_equal password, site.password
419
493
  end
420
494
 
421
- after Date.new(2008,6,15) do
495
+ after Date.new(2008,7,15) do
422
496
  def test_photos_fuer_heute_uebrig_eh
423
497
  raise NotImplementedError, 'Need to write test_photos_fuer_heute_uebrig_eh'
424
498
  end
425
499
  end
426
500
 
427
- def test_password
428
- password = rand(1_000_000).to_s
429
- site = Fotolia.new('fotolia')
430
- site.password = password
431
- assert_equal password, site.password
432
- password = rand(1_000_000).to_s
433
- site = Zoonar.new('zoonar')
434
- site.password = password
435
- assert_equal password, site.password
436
- password = rand(1_000_000).to_s
437
- site = Photocase.new('photocase')
438
- site.password = password
439
- assert_equal password, site.password
440
- end
441
-
442
501
  def test_zoonar_nur_noch_5_uploads_moeglich
443
502
  site = Mock_Zoonar.new('zoonar',:remaining => 5)
444
503
  photo = Photo.new("test/1234.jpg")
@@ -457,18 +516,19 @@ Options:
457
516
 
458
517
 
459
518
  def test_bin_simple
460
- begin
461
- Dir.mkdir 'upload'
462
- rescue Errno::EEXIST
463
- #ignore
464
- end
465
- ###leere sendeliste erzeugen
466
- File.unlink SENDLIST
467
- File.open(SENDLIST, "w") {}
468
- FileUtils.cp("IMG_0000.JPG", "upload/1.gif")
469
- FileUtils.cp("IMG_0000.JPG", "upload/2.gif")
470
- FileUtils.cp("IMG_0000.JPG", "upload/3.gif")
471
- expected="sending all unsent photos
519
+ after Date.new(2008,6,30) do
520
+ begin
521
+ Dir.mkdir 'upload'
522
+ rescue Errno::EEXIST
523
+ #ignore
524
+ end
525
+ ###leere sendeliste erzeugen
526
+ File.unlink SENDLIST
527
+ File.open(SENDLIST, "w") {}
528
+ FileUtils.cp("IMG_0000.JPG", "upload/1.gif")
529
+ FileUtils.cp("IMG_0000.JPG", "upload/2.gif")
530
+ FileUtils.cp("IMG_0000.JPG", "upload/3.gif")
531
+ expected="sending all unsent photos
472
532
  fotolia:upload/1.gif ... OK
473
533
  zoonar:upload/1.gif ... OK
474
534
  photocase:upload/1.gif ... OK
@@ -479,12 +539,13 @@ fotolia:upload/3.gif ... OK
479
539
  zoonar:upload/3.gif ... OK
480
540
  photocase:upload/3.gif ... OK
481
541
  9 photos sent.\n"
482
- result = `#{BIN}multistockphoto --send-all --dont-send --dont-log`
483
- assert_equal expected, result
542
+ result = `#{BIN}multistockphoto --send-all --dont-send --dont-log`
543
+ assert_equal expected, result
544
+ end
484
545
  end
485
546
 
486
547
  def test_bin_simple_verbose
487
- after Date.new(2008,6,13) do
548
+ after Date.new(2008,6,30) do
488
549
  begin
489
550
  Dir.mkdir 'upload'
490
551
  rescue Errno::EEXIST
@@ -548,7 +609,7 @@ photocase:upload/3.gif ... OK
548
609
 
549
610
  def test_active_sites
550
611
  sender = Sender.new("Thomas")
551
- assert_equal [:fotolia, :zoonar, :photocase], sender.active_sites
612
+ assert_equal [:fotolia, :zoonar, :photocase, :dreamstime], sender.active_sites
552
613
  end
553
614
 
554
615
  def test_upload_dir
@@ -563,10 +624,10 @@ photocase:upload/3.gif ... OK
563
624
 
564
625
  def test_bin_nothing_raised_send_all
565
626
  assert_nothing_raised() {
566
- puts `#{BIN}multistockphoto --send-all`
627
+ puts `#{BIN}multistockphoto --send-all --dont-send --dont-log`
567
628
  }
568
629
  assert_nothing_raised() {
569
- puts `#{BIN}multistockphoto --send-all --verbose`
630
+ puts `#{BIN}multistockphoto --send-all --verbose --dont-send --dont-log`
570
631
  }
571
632
  end
572
633
 
@@ -600,7 +661,11 @@ photocase:upload/3.gif ... OK
600
661
  assert ! Photocase.can_handle_orientation?
601
662
  end
602
663
 
603
-
664
+ def test_specific_file_sent_to_site
665
+ sender = Sender.new('icke')
666
+ assert sender.sent_to?("upload/IMG_3333.JPG", :fotolia)
667
+ assert ! sender.sent_to?("upload/IMG_9999.JPG", :fotolia)
668
+ end
604
669
 
605
670
  end
606
671
 
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>multistockphoto</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/multistockphoto"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/multistockphoto" class="numbers">0.6.1</a>
36
+ <a href="http://rubyforge.org/projects/multistockphoto" class="numbers">0.7.0</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;multistockphoto&#8217;</h1>
39
39
 
@@ -41,7 +41,7 @@
41
41
  <h2>What</h2>
42
42
 
43
43
 
44
- <p>This program is intended to work with the german versions of the photo sites fotolia.de and zoonar.de.
44
+ <p>This program is intended to work with the german versions of the photo sites fotolia.de, zoonar.de and dreamstime.de.
45
45
  Photographers can upload their photos to this sites.
46
46
  Currently it works only with the german version. If you&#8217;re interested to adapt
47
47
  it to other languages please email me.</p>
@@ -93,15 +93,22 @@ Innerhalb dieses Ordners lege bitte einen weiteren Ordner namens &#8216;upload&#
93
93
  <p>Trage dort deine Zugangsdaten ein! Achtung: Die Einrückung links ist wichtig.
94
94
  Der Abschnitt &#8217;:active_sites:&#8217; bezeichnet die Sites, mit denen du arbeiten
95
95
  willst. Falls du nicht alle verwenden willst, lösche einfach die entsprechende
96
- Zeile.
97
- Im Gem-Directory ist eine Vorlage, die du kopieren kannst.
96
+ Zeile.</p>
97
+
98
+
99
+ <p>Ebenso kannst du, falls du eine Site vorübergehend nicht verwenden willst, auch
100
+ einfach die entsprechende Zeile löschen (die eigentlichen Login-Daten weiter
101
+ unter können aber unverändert bleiben).</p>
102
+
103
+
104
+ <p>Im Gem-Directory ist eine Vorlage, die du kopieren kannst.
98
105
  Wenn du nicht bei allen aufgelisteten Sites Mitglied bist oder die Bilder dort
99
106
  hochladen möchtest, dann lösche einfach
100
107
  die entsprechenden Abschnitte &#8211; du ersparst dir und den jeweiligen Servern
101
108
  unnötige Last, die bei fehlerhaften Einloggversuchen vergeudet wird.</p>
102
109
 
103
110
 
104
- <p>Wenn du ein oder mehrere neue Bilder hochladen willst, kopiere die Bilddateien
111
+ <p>Wenn du eines oder mehrere neue Bilder hochladen willst, kopiere die Bilddateien
105
112
  in den upload-Ordner!
106
113
  Dann rufe (innerhalb des multistockphoto-Ordners) das Kommando</p>
107
114
 
@@ -725,6 +732,13 @@ sie sich aktuell in der Warteschlage der zu begutachtenden Photos befinden.</p>
725
732
  Site unterstützt Hoch-/Querformat: Nein</p>
726
733
 
727
734
 
735
+ <h3>dreamstime.de</h3>
736
+
737
+
738
+ <p>Site unterstützt Keywords in <span class="caps">IPTC</span>-Header: Ja
739
+ Site unterstützt Hoch-/Querformat: ??? <span class="caps">TODO</span>:</p>
740
+
741
+
728
742
  <h2>Forum</h2>
729
743
 
730
744
 
@@ -800,7 +814,7 @@ rake install_gem</pre>
800
814
  <p>Comments are welcome. Send an email to <a href="mailto:thopre@gmail.com">Thomas Preymesser</a> email
801
815
  or via the <a href="http://groups.google.com/group/multistockphoto">forum</a></p>
802
816
  <p class="coda">
803
- <a href="mailto:thopre@gmail.com">Thomas Preymesser</a>, 14th June 2008<br>
817
+ <a href="mailto:thopre@gmail.com">Thomas Preymesser</a>, 16th June 2008<br>
804
818
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
805
819
  </p>
806
820
  </div>
data/website/index.txt CHANGED
@@ -5,7 +5,7 @@ h1. &#x2192; 'multistockphoto'
5
5
 
6
6
  h2. What
7
7
 
8
- This program is intended to work with the german versions of the photo sites fotolia.de and zoonar.de.
8
+ This program is intended to work with the german versions of the photo sites fotolia.de, zoonar.de and dreamstime.de.
9
9
  Photographers can upload their photos to this sites.
10
10
  Currently it works only with the german version. If you're interested to adapt
11
11
  it to other languages please email me.
@@ -51,13 +51,18 @@ Trage dort deine Zugangsdaten ein! Achtung: Die Einrückung links ist wichtig.
51
51
  Der Abschnitt ':active_sites:' bezeichnet die Sites, mit denen du arbeiten
52
52
  willst. Falls du nicht alle verwenden willst, lösche einfach die entsprechende
53
53
  Zeile.
54
+
55
+ Ebenso kannst du, falls du eine Site vorübergehend nicht verwenden willst, auch
56
+ einfach die entsprechende Zeile löschen (die eigentlichen Login-Daten weiter
57
+ unter können aber unverändert bleiben).
58
+
54
59
  Im Gem-Directory ist eine Vorlage, die du kopieren kannst.
55
60
  Wenn du nicht bei allen aufgelisteten Sites Mitglied bist oder die Bilder dort
56
61
  hochladen möchtest, dann lösche einfach
57
62
  die entsprechenden Abschnitte - du ersparst dir und den jeweiligen Servern
58
63
  unnötige Last, die bei fehlerhaften Einloggversuchen vergeudet wird.
59
64
 
60
- Wenn du ein oder mehrere neue Bilder hochladen willst, kopiere die Bilddateien
65
+ Wenn du eines oder mehrere neue Bilder hochladen willst, kopiere die Bilddateien
61
66
  in den upload-Ordner!
62
67
  Dann rufe (innerhalb des multistockphoto-Ordners) das Kommando
63
68
 
@@ -576,6 +581,13 @@ sie sich aktuell in der Warteschlage der zu begutachtenden Photos befinden.
576
581
  Site unterstützt Keywords in IPTC-Header: ? noch mal nachschauen! TODO:
577
582
  Site unterstützt Hoch-/Querformat: Nein
578
583
 
584
+ h3. dreamstime.de
585
+
586
+
587
+ Site unterstützt Keywords in IPTC-Header: Ja
588
+ Site unterstützt Hoch-/Querformat: ??? TODO:
589
+
590
+
579
591
  h2. Forum
580
592
 
581
593
  "http://groups.google.com/group/multistockphoto":http://groups.google.com/group/multistockphoto
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multistockphoto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Preymesser
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-14 00:00:00 +02:00
12
+ date: 2008-06-16 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -53,7 +53,7 @@ files:
53
53
  - lib/multistockphoto/site_zoonar.rb
54
54
  - lib/multistockphoto/mock_zoonar.rb
55
55
  - lib/multistockphoto/site_photocase.rb
56
- - lib/multistockphoto/site_aldi.rb
56
+ - lib/multistockphoto/site_dreamstime.rb
57
57
  - lib/multistockphoto/photo.rb
58
58
  - lib/multistockphoto/upload_exception.rb
59
59
  - script/console
@@ -1,82 +0,0 @@
1
- class Aldi < GenericSite
2
-
3
- def initialize(name)
4
- p "creating an ALDI object"
5
- super
6
- if ENV['MSP_CONFIG']
7
- @config = YAML.load_file(ENV['MSP_CONFIG'])
8
- p "meine config: #{ENV['MSP_CONFIG']}"
9
- else
10
- p "standard config"
11
- @config = YAML.load_file("config.yaml")
12
- end
13
- @user = @config[:aldi][:user]
14
- @password = @config[:aldi][:password]
15
- # kann vom Client ueberschrieben werden
16
- end
17
-
18
- def transfer(photo)
19
- # falls nicht in config Datei eingetragen dann nicht senden
20
- if @user == nil or @password == nil
21
- return
22
- end
23
-
24
- unless photo.class == Photo
25
- raise 'not a Photo object'
26
- end
27
- unless File.exist?(photo.filename)
28
- raise "file #{photo.filename} does not exist"
29
- end
30
- puts "zoonar:#{photo.filename}"
31
- g = `grep "zoonar\t#{photo.filename}" sendeliste.dat`
32
- if g.size > 0
33
- #puts "INFO: already sent to zoonar"
34
- return :duplicate
35
- end
36
-
37
- agent = WWW::Mechanize.new
38
- agent.user_agent_alias = 'Linux Mozilla'
39
- page = agent.get 'https://shop.aldi-fotoservice-druck.de/shop/viewLoginForm.do'
40
-
41
- if page.body.include?('Login/Neuanmeldung')
42
- p 'bin auf Login-Seite'
43
- end
44
- form = page.forms.first #TODO: besser nach Name
45
- form.username = @config[:aldi][:user]
46
- form.password = @config[:aldi][:password]
47
- p form.username
48
- p form.password
49
- page = agent.submit form
50
- if page.body.include?('Ihre Benutzerdaten')
51
- p 'bin auf Benutzerdaten-Seite'
52
- else
53
- html_out(page.body,'out.html')
54
- end
55
- page = agent.click page.links.text('zum Direkt-Upload')
56
- # if page.body.include?('Ihr Warenkorb ist leer.')
57
- # p 'bin beim leeren Warenkorb'
58
- # end
59
- # # page = agent.get('https://shop.aldi-fotoservice-druck.de/shop/viewUploadForm.do')
60
- # page = agent.click page.links.text(/viewUploadForm/)
61
- if page.body.include?('Bilddateien und Zip-Archive einzeln hochladen')
62
- p 'bin auf Upload-Seite'
63
- end
64
- form = page.forms.first #TODO: besser nach Name
65
- pp form
66
- #form.file_1 = photo.filename
67
- pp form.file_uploads.name('file_1').first
68
- form.file_uploads.name('file_1').first.file_name = photo.filename
69
- pp form.file_uploads.name('file_1').first
70
- #pp form
71
- ##TODO: derzeit sind in diesem Formular bis zu 5 Photos gleichzeitig moeglich
72
- page = agent.submit form
73
- if page.body.include?('Ihr Auftrag')
74
- p "bin auf Auftrag-Anzeigeseite"
75
- html_out(page.body,'out.html')
76
- end
77
- end
78
-
79
- def html_out(body,html_file)
80
- File.open(html_file,"w") {|f| f.print body}
81
- end
82
- end