<?xml version="1.0" encoding="utf-8"?>
<service name="youtube"
         version="$Id: youtube.xml 22902 2009-10-15 02:58:08Z justin $"
         xmlns="http://www.flock.com/web-detective#">

  <strings>
    <string name="domains" value="youtube.com,google.com" />
    <string name="shareIframeURL">
      <![CDATA[http://youtube.com/share_addresses]]>
    </string>
    <string name="userprofile">
      <![CDATA[http://www.youtube.com/profile?user=%accountid%]]>
    </string>
    <string name="inviteFriendsURL">
      <![CDATA[http://youtube.com/my_friends_invite]]>
    </string>
    <string name="friendprofile">
      <![CDATA[http://www.youtube.com/profile?user=%accountid%]]>
    </string>
    <string name="editprofile">
      <![CDATA[http://youtube.com/my_profile]]>
    </string>
    <string name="inbox">
      <![CDATA[http://youtube.com/my_messages]]>
    </string>
    <string name="friendMediaFave">
      <![CDATA[mediabar:favorites:]]>
    </string>
    <string name="friendMessage">
      <![CDATA[newtab:http://www.youtube.com/outbox?to_user=%friendid%]]>
    </string>
    <string name="friendShareFlock"
            value="method:shareFlock" />
    <string name="friendViewProfile">
      <![CDATA[newtab:http://www.youtube.com/user/%friendid%]]>
    </string>
    <string name="meMessages_URL">
      <![CDATA[http://youtube.com/my_messages]]>
    </string>
    <string name="youtubeMedia_URL">
      <![CDATA[http://www.youtube.com/?v=%VIDEO_ID%]]>
    </string>
    <string name="youtubeMessage_URL">
      <![CDATA[http://www.youtube.com/inbox?action_compose=1&to_users=%friendid%]]>
    </string>
    <string name="youtubeShare_URL">
      <![CDATA[http://youtube.com/share?v=%videoid%]]>
    </string>
    <string name="shareAction_sharevideo_features">
     <![CDATA[width=580,height=480,resizable=yes,scrollbars=yes,status=0]]>
    </string>
    <string name="youtubemessage_subjectXPath">
     <![CDATA[//div[@id="baseDiv"]//input[@id="compose_subject"]]]>
    </string>
    <string name="youtubemessage_bodyXPath">
     <![CDATA[//div[@id="baseDiv"]//textarea[@id="compose_message"]]]>
    </string>
    <string name="youtubeUserUploadNamespace">
     <![CDATA[#user.uploads]]>
    </string>
    <string name="dndXPathFields">
      <![CDATA[youtubemessage_bodyXPath,text/unicode]]>
    </string>
    <string name="avoidDnDXPathFields">
      <![CDATA[youtubecommentXPath;youtubecomment2XPath;youtubeprofile_commentXPath]]>
    </string>
    <string name="youtubecommentXPath">
      <![CDATA[//form[@id="comment_formmain_comment"]//textarea[@name="comment"]]]>
    </string>
    <string name="youtubecomment2XPath">
      <![CDATA[//form[@id="comment_formmain_comment2"]//textarea[@name="comment"]]]>
    </string>
    <string name="youtubeprofile_commentXPath">
      <![CDATA[//form[@name="comment_form"]//textarea[@name="comment"][@class="largeTextArea"]]]>
    </string>
    <string name="loginURL" locale="default">
      <![CDATA[http://www.youtube.com/login]]>
    </string>
    <string name="loginURL" locale="de">
      <![CDATA[http://de.youtube.com/login]]>
    </string>
    <string name="homePageURL" locale="default">
      <![CDATA[http://www.youtube.com/]]>
    </string>
    <string name="homePageURL" locale="de">
      <![CDATA[http://de.youtube.com/]]>
    </string>
  </strings>

  <sessioncookies>
    <cookie host=".youtube.com" name="LOGIN_INFO" path="/"/>
    <cookie host=".google.com" name="SID" path="/" />
  </sessioncookies>

  <detect type="login">
    <url domain="youtube.com"/>
    <form>
      <field tagname="input" name="username" type="text"/>
      <field tagname="input" name="password" type="password"/>
    </form>
  </detect>

  <detect type="login">
    <url domain="google.com">
      <path contains="/accounts/ServiceLogin" />
      <querystring contains="service=youtube" />
    </url>
    <form>
      <xpath name="username" extract="value">
        <![CDATA[//input[@id="Email"]]]>
      </xpath>
      <xpath name="password" extract="value">
        <![CDATA[//input[@id="Passwd"]]]>
      </xpath>
    </form>
  </detect>

  <detect type="googlelogin">
    <url domain="google.com">
      <path contains="/accounts/ServiceLogin" />
      <querystring contains="service=youtube" />
    </url>
  </detect>

  <detect type="signup">
    <url domain="youtube.com"><path contains="/signup"/></url>
    <form>
      <field tagname="input" name="username"/>
      <field tagname="input" type="password" name="password2" extractas="password"/>
    </form>
  </detect>

  <detect type="loggedin">
    <xpath><![CDATA[//a[contains(@onClick,"document.logoutForm.submit()")]]]></xpath>
  </detect>

  <detect type="loggedin">
    <xpath><![CDATA[//div[@class="dropdown-link"]/a[contains(@href,"/user/")]]]></xpath>
  </detect>

  <!-- Possibly obsolete as of 2008-07-17 -->
  <detect type="loggedin">
    <xpath><![CDATA[//div[@class="user-info"]//a[contains(@onClick,"document.logoutForm.submit()")]]]></xpath>
  </detect>

  <!-- Possibly obsolete as of 2008-07-17 -->
  <detect type="loggedin">
    <xpath><![CDATA[//div[@id="utilDiv"]//a[contains(@onClick,"document.logoutForm.submit()")]]]></xpath>
  </detect>

  <!-- Possibly obsolete as of 2008-07-17 -->
  <detect type="loggedin">
    <xpath><![CDATA[//table[@class="channelMastheadTable"]//a/text()[contains(.,"Log Out")]]]></xpath>
  </detect>

  <detect type="loggedout">
    <xpath extract="attribute:href">
      <![CDATA[//div[@id="masthead-utility"]//a]]>
      <regexp><![CDATA[/ServiceLogin\?.*service=youtube/]]></regexp>
    </xpath>
  </detect>

  <!-- Possibly obsolete as of 2009-10-13 -->
  <detect type="loggedout">
    <xpath extract="attribute:href">
      <![CDATA[//div[@id="masthead-user"]//a]]>
      <regexp><![CDATA[/ServiceLogin\?.*service=youtube/]]></regexp>
    </xpath>
  </detect>
  
  <!-- Possibly obsolete as of 2009-08-13 -->
  <detect type="loggedout">
    <xpath>
      <![CDATA[//span[@class="util-item"]/a[contains(@href, "/login?next=")]]]>
    </xpath>
  </detect>

  <detect type="loggedout">
    <xpath>
      <![CDATA[//div[@class="signInBoxContent"]/a[contains(@href, "/login?next=/index")]]]>
    </xpath>
  </detect>

  <!-- Possibly obsolete as of 2008-07-17 -->
  <detect type="loggedout">
    <xpath>
      <![CDATA[//span[@class="util-item"]//a[contains(@class,"loginBoxZ")][contains(@onclick,"openLoginBox(")]]]>
    </xpath>
  </detect>

  <!-- Possibly obsolete as of 2008-04-21 -->
  <detect type="loggedout">
    <xpath>
      <![CDATA[//span[@class="info-section"]//a[contains(@class,"loginBoxZ")][contains(@onclick,"openLoginBox(")]]]>
    </xpath>
  </detect>

  <!-- Possibly obsolete as of 2008-07-17 -->
  <detect type="loggedout">
    <xpath><![CDATA[//div[@id="baseDiv"]/div[@id="utilDiv"]//a[@onclick="_hbLink('LogIn','UtilityLinks');"]]]></xpath>
  </detect>

  <detect type="accountinfo"><!-- Matches on youtube.com/ -->
    <xpath name="accountid">
      <![CDATA[//div[@id="masthead-utility"]//span[@class="utility-item"]//a[contains(@href,"/user/")]/text()]]>
    </xpath>
  </detect>

  <!-- Possibly obsolete as of 2009-08-20 -->
  <detect type="accountinfo"><!-- Matches on youtube.com/ -->
    <xpath name="accountid">
      <![CDATA[//div[@id="masthead-user"]//span[@class="utility-item"]//a[contains(@href,"/user/")]/text()]]>
    </xpath>
  </detect>

  <!-- Possibly obsolete as of 2009-08-13 -->
  <detect type="accountinfo">
    <xpath name="accountid">
      <![CDATA[//div[@id="util-links"]//a[contains(@href,"/user/")]/text()]]>
    </xpath>
  </detect>

  <!-- Possibly obsolete as of 2009-06-15 -->
  <detect type="accountinfo">
    <xpath name="accountid">
      <![CDATA[//div[@class="user-info"]//a[contains(@href,"/user/")]/text()]]>
    </xpath>
  </detect>

  <detect type="accountinfo"><!-- Possibly obsolete as of 2009-06-03 -->
    <xpath name="accountid">
      <![CDATA[//div[@class="dropdown-link"]/a[contains(@onmousedown,"/UtilLinks/Channel")]/span/text()]]>
    </xpath>
  </detect>

  <detect type="accountinfo"><!-- Possibly obsolete as of 2008-03-26 -->
    <xpath name="accountid">
      <![CDATA[//div[@class="dropdown-link"]/a[contains(@onmousedown,"/UtilLinks/Channel")]/text()]]>
    </xpath>
  </detect>

  <detect type="messages">
    <regexp re1="messagecount">
      <![CDATA[/<a href="\/inbox\?folder=messages&amp;action_message=1">\((\d+)\)<\/a>/]]>
    </regexp>
  </detect>

  <!-- Possibly obsolete as of 2009-10-13 -->
  <detect type="messages">
    <regexp re1="messagecount">
      <![CDATA[/<span class="grayText smallText">\((\d+)\)<\/span>/]]>
    </regexp>
  </detect>

  <detect type="person">
    <conditions>
      <url>
        <path contains="profile"/>
        <querystring contains="user="/>
      </url>
    </conditions>
    <results>
      <url>
        <regexp re1="userid">
          <![CDATA[/user=(\w+)/]]>
        </regexp>
      </url>
      <document>
        <regexp re1="addFriendURL">
          <![CDATA[/a href="(.+?)">Add as Friend/]]>
        </regexp>
      </document>
    </results>
  </detect>
  
  <detect type="person">
    <regexp re1="userid">
      <![CDATA[/subscription_center\?add_user=(.+?)"/]]>
    </regexp>
    <results>
      <regexp re1="addFriendURL">
        <![CDATA[/user_id=(\w+)/]]>
      </regexp>
    </results>
  </detect>

  <detect type="media">
    <conditions>
      <url><path contains="profile"/></url>
    </conditions>
    <url>
      <regexp re1="userid">
        <![CDATA[/user=(\w+)/]]>
      </regexp>
    </url>
  </detect>

  <detect type="media">
    <regexp re1="userid">
      <![CDATA[/watchUsername\s=\s\'(\w+)'/]]>
    </regexp>
  </detect>

  <detect type="videoId">
    <regexp re1="videoId">
      <![CDATA[/^https?:\/\/[^\/]*\.?youtube.com\/v\/(.*)/]]>
    </regexp>
  </detect>

  <detect type="videoId">
    <regexp re1="videoId">
      <![CDATA[/^https?:\/\/[^\/]*\.?youtube.com\/watch\/v\/(.*)/]]>
    </regexp>
  </detect>

  <detect type="videoId">
    <regexp re1="videoId">
      <![CDATA[/^https?:\/\/[^\/]*\.?youtube.com\/watch\?v=(.*)/]]>
    </regexp>
  </detect>
  
  <detect type="videoId">
    <regexp re1="videoId">
      <![CDATA[/^https?:\/\/[^\/]*\.?youtube.com\/\?v=(.*)/]]>
    </regexp>
  </detect>
  
  <detect type="videoId">
    <regexp re1="videoId">
      <![CDATA[/^.*\/player2\.swf\?.*video_id=([^&]+).*/]]>
    </regexp>
  </detect>

  <detect type="videoId">
    <regexp re1="videoId">
      <![CDATA[/videos\/(.*)/]]>
    </regexp>
  </detect>

  <detect type="page">
    <regexp re1="friend">
      <![CDATA[/div class="largeTitles"\>\<b\>(.+)\<\/b\>/]]>
    </regexp>
  </detect>

  <detect type="page"><!-- Needs to match on profile page. Possibly obsolete as of 2008-06-30 -->
    <regexp re1="avatar">
      <![CDATA[/<img src="(http:\/\/.+\/.+.jpg)" alt="\S+"(\/)?>/]]>
    </regexp>
    <regexp re1="" re2="friend" re3="">
      <![CDATA[/div class="largeTitles"\>(\<b\>|<strong>)(.+)(\<\/b\>|<\/strong>)/]]>
    </regexp>
  </detect>

  <detect type="page"><!-- Needs to match on profile page. -->
    <regexp re1="avatar">
      <![CDATA[/<img\s+src="(http:\/\/.+\/.+.jpg)" alt="\S+"(\/)?>/]]>
    </regexp>
    <regexp re1="" re2="friend" re3="">
      <![CDATA[/div class="largeTitles"\>(\<b\>|<strong>)(.+)(\<\/b\>|<\/strong>)/]]>
    </regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/[^\/]*\.?youtube.com\/v\/.*/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/[^\/]*\.?youtube.com\/watch\/v\/.*/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/[^\/]*\.?youtube.com\/watch\?v=.*/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/[^\/]*\.?youtube.com\/player.*\.swf/]]></regexp>
  </detect>

  <detect type="isStreamUrl">
    <regexp><![CDATA[/^https?:\/\/[^\/]*\.?ytimg.com\/yt\/swf\/.*\.swf/]]></regexp>
  </detect>

  <detect type="mediabarDud">
    <regexp><![CDATA[/\/my_videos_edit/g]]></regexp>
  </detect>

</service>
