This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
my $WATCHDIR = '/var/www/owncloud/data/mk/files/InstantUpload/'; | |
my $FLICKR_TOKEN = 'xxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxx'; | |
my $jpg; | |
open CMD, "/usr/bin/inotifywait -m -e moved_to --format %f $WATCHDIR |"; | |
while($jpg=<CMD>){ | |
chomp $jpg; | |
my $small = $jpg; | |
#-- resize(Google+用) | |
$small =~s/\.jpg$/-2048\.jpg/i; | |
system("convert -resize 2048x -quality 100 $WATCHDIR/$jpg /tmp/$small"); | |
#-- Google+ post | |
system("google picasa post '自動バックアップ' /tmp/$small"); | |
system("rm /tmp/$small"); | |
#-- Flickr post | |
system("/usr/bin/flickr_upload --auth_token $FLICKR_TOKEN --public 0 --friend 0 --family 0 --tag='\"InstantUpload\"' $WATCHDIR/$jpg"); | |
} | |
__END__ | |
"inotyfy-post.pl" https://gist.github.com/matoken/1e9a5455bf8ab6511c7d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
これは何?
OwnCloud で自動Upload されるディレクトリをinotify で監視してPicasa の自動Upload 領域と,Flickr
にUpload するScript
Android の Ownclowd アプリで自動アップロードされた写真を監視してpost するのに使っています.
pkg install
UploadDIR
Ownclowd のアップロードされるディレクトリを確認して Script の $WATCHDIR に書いておく.
get token
このScript 実行前に利用するサービスのトークンを入手しておく
Flickr
このtoken をscript の $FLICKR_TOKEN に書いておく
google
既存のブラウザ セッションに新しいウィンドウが作成されました。
※w3m でも行けるかと思ったが,2段階認証後JavaScriptが必要と言われて失敗した.リモートサーバ環境 ではssh のX 転送で凌いた
実行