Class: Panthermedia
- Inherits:
-
GenericSite
- Object
- GenericSite
- Panthermedia
- Defined in:
- lib/multistockphoto/site_panthermedia.rb
Overview
Das hier schreibt Panthermedia: Wichtig:
-
Umlaute und Sonderzeichen im Dateinamen vermeiden
-
Bitte nur JPG-Dateien (max. Größe: 12 MB) hochladen
-
Bilder im FTP-Ordner nach spätestens 7 Tagen bearbeiten/entfernen
-
Ihr verfügbarer FTP-Speicher: 150 MB (bitte nicht überschreiten)
-
Bitte keine Verzeichnisse im FTP-Ordner anlegen
TODO: Groesse der Datei testen - ist aber momentan kein kritischer Wert fuer mich
Constant Summary collapse
- FTP_HOST =
'panthermedia.net'
- SITENAME =
'panthermedia'
- @@errors =
0
Constants inherited from GenericSite
GenericSite::MAX_ERRORS, GenericSite::SENDLIST
Instance Attribute Summary collapse
-
#ftp_password ⇒ Object
Returns the value of attribute ftp_password.
-
#ftp_user ⇒ Object
Returns the value of attribute ftp_user.
-
#max_errors ⇒ Object
Returns the value of attribute max_errors.
-
#password ⇒ Object
readonly
user/password wird aber eigentlich nicht benoetigt.
-
#total_per_day ⇒ Object
readonly
user/password wird aber eigentlich nicht benoetigt.
-
#user ⇒ Object
readonly
user/password wird aber eigentlich nicht benoetigt.
Attributes inherited from GenericSite
Class Method Summary collapse
-
.accept?(ext) ⇒ Boolean
Site akzeptiert diese Extension.
-
.can_handle_orientation? ⇒ Boolean
can site handle orientation?.
Instance Method Summary collapse
- #accept?(ext) ⇒ Boolean
-
#already_sent?(photo) ⇒ Boolean
wurde dieses Photo schon gesendet?.
-
#initialize(name) ⇒ Panthermedia
constructor
A new instance of Panthermedia.
-
#sent_today ⇒ Object
Anzahl heute schon gesendeter Photos.
- #transfer(photo, dont_send = nil, dont_log = nil) ⇒ Object
Methods inherited from GenericSite
#already_sent_site?, #heute_schon_gesendet, #photos_fuer_heute_uebrig?, #photosize_valid?
Constructor Details
#initialize(name) ⇒ Panthermedia
Returns a new instance of Panthermedia.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 24 def initialize(name) super @config = load_config begin @user = @config[:panthermedia][:user] @password = @config[:panthermedia][:password] @ftp_user = @config[:panthermedia][:ftp_user] @ftp_password = @config[:panthermedia][:ftp_password] @total_per_day = @config[:panthermedia][:total_per_day] rescue puts 'cannot read configuration entries of '+SITENAME end end |
Instance Attribute Details
#ftp_password ⇒ Object
Returns the value of attribute ftp_password.
19 20 21 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 19 def ftp_password @ftp_password end |
#ftp_user ⇒ Object
Returns the value of attribute ftp_user.
19 20 21 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 19 def ftp_user @ftp_user end |
#max_errors ⇒ Object
Returns the value of attribute max_errors.
19 20 21 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 19 def max_errors @max_errors end |
#password ⇒ Object (readonly)
user/password wird aber eigentlich nicht benoetigt
18 19 20 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 18 def password @password end |
#total_per_day ⇒ Object (readonly)
user/password wird aber eigentlich nicht benoetigt
18 19 20 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 18 def total_per_day @total_per_day end |
#user ⇒ Object (readonly)
user/password wird aber eigentlich nicht benoetigt
18 19 20 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 18 def user @user end |
Class Method Details
.accept?(ext) ⇒ Boolean
Site akzeptiert diese Extension
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 109 def self.accept?(ext) ext = ext.downcase if ext[0,1] == '.' ext = ext[1..-1] end case ext when 'jpg','jpeg' return true else return false end end |
.can_handle_orientation? ⇒ Boolean
can site handle orientation?
104 105 106 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 104 def self.can_handle_orientation? false end |
Instance Method Details
#accept?(ext) ⇒ Boolean
122 123 124 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 122 def accept?(ext) Panthermedia.accept?(ext) end |
#already_sent?(photo) ⇒ Boolean
wurde dieses Photo schon gesendet?
99 100 101 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 99 def already_sent?(photo) already_sent_site?(photo,SITENAME) end |
#sent_today ⇒ Object
Anzahl heute schon gesendeter Photos
93 94 95 96 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 93 def sent_today site = SITENAME return sent_today_site(site) end |
#transfer(photo, dont_send = nil, dont_log = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/multistockphoto/site_panthermedia.rb', line 38 def transfer(photo, dont_send=nil, dont_log=nil) # falls nicht in config Datei eingetragen dann nicht senden if @user == nil or @password == nil return end unless photo.class == Photo raise 'not a Photo object' end unless File.exist?(photo.filename) raise "file #{photo.filename} does not exist" end if @ftp_user == nil or @ftp_password == nil raise "ftp_user/ftp_password not set" end print "#{SITENAME}:#{photo.filename} ... " $stdout.flush if already_sent_site?(photo,SITENAME) puts "already sent" return :duplicate end if photo.portrait? and ! Panthermedia.can_handle_orientation? photo.drehen end if site_can_handle_keywords? photo.set_keywords end if ! dont_send begin ftp = Net::FTP.new(FTP_HOST) ftp.login(@ftp_user,@ftp_password) files=ftp.list('*') if photo.portrait? #p photo.rotated_filename res = ftp.putbinaryfile(photo.rotated_filename) else res = ftp.putbinaryfile(photo.filename) end files =ftp.list('*') #p files ftp.close rescue Errno::EPIPE,Net::FTPTempError raise UploadException end end @@errors = 0 puts 'OK' if ! dont_log File.open(SENDLIST,'a') {|f| f.puts "#{SITENAME}\t#{photo.filename}\t#{Time.now}" } end true end |