Created
September 15, 2008 13:16
-
-
Save kzys/10849 to your computer and use it in GitHub Desktop.
Filter::FlickrContactPhotos
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
Index: t/plugins/Filter-FlickrContactPhotos/base.t | |
=================================================================== | |
--- t/plugins/Filter-FlickrContactPhotos/base.t (revision 0) | |
+++ t/plugins/Filter-FlickrContactPhotos/base.t (revision 0) | |
@@ -0,0 +1,28 @@ | |
+use strict; | |
+use t::TestPlagger; | |
+ | |
+test_requires_network; | |
+test_plugin_deps; | |
+plan tests => 6; | |
+ | |
+run_eval_expected; | |
+ | |
+__END__ | |
+ | |
+=== Test Flickr Contact Photos | |
+--- input config | |
+plugins: | |
+ - module: Subscription::Config | |
+ config: | |
+ feed: | |
+ - file://$t::TestPlagger::BaseDirURI/t/samples/flickr-friends.xml | |
+ - module: Filter::FlickrContactPhotos | |
+ config: | |
+ api_key: 9d58b60bd3cb21e7d5cd940f3f7c7305 | |
+--- expected | |
+is $context->update->feeds->[0]->entries->[0]->icon->{url}, 'http://farm1.static.flickr.com/25/buddyicons/[email protected]'; | |
+is $context->update->feeds->[0]->entries->[0]->icon->{title}, 'Natsu Tohi'; | |
+is $context->update->feeds->[0]->entries->[0]->icon->{link}, 'http://www.flickr.com/people/tohinatsu/'; | |
+is $context->update->feeds->[0]->entries->[1]->icon->{url}, 'http://farm1.static.flickr.com/5/buddyicons/[email protected]'; | |
+is $context->update->feeds->[0]->entries->[1]->icon->{title}, 'Kohichi Aoki'; | |
+is $context->update->feeds->[0]->entries->[1]->icon->{link}, 'http://www.flickr.com/people/drikin/'; | |
Index: t/samples/flickr-friends.xml | |
=================================================================== | |
--- t/samples/flickr-friends.xml (revision 0) | |
+++ t/samples/flickr-friends.xml (revision 0) | |
@@ -0,0 +1,403 @@ | |
+<?xml version="1.0" encoding="utf-8" standalone="yes"?> | |
+<feed xmlns="http://www.w3.org/2005/Atom" | |
+ xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:flickr="urn:flickr:" xmlns:media="http://search.yahoo.com/mrss/"> | |
+ | |
+ <title>From miyagawa's contacts</title> | |
+ <link rel="self" href="http://api.flickr.com/services/feeds/photos_friends.gne?user_id=49503048699@N01" /> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/bulknews/friends/"/> | |
+ <id>tag:flickr.com,2005:/photos/friends-0-0</id> | |
+ <icon>http://farm1.static.flickr.com/1/buddyicons/[email protected]?1102118620#49503048699@N01</icon> | |
+ <subtitle></subtitle> | |
+ <updated>2008-09-15T08:56:47Z</updated> | |
+ <generator uri="http://www.flickr.com/">Flickr</generator> | |
+ | |
+ <entry> | |
+ <title>P1060338</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/tohinatsu/2858471483/"/> | |
+ <id>tag:flickr.com,2005:/photo/2858471483</id> | |
+ <published>2008-09-15T08:56:47Z</published> | |
+ <updated>2008-09-15T08:56:47Z</updated> | |
+ <dc:date.Taken>2008-07-24T21:36:58-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/tohinatsu/">tohinatsugon</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/tohinatsu/2858471483/" title="P1060338"><img src="http://farm4.static.flickr.com/3199/2858471483_b85da97c16_m.jpg" width="240" height="180" alt="P1060338" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>tohinatsugon</name> | |
+ <uri>http://www.flickr.com/people/tohinatsu/</uri> | |
+ </author> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3199/2858471483_20e3b2d8cd_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>鮨英</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/drikin/2858223527/"/> | |
+ <id>tag:flickr.com,2005:/photo/2858223527</id> | |
+ <published>2008-09-15T06:20:53Z</published> | |
+ <updated>2008-09-15T06:20:53Z</updated> | |
+ <dc:date.Taken>2008-09-14T13:42:34-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/drikin/">Kohichi</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/drikin/2858223527/" title="鮨英"><img src="http://farm4.static.flickr.com/3205/2858223527_23df920117_m.jpg" width="240" height="180" alt="鮨英" /></a></p> | |
+ | |
+<p>先日王様のブランチで紹介されていた旗の台にある寿司屋さん<br /> | |
+歩いて行ける圏内なので早速行って見ました。<br /> | |
+<br /> | |
+売りは500円ランチ鮨ですが写真は満腹にぎり1000円。ほん<br /> | |
+と満腹になります。興味あるかたは"旗の台 鮨英"で<br /> | |
+くぐって見てください。気軽に鮨食べたい時にはオススメです。<br /> | |
+<br /> | |
+Sent from iPhone</p></content> | |
+ <author> | |
+ <name>Kohichi</name> | |
+ <uri>http://www.flickr.com/people/drikin/</uri> | |
+ </author> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3205/2858223527_23df920117_m.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Mizuka with our giant okra plant</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/joi/2858804056/"/> | |
+ <id>tag:flickr.com,2005:/photo/2858804056</id> | |
+ <published>2008-09-15T04:24:18Z</published> | |
+ <updated>2008-09-15T04:24:18Z</updated> | |
+ <dc:date.Taken>2008-09-14T23:53:08-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/joi/">Joi</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/joi/2858804056/" title="Mizuka with our giant okra plant"><img src="http://farm4.static.flickr.com/3258/2858804056_51c1f96cf6_m.jpg" width="240" height="161" alt="Mizuka with our giant okra plant" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>Joi</name> | |
+ <uri>http://www.flickr.com/people/joi/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3258/2858804056_c21e41d88b_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Taft Point</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/naotakem/2857771011/"/> | |
+ <id>tag:flickr.com,2005:/photo/2857771011</id> | |
+ <published>2008-09-15T03:10:13Z</published> | |
+ <updated>2008-09-15T03:10:13Z</updated> | |
+ <dc:date.Taken>2008-09-07T11:12:24-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/naotakem/">naotakem</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/naotakem/2857771011/" title="Taft Point"><img src="http://farm4.static.flickr.com/3037/2857771011_1d67dc1d28_m.jpg" width="180" height="240" alt="Taft Point" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>naotakem</name> | |
+ <uri>http://www.flickr.com/people/naotakem/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3037/2857771011_63e2bf4bbc_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>James!</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/ginevra/2857686733/"/> | |
+ <id>tag:flickr.com,2005:/photo/2857686733</id> | |
+ <published>2008-09-15T02:40:22Z</published> | |
+ <updated>2008-09-15T02:40:22Z</updated> | |
+ <dc:date.Taken>2008-09-14T22:40:22-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/ginevra/">miz_ginevra</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/ginevra/2857686733/" title="James!"><img src="http://farm4.static.flickr.com/3039/2857686733_9360ddb28e_m.jpg" width="180" height="240" alt="James!" /></a></p> | |
+ | |
+<p>first stop on their North American tour was the Paradise in Boston.</p></content> | |
+ <author> | |
+ <name>miz_ginevra</name> | |
+ <uri>http://www.flickr.com/people/ginevra/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3039/2857686733_82625b208d_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>IMG_7727</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/kennejima/2858189226/"/> | |
+ <id>tag:flickr.com,2005:/photo/2858189226</id> | |
+ <published>2008-09-15T00:45:33Z</published> | |
+ <updated>2008-09-15T00:45:33Z</updated> | |
+ <dc:date.Taken>2008-09-13T20:04:17-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/kennejima/">kennejima</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/kennejima/2858189226/" title="IMG_7727"><img src="http://farm4.static.flickr.com/3292/2858189226_5084b0c992_m.jpg" width="240" height="160" alt="IMG_7727" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>kennejima</name> | |
+ <uri>http://www.flickr.com/people/kennejima/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3292/2858189226_defe4fcf8f_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Milo</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/petdance/2857809866/"/> | |
+ <id>tag:flickr.com,2005:/photo/2857809866</id> | |
+ <published>2008-09-14T22:30:22Z</published> | |
+ <updated>2008-09-14T22:30:22Z</updated> | |
+ <dc:date.Taken>2008-09-09T04:54:33-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/petdance/">Andy Lester</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/petdance/2857809866/" title="Milo"><img src="http://farm4.static.flickr.com/3208/2857809866_be78b5c4b7_m.jpg" width="240" height="158" alt="Milo" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>Andy Lester</name> | |
+ <uri>http://www.flickr.com/people/petdance/</uri> | |
+ </author> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3208/2857809866_be78b5c4b7_m.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Marble</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/dot_tiff/2856548409/"/> | |
+ <id>tag:flickr.com,2005:/photo/2856548409</id> | |
+ <published>2008-09-14T20:12:29Z</published> | |
+ <updated>2008-09-14T20:12:29Z</updated> | |
+ <dc:date.Taken>2009-01-29T20:59:58-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/dot_tiff/">.tiff</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/dot_tiff/2856548409/" title="Marble"><img src="http://farm4.static.flickr.com/3035/2856548409_b4dee6ea05_m.jpg" width="240" height="180" alt="Marble" /></a></p> | |
+ | |
+<p>Came with my marble soccer set, from San Salvador</p></content> | |
+ <author> | |
+ <name>.tiff</name> | |
+ <uri>http://www.flickr.com/people/dot_tiff/</uri> | |
+ </author> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3035/2856548409_b4dee6ea05_m.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Thames In Flood</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/cdent/2857339490/"/> | |
+ <id>tag:flickr.com,2005:/photo/2857339490</id> | |
+ <published>2008-09-14T20:00:31Z</published> | |
+ <updated>2008-09-14T20:00:31Z</updated> | |
+ <dc:date.Taken>2008-09-14T15:15:35-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/cdent/">cdent</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/cdent/2857339490/" title="Thames In Flood"><img src="http://farm4.static.flickr.com/3074/2857339490_159d4a1cec_m.jpg" width="240" height="161" alt="Thames In Flood" /></a></p> | |
+ | |
+<p>Near the locks in Osney</p></content> | |
+ <author> | |
+ <name>cdent</name> | |
+ <uri>http://www.flickr.com/people/cdent/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3074/2857339490_1fe9c21b7f_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>photo.jpg</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/steveobd/2856959078/"/> | |
+ <id>tag:flickr.com,2005:/photo/2856959078</id> | |
+ <published>2008-09-14T18:05:37Z</published> | |
+ <updated>2008-09-14T18:05:37Z</updated> | |
+ <dc:date.Taken>2008-09-14T11:05:37-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/steveobd/">steveobd</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/steveobd/2856959078/" title="photo.jpg"><img src="http://farm4.static.flickr.com/3090/2856959078_6cf3f99484_m.jpg" width="180" height="240" alt="photo.jpg" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>steveobd</name> | |
+ <uri>http://www.flickr.com/people/steveobd/</uri> | |
+ </author> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3090/2856959078_6cf3f99484_m.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>aspects2</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/91221720@N00/2856660556/"/> | |
+ <id>tag:flickr.com,2005:/photo/2856660556</id> | |
+ <published>2008-09-14T16:28:22Z</published> | |
+ <updated>2008-09-14T16:28:22Z</updated> | |
+ <dc:date.Taken>2008-09-15T01:28:22-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/91221720@N00/">Yamaguchies</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/91221720@N00/2856660556/" title="aspects2"><img src="http://farm4.static.flickr.com/3206/2856660556_86d97795a4_m.jpg" width="240" height="180" alt="aspects2" /></a></p> | |
+ | |
+<p>it doesn't have any meaning. I like this angle, color, and font.</p></content> | |
+ <author> | |
+ <name>Yamaguchies</name> | |
+ <uri>http://www.flickr.com/people/91221720@N00/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3206/2856660556_23cb94dfde_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Chain Gang</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/davorg/2856439724/"/> | |
+ <id>tag:flickr.com,2005:/photo/2856439724</id> | |
+ <published>2008-09-14T15:10:37Z</published> | |
+ <updated>2008-09-14T15:10:37Z</updated> | |
+ <dc:date.Taken>1982-07-01T00:00:00-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/davorg/">Dave Cross</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/davorg/2856439724/" title="Chain Gang"><img src="http://farm4.static.flickr.com/3221/2856439724_0a6f1e72e1_m.jpg" width="240" height="188" alt="Chain Gang" /></a></p> | |
+ | |
+<p>Another blast from the past. I'm second from right.<br /> | |
+<br /> | |
+It's summer 1982 and I'm nineteen. I was walking down Goswell Road one morning when someone stops me and asks if he can take a polaroid of me. Turns out he's from a photographic studio nearby and they're doing a shoot of a heavy metal band that evening. Someone has dropped out of the shoot at the last minute and he's out looking for a replacement. A couple of hours later, having shown the polaroid to his boss, he calls me to ask me to come along to their studio that evening.<br /> | |
+<br /> | |
+I spent a couple of hours having my photo taken with these other people. I got paid £35 for the evening and we also all got more than a little drunk on the crates of beer the studio people brought in. I should point out that there isn't really a band called Chain Gang. None of us had met before that evening.<br /> | |
+<br /> | |
+The advert was for BASF tape. The slogan was "Metal by Chain Gang - Metal tape by BASF". It was part of a series of similar adverts for various types of BASF tapes. The only other one I can remember is a picture of a mod on a really shiny scooter. The slogan on that one was "Chrome by Colin - Chrome tape by BASF".<br /> | |
+<br /> | |
+The adverts appeared in the music press (and on huge posters in tube stations) in about September of that year.</p></content> | |
+ <author> | |
+ <name>Dave Cross</name> | |
+ <uri>http://www.flickr.com/people/davorg/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3221/2856439724_561933bc47_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>stuffed Pikachu</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/44855846@N00/2855290451/"/> | |
+ <id>tag:flickr.com,2005:/photo/2855290451</id> | |
+ <published>2008-09-14T12:53:53Z</published> | |
+ <updated>2008-09-14T12:53:53Z</updated> | |
+ <dc:date.Taken>2008-09-14T21:53:53-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/44855846@N00/">risathebuzztum</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/44855846@N00/2855290451/" title="stuffed Pikachu"><img src="http://farm4.static.flickr.com/3247/2855290451_1d54a146c1_m.jpg" width="180" height="240" alt="stuffed Pikachu" /></a></p> | |
+ | |
+<p><br /> | |
+ - Camera phone upload powered by <a href="http://www.shozu.com/?utm_source=upload&utm_medium=graphic&utm_campaign=upload_graphic/" target="_newwindow">ShoZu</a></p></content> | |
+ <author> | |
+ <name>risathebuzztum</name> | |
+ <uri>http://www.flickr.com/people/44855846@N00/</uri> | |
+ </author> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3247/2855290451_1d54a146c1_m.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>RIMG0027</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/mu_0623/2855237683/"/> | |
+ <id>tag:flickr.com,2005:/photo/2855237683</id> | |
+ <published>2008-09-14T12:23:08Z</published> | |
+ <updated>2008-09-14T12:23:08Z</updated> | |
+ <dc:date.Taken>2008-09-14T11:25:05-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/mu_0623/">mu_0623</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/mu_0623/2855237683/" title="RIMG0027"><img src="http://farm4.static.flickr.com/3224/2855237683_2bbd34659e_m.jpg" width="240" height="180" alt="RIMG0027" /></a></p> | |
+ | |
+<p>Exif_JPEG_PICTURE</p></content> | |
+ <author> | |
+ <name>mu_0623</name> | |
+ <uri>http://www.flickr.com/people/mu_0623/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3224/2855237683_2eefac2533_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Purple civilisation</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/crucially/2856052690/"/> | |
+ <id>tag:flickr.com,2005:/photo/2856052690</id> | |
+ <published>2008-09-14T12:12:03Z</published> | |
+ <updated>2008-09-14T12:12:03Z</updated> | |
+ <dc:date.Taken>2008-09-14T05:12:03-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/crucially/">crucially</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/crucially/2856052690/" title="Purple civilisation"><img src="http://farm4.static.flickr.com/3223/2856052690_6ae2dae072_m.jpg" width="180" height="240" alt="Purple civilisation" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>crucially</name> | |
+ <uri>http://www.flickr.com/people/crucially/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3223/2856052690_aabdbe2623_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Fujiya Camera, Nakano, Tokyo, Japan</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/minami/2855906014/"/> | |
+ <id>tag:flickr.com,2005:/photo/2855906014</id> | |
+ <published>2008-09-14T10:39:49Z</published> | |
+ <updated>2008-09-14T10:39:49Z</updated> | |
+ <dc:date.Taken>2008-09-14T18:28:48-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/minami/">digitalbear</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/minami/2855906014/" title="Fujiya Camera, Nakano, Tokyo, Japan"><img src="http://farm4.static.flickr.com/3245/2855906014_abb48bf6e3_m.jpg" width="240" height="180" alt="Fujiya Camera, Nakano, Tokyo, Japan" /></a></p> | |
+ | |
+<p>Photo by Panasonic Lumix LX3</p></content> | |
+ <author> | |
+ <name>digitalbear</name> | |
+ <uri>http://www.flickr.com/people/minami/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3245/2855906014_e6179b4983_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>iPhone app display, apple store sf</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/emilychang/2854977417/"/> | |
+ <id>tag:flickr.com,2005:/photo/2854977417</id> | |
+ <published>2008-09-14T09:36:15Z</published> | |
+ <updated>2008-09-14T09:36:15Z</updated> | |
+ <dc:date.Taken>2008-09-14T02:36:15-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/emilychang/">emilychang</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/emilychang/2854977417/" title="iPhone app display, apple store sf"><img src="http://farm4.static.flickr.com/3084/2854977417_79fb909c28_m.jpg" width="240" height="180" alt="iPhone app display, apple store sf" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>emilychang</name> | |
+ <uri>http://www.flickr.com/people/emilychang/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3084/2854977417_c59f7dae38_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Samaritain[e]</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/rgarciasuarez74/2854867119/"/> | |
+ <id>tag:flickr.com,2005:/photo/2854867119</id> | |
+ <published>2008-09-14T08:20:15Z</published> | |
+ <updated>2008-09-14T08:20:15Z</updated> | |
+ <dc:date.Taken>2008-09-12T17:56:57-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/rgarciasuarez74/">@rgs</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/rgarciasuarez74/2854867119/" title="Samaritain[e]"><img src="http://farm4.static.flickr.com/3051/2854867119_10c0aa628e_m.jpg" width="240" height="180" alt="Samaritain[e]" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>@rgs</name> | |
+ <uri>http://www.flickr.com/people/rgarciasuarez74/</uri> | |
+ </author> | |
+ <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en" /> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3051/2854867119_865e9e1a36_o.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Big Moon</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/kazuhito/2854857525/"/> | |
+ <id>tag:flickr.com,2005:/photo/2854857525</id> | |
+ <published>2008-09-14T08:13:18Z</published> | |
+ <updated>2008-09-14T08:13:18Z</updated> | |
+ <dc:date.Taken>2008-09-13T14:12:37-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/kazuhito/">kazuhito</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/kazuhito/2854857525/" title="Big Moon"><img src="http://farm4.static.flickr.com/3247/2854857525_9d566e9598_m.jpg" width="240" height="180" alt="Big Moon" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>kazuhito</name> | |
+ <uri>http://www.flickr.com/people/kazuhito/</uri> | |
+ </author> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3247/2854857525_9d566e9598_m.jpg" /> | |
+ | |
+ </entry> | |
+ <entry> | |
+ <title>Pepsi</title> | |
+ <link rel="alternate" type="text/html" href="http://www.flickr.com/photos/lopnor/2854753681/"/> | |
+ <id>tag:flickr.com,2005:/photo/2854753681</id> | |
+ <published>2008-09-14T06:59:59Z</published> | |
+ <updated>2008-09-14T06:59:59Z</updated> | |
+ <dc:date.Taken>2008-09-14T15:59:24-08:00</dc:date.Taken> | |
+ <content type="html"><p><a href="http://www.flickr.com/people/lopnor/">lopnor</a> posted a photo:</p> | |
+<p><a href="http://www.flickr.com/photos/lopnor/2854753681/" title="Pepsi"><img src="http://farm4.static.flickr.com/3021/2854753681_a6c31319f7_m.jpg" width="133" height="240" alt="Pepsi" /></a></p> | |
+ | |
+</content> | |
+ <author> | |
+ <name>lopnor</name> | |
+ <uri>http://www.flickr.com/people/lopnor/</uri> | |
+ </author> | |
+ <link rel="enclosure" type="image/jpeg" href="http://farm4.static.flickr.com/3021/2854753681_a6c31319f7_m.jpg" /> | |
+ | |
+ </entry> | |
+ | |
+</feed> | |
\ No newline at end of file | |
Index: lib/Plagger/Plugin/Filter/FlickrContactPhotos.pm | |
=================================================================== | |
--- lib/Plagger/Plugin/Filter/FlickrContactPhotos.pm (revision 0) | |
+++ lib/Plagger/Plugin/Filter/FlickrContactPhotos.pm (revision 0) | |
@@ -0,0 +1,107 @@ | |
+package Plagger::Plugin::Filter::FlickrContactPhotos; | |
+use strict; | |
+ | |
+use base qw( Plagger::Plugin ); | |
+use Flickr::API; | |
+use XML::LibXML; | |
+ | |
+sub register { | |
+ my($self, $context) = @_; | |
+ $context->register_hook( | |
+ $self, | |
+ 'plugin.init' => \&init_flickr, | |
+ 'update.entry.fixup' => \&update, | |
+ ); | |
+} | |
+ | |
+sub init_flickr { | |
+ my ($self, $context, $args) = @_; | |
+ | |
+ $self->{flickr} = Flickr::API->new({ | |
+ key => $self->conf->{api_key} | |
+ }); | |
+} | |
+ | |
+sub update { | |
+ my($self, $context, $args) = @_; | |
+ my $entry = $args->{entry}; | |
+ | |
+ if ($entry->link !~ m{^http://www\.flickr\.com/photos/(.+?)/(\d+)/}) { | |
+ return; | |
+ } | |
+ my $user_id = $1; | |
+ my $photo_id = $2; | |
+ | |
+ my $icon = $self->cache->get_callback( | |
+ "flickr-buddyicon-$user_id", | |
+ sub { | |
+ $self->_buddy_icon_of($photo_id); | |
+ }, | |
+ '3 days' | |
+ ); | |
+ $entry->icon($icon); | |
+} | |
+ | |
+sub _buddy_icon_of { | |
+ my($self, $photo_id) = @_; | |
+ | |
+ my $nsid = $self->_call_flickr( | |
+ 'flickr.photos.getInfo', | |
+ { photo_id => $photo_id } | |
+ )->findvalue('/rsp/photo/owner/@nsid'); | |
+ | |
+ my $person = $self->_call_flickr( | |
+ 'flickr.people.getInfo', | |
+ { user_id => $nsid } | |
+ ); | |
+ | |
+ my $title = $person->findvalue('/rsp/person/realname'); | |
+ $title ||= $person->findvalue('/rsp/person/username'); | |
+ | |
+ return { | |
+ url => sprintf( | |
+ 'http://farm%s.static.flickr.com/%s/buddyicons/%s.jpg', | |
+ $person->findvalue('/rsp/person/@iconfarm'), | |
+ $person->findvalue('/rsp/person/@iconserver'), | |
+ $nsid, | |
+ ), | |
+ link => $person->findvalue('/rsp/person/profileurl'), | |
+ title => $title, | |
+ }; | |
+} | |
+ | |
+sub _call_flickr { | |
+ my($self, $method, $args) = @_; | |
+ | |
+ my $resp = $self->{flickr}->execute_method($method, $args); | |
+ | |
+ my $doc = XML::LibXML->new->parse_string($resp->decoded_content); | |
+ return $doc; | |
+} | |
+ | |
+1; | |
+__END__ | |
+ | |
+=head1 NAME | |
+ | |
+Plagger::Plugin::Filter::FlickrContactPhotos; | |
+ | |
+=head1 SYNOPSIS | |
+ | |
+ - module: Filter::FlickrContactPhotos | |
+ config: | |
+ api_key: YOUR-FLICKR-APIKEY | |
+ | |
+=head1 DESCRIPTION | |
+ | |
+This plugin adds user's buddy icon to Flickr's photos. | |
+ | |
+=head1 AUTHOR | |
+ | |
+Kazuyoshi Kato | |
+ | |
+=head1 SEE ALSO | |
+ | |
+L<Plagger>, L<http://www.flickr.com/>, L<Flickr::API> | |
+ | |
+=cut | |
Index: deps/Filter-FlickrContactPhotos.yaml | |
=================================================================== | |
--- deps/Filter-FlickrContactPhotos.yaml (revision 0) | |
+++ deps/Filter-FlickrContactPhotos.yaml (revision 0) | |
@@ -0,0 +1,4 @@ | |
+name: Filter::FlickrContactPhotos | |
+author: Kazuyoshi Kato | |
+depends: | |
+ Flickr::API: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment