<?xml version="1.0" encoding="utf-8"?>
<service name="flickr"
         version="$Id: flickr.xml 20770 2008-10-24 23:48:34Z justin $"
         xmlns="http://www.flock.com/web-detective#">

  <strings>
    <string name="domains" value="flickr.com,yahoo.com"/>
    <string name="userprofile">
      <![CDATA[http://www.flickr.com/people/%accountid%/]]>
    </string>
    <string name="inviteFriendsURL">
      <![CDATA[http://flickr.com/invite/]]>
    </string>
    <string name="photopage">
      <![CDATA[http://www.flickr.com/photos/%accountid%/%photoid%/]]>
    </string>
    <string name="commentsreceivedRSS">
      <![CDATA[http://api.flickr.com/services/feeds/activity.gne?id=%accountid%&format=rss_200]]>
    </string>
    <string name="staticimage">
      <![CDATA[http://static.flickr.com/%server%/%photoid%_%secret%%size%.jpg]]>
    </string>
    <string name="buddyicon">
      <![CDATA[http://www.flickr.com/images/buddyicon.jpg]]>
    </string>
    <string name="staticbuddyicon">
      <![CDATA[http://static.flickr.com/%iconserver%/buddyicons/%owner%.jpg]]>
    </string>
    <string name="apikey">
      <![CDATA[92c2a562f0e9c2ed8dfe78f42a7734c7]]>
    </string>
    <string name="endpoint">
      <![CDATA[http://www.flickr.com/services/rest/]]>
    </string>
    <string name="uploadendpoint">
      <![CDATA[http://www.flickr.com/services/upload/]]>
    </string>
    <string name="authendpoint">
      <![CDATA[http://www.flickr.com/services/auth/]]>
    </string>
    <string name="friendprofile">
      <![CDATA[http://www.flickr.com/people/%accountid%/]]>
    </string>
    <string name="scrapeAccountInfo">
      <![CDATA[http://www.flickr.com/]]>
    </string>
    <string name="imageUrlPattern">
      <![CDATA[https?:\/\/farm\d+\.static\.flickr\.com\/.*]]>
    </string>
    <string name="spaceballUrlPattern">
      <![CDATA[https?:\/\/l\.yimg\.com\/.*\/images\/spaceball\.gif]]>
    </string>

    <string name="friendMessage">
      <![CDATA[newtab:http://www.flickr.com/messages_write.gne?to=%friendid%]]>
    </string>
    <string name="friendShareFlock" value="method:flockIFlickrAccount:shareFlock" />
    <string name="friendViewProfile">
      <![CDATA[newtab:http://www.flickr.com/people/%friendid%/]]>
    </string>
    <string name="meMessages_URL">
      <![CDATA[http://www.flickr.com/messages.gne?ok=1]]>
    </string>
    <string name="meCommentActivity_URL">
      <![CDATA[http://www.flickr.com/recent_activity.gne?days=%timespan%h]]>
    </string>
    <string name="shareAction" value="method:flockIFlickrAccount:flickrMail" />
    <string name="flickrmail_URL">
      <![CDATA[http://www.flickr.com/messages_write.gne?to=%friendid%]]>
    </string>
    <string name="flickrmail_subjectXPath">
      <![CDATA[//div[@id="Main"]//form[@action="messages_write.gne"]//input[@name="subject"]]]>
    </string>
    <string name="flickrmail_bodyXPath">
      <![CDATA[//div[@id="Main"]//form[@action="messages_write.gne"]//textarea[@name="message"]]]>
    </string>
    <string name="dndXPathFields">
      <![CDATA[flickrmail_bodyXPath,text/unicode;photoCommentXPath,text/html]]>
    </string>
    <string name="photoCommentXPath">
      <![CDATA[//textarea[@id="message"]]]>
    </string>

    <string name="homePageURL" locale="default">
      <![CDATA[http://flickr.com/]]>
    </string>

    <string name="loginURL" locale="default">
      <![CDATA[http://flickr.com/signin/]]>
    </string>
  </strings>

  <sessioncookies>
    <cookie host=".flickr.com" name="cookie_accid" path="/"/>
    <cookie host=".flickr.com" name="cookie_epass" path="/"/>
    <cookie host=".flickr.com" name="cookie_session" path="/"/>
    <cookie host=".flickr.com" name="use_master_until" path="/"/>
  </sessioncookies>

  <detect type="login"><!-- Yahoo! login with username text field -->
    <url>
      <host equals="login.yahoo.com"/>
      <path contains=".src=flickr"/>
    </url>
    <form>
      <xpath name="username" extract="value">
        <![CDATA[[@name="login_form"]//input[@id="username"][@type="text"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@id="passwd"]]]>
      </xpath>
    </form>
  </detect>

  <!-- Yahoo! login (after intial failed attempt) with username text field -->
  <detect type="login">
    <url>
      <host equals="login.yahoo.com" />
      <path contains="config/login?" />
    </url>
    <form>
      <xpath>
        <![CDATA[//input[@type="hidden"][@name=".src"][@value="flickr"]]]>
      </xpath>
      <xpath name="username" extract="value">
        <![CDATA[//input[@id="username"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@id="passwd"]]]>
      </xpath>
    </form>
  </detect>

  <detect type="login"><!-- Yahoo! login with hidden username field -->
    <url>
      <host equals="login.yahoo.com"/>
      <path contains=".src=flickr"/>
    </url>
    <form>
      <xpath name="username" extract="value">
        <![CDATA[[@name="login_form"]//input[@name=".slogin"][@type="hidden"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@id="passwd"]]]>
      </xpath>
    </form>
  </detect>

  <detect type="login"><!-- Old Skool Flickr login -->
    <url domain="flickr.com"><path contains="signin/"/></url>
    <form>
      <xpath name="username" extract="value">
        <![CDATA[[@name="flickrloginform"]//input[@id="first_field"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@name="password"]]]>
      </xpath>
    </form>
  </detect>

  <detect type="signup">
    <url><host equals="edit.yahoo.com"/><path contains="/config/eval_register"/></url>
    <form>
      <field tagname="input" name="login" extractas="username"/>
      <field tagname="input" name=".pw" type="password" extractas="password"/>
    </form>
  </detect>

  <detect type="loggedin">
    <url domain="flickr.com"/>
    <xpath><![CDATA[//div[@id="TopBar"]//td[@class="Status"]//a[@href="/account"]]]></xpath>
  </detect>

  <detect type="loggedin">
    <url domain="flickr.com"><path contains="/welcome/hello"/></url>
    <regexp><![CDATA[/<h1>OK. You're all set, /]]></regexp>
  </detect>

  <detect type="loggedout">
    <url domain="flickr.com"/>
    <xpath><![CDATA[//div[@id="TopBar"]//td[@class="Status"]//a[@href="/signin/"]]]></xpath>
  </detect>

  <detect type="loggedout">
    <cookie nomatch="true" host=".flickr.com" name="cookie_session"/>
    <cookie nomatch="true" host=".flickr.com" name="cookie_epass"/>
  </detect>

  <detect type="completeLogout">
    <url domain="yahoo.com">
      <host equals="login.yahoo.com" />
      <path contains="config/" />
      <querystring contains="logout=1" />
    </url>
  </detect>

  <detect type="accountinfo">
    <results>
      <regexp re1="accountid">
        <![CDATA[/global_nsid = '(.+)'/]]>
      </regexp>
      <regexp re1="username">
        <![CDATA[/global_name ='(.+)'/]]>
      </regexp>
      <regexp re1="avatarURL">
        <![CDATA[/global_icon_url ='(.+)'/]]>
      </regexp>
      <regexp re1="messages">
        <![CDATA[/\/messages\.gne\?ok=1\"\>\<b\>(.+)\<\/b>/]]>
      </regexp>
    </results>
  </detect>

  <!-- Find the URL of an image hidden by spaceball.gif -->
  <detect type="spaceball">
    <results>
      <xpath name="imageUrl" extract="attribute:src">
        <![CDATA[/html/body/div/table/tbody/tr/td/div[2]/div[@class="photoImgDiv"]/img]]>
      </xpath>
    </results>
  </detect>

  <detect type="ownsDocument">
    <url domain="flickr.com" />
  </detect>

  <detect type="ownsDocument">
    <url domain="login.yahoo.com">
      <querystring contains=".src=flickr" />
    </url>
  </detect>

  <detect type="ownsDocument">
    <url domain="yahoo.com">
      <host equals="login.yahoo.com" />
      <path contains="config/" />
      <querystring contains="logout=1" />
    </url>
  </detect>

  <!-- extract username in English pages -->
  <detect type="person">
    <url domain="flickr.com">
      <path contains="photos/" />
    </url>
    <regexp re1="userid">
      <![CDATA[/send.photostream=(.*)".id/]]>
    </regexp>
    <regexp re1="username">
      <![CDATA[/<a class="menu_item_line_above" title="(.*)'s? Photos" href="\/search\/" onclick=/]]>
    </regexp>
  </detect>

  <!-- extract username in English pages (logged out) -->
  <detect type="person">
    <url domain="flickr.com">
      <path contains="photos/" />
    </url>
    <regexp re1="userid">
      <![CDATA[/var photostream_owner_nsid = "(.*)";/]]>
    </regexp>
    <regexp re1="username">
      <![CDATA[/<a class="menu_item_line_above" title="(.*)'s? Photos" href="\/search\/" onclick=/]]>
    </regexp>
  </detect>

  <!-- extract username in non-English pages -->
  <detect type="person">
    <url domain="flickr.com">
      <path contains="photos/" />
    </url>
    <regexp re1="userid">
      <![CDATA[/send.photostream=(.*)".id/]]>
    </regexp>
    <regexp re1="username">
      <![CDATA[/<a class="menu_item_line_above" title="(.*) Photos"/]]>
    </regexp>
  </detect>

  <!-- extract username in non-English pages (logged out) -->
  <detect type="person">
    <url domain="flickr.com">
      <path contains="photos/" />
    </url>
    <regexp re1="userid">
      <![CDATA[/var photostream_owner_nsid = "(.*)";/]]>
    </regexp>
    <regexp re1="username">
      <![CDATA[/<a class="menu_item_line_above" title="(.*) Photos"/]]>
    </regexp>
  </detect>

  <detect type="person">
    <url domain="flickr.com">
      <path contains="photos/" />
    </url>
    <regexp re1="userid">
      <![CDATA[/send.photostream=(.*)".id/]]>
    </regexp>
    <regexp re1="username">
      <![CDATA[/var alias = '(.*)';/]]>
    </regexp>
  </detect>

  <detect type="person">
    <url domain="flickr.com"><path contains="photos/"/></url>
    <regexp re1="userid" re2="username">
      <![CDATA[/photos_public\.gne\?id=([^&"]+)&.+Subscribe to (.+)'s? photos/]]>
    </regexp>
  </detect>

  <detect type="person">
    <url domain="flickr.com"><path contains="photos/"/></url>
    <regexp re1="userid" re2="username">
      <![CDATA[/contextLink_stream(.+)">(.+)'s? photostream/]]>
    </regexp>
  </detect>

  <detect type="person">
    <url domain="flickr.com"><path contains="photos/"/></url>
    <regexp re1="userid">
      <![CDATA[/contextLink_stream(.+)">/]]>
    </regexp>
    <xpath name="username">
      <![CDATA[//div[@class="Widget"]//a/b/text()]]>
    </xpath>
  </detect>

  <detect type="person">
    <url domain="flickr.com"><path contains="people/"/></url>
    <regexp re1="userid">
      <![CDATA[/messages_write\.gne\?to=(.+?)"/]]>
    </regexp>
    <regexp re1="username">
      <![CDATA[/<span class="nickname">(.+)</]]>
    </regexp>
  </detect>

  <detect type="pool">
    <url domain="flickr.com"><path contains="groups/"/></url>
    <conditions>
      <regexp><![CDATA[/Subscribe to .+ discussion threads/]]></regexp>
    </conditions>
    <results>
      <regexp re1="groupname">
        <![CDATA[/Subscribe to (.+) discussion threads/]]>
      </regexp>
      <regexp re1="groupid">
        <![CDATA[/\/groups_members\.gne\?id=([^"&]+)/]]>
      </regexp>
    </results>
  </detect>

  <detect type="pool">
    <url domain="flickr.com"/>
    <regexp re1="groupname">
      <![CDATA[/<a href="\/groups\/[^\/]+\/">([^<]+)</]]>
    </regexp>
    <regexp re1="groupid">
      <![CDATA[/\/groups_members[^\.]*\.gne\?id=([^"&]+)/]]>
    </regexp>
  </detect>

  <detect type="pool">
    <regexp re1="groupid" re2="groupname">
      <![CDATA[/id="contextLink_pool([^"]+)">(.+) \(Pool\)<\/a>/]]>
    </regexp>
  </detect>

  <detect type="apiAuth1">
    <conditions>
      <regexp><![CDATA[/value="OK, I'LL ALLOW IT"/]]></regexp>
    </conditions>
    <results>
      <regexp re1="magic_cookie">
        <![CDATA[/name="magic_cookie" value="(\w+)"/]]>
      </regexp>
      <regexp re1="api_sig">
        <![CDATA[/name="api_sig" value="(\w+)"/]]>
      </regexp>
    </results>
  </detect>

  <detect type="apiAuth2">
    <regexp><![CDATA[/<p class="Confirm">Success!<\/p>/]]></regexp>
  </detect>

  <detect type="apiAuth3">
    <regexp><![CDATA[/<a href="\/account" /]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/([^\/]*\.)?flickr\.com\/photos\/upload($|\/)/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/([^\/]*\.)?flickr\.com\/photos\/organize($|\/)/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/([^\/]*\.)?flickr\.com\/photos\/tags($|\/)/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/([^\/]*\.)?flickr\.com\/photos\/search($|\/)/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/[^\.]*\.?flickr\.com\/photos\/([^\/]+)\/.+/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/[^\.]*\.?flickr\.com\/apps\/video\/.+\.swf\..+/]]></regexp>
  </detect>

</service>
