]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/commitdiff
Fixed the Howcast downloads.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 27 Sep 2009 00:20:41 +0000 (20:20 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 2 Oct 2009 02:49:10 +0000 (22:49 -0400)
Modified the Howcast class to parse an XML file containing the real video URL.
Added a test for the new method.

src/websites/howcast.rb
test/fixtures/howcast/81134.xml [new file with mode: 0644]
test/howcast_test.rb

index c8dfcd3fc12a13564bcd53c56d9ccaf81621c75a..58861e7d1da0ebf555f2ee06ba0077dfa56e0fda 100644 (file)
@@ -26,8 +26,19 @@ class Howcast < Website
     return url =~ VALID_HOWCAST_URL_REGEX
   end
 
+  def get_video_url()
+    video_id = parse_video_id()
+    xml_url = "http://www.howcast.com/videos/#{video_id}.xml"
+    xml_data = self.get_page_data(xml_url)
+    filepath = parse_file_path_from_xml(xml_data)
+    
+    return "http://www.howcast.com#{filepath}"
+  end
 
-  def parse_video_id()
+  :private
+
+    def parse_video_id()
     # This regex just pulls out the video id
     id_regex = /\/(\d+)-/
     matches = id_regex.match(@url)
@@ -39,12 +50,16 @@ class Howcast < Website
     return matches[1]
   end
 
-  
-  def get_video_url()
-    video_id = parse_video_id()
-    
-    return "http://media.howcast.com/system/videos/#{video_id}/#{video_id}.flv"
+
+  def parse_file_path_from_xml(data)
+    file_path_regex = /<filename>(.*?)<\/filename>/
+    matches = file_path_regex.match(data)
+
+    if matches.nil?
+      raise StandardError.new("Couldn't parse the <filename> tag from the XML file.")
+    end
+
+    return matches[1]
   end
 
-  
 end
diff --git a/test/fixtures/howcast/81134.xml b/test/fixtures/howcast/81134.xml
new file mode 100644 (file)
index 0000000..b5c9282
--- /dev/null
@@ -0,0 +1,586 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<howcast version="0.1">
+  <video>
+    <id>81134</id>
+    <category-id>884</category-id>
+    <category-hierarchy>
+      <category id="841">Language &amp; Reference</category>
+      <category parent_id="841" id="875">Etiquette</category>
+      <category parent_id="875" id="884">Socially Awkward Situations</category>
+    </category-hierarchy>
+    <easy-steps>true</easy-steps>
+    <created-at>Sun, 16 Nov 2008 05:01:46 -0800</created-at>
+    <filename>/system/videos/4/34/11/08/81134.flv</filename>
+    <tags>DIY, Instructional, tutorial, Do It Yourself, Tips, Essential Skills, Learn to, language, reference, etiquette</tags>
+    <title>How To Act If a Dog Is Humping Your Leg</title>
+    <description>
+      <![CDATA[Everyone loves a party—until the host’s pooch starts giving your leg a little bit of his doggie style. Show that canine he’s not humping any old bitch.]]>
+    </description>
+    <permalink>http://www.howcast.com/videos/81134-How-To-Act-If-a-Dog-Is-Humping-Your-Leg</permalink>
+    <edit-url>http://www.howcast.com/videos/81134-How-To-Act-If-a-Dog-Is-Humping-Your-Leg/edit</edit-url>
+    <state>approved</state>
+    <duration>103</duration>
+    <width>640</width>
+    <height>360</height>
+    <embed>&lt;object width="425" height="273" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"&gt;&lt;param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=81134"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowScriptAccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.howcast.com/flash/howcast_player.swf?file=81134" type="application/x-shockwave-flash" width="425" height="273" allowFullScreen="true" allowScriptAccess="always" &gt;&lt;/embed&gt;&lt;/object&gt;</embed>
+    <rating>12</rating>
+    <username>vertizonticalstudios</username>
+    <thumbnail-url>http://img.howcast.com/system/thumbnails/81134/50_xxlarge_maintained_aspect.jpg</thumbnail-url>
+    <views>6608</views>
+    <overlay>
+      <titlecard>false</titlecard>
+      <steps>false</steps>
+      <overlays>false</overlays>
+    </overlay>
+    <ingredients>
+      <ingredient>
+        <![CDATA[Calm nerves]]>
+      </ingredient>
+      <ingredient>
+        <![CDATA[Quick wits]]>
+      </ingredient>
+      <ingredient>
+        <![CDATA[Snack food]]>
+      </ingredient>
+      <ingredient>
+        <![CDATA[Wet naps (just in case)]]>
+      </ingredient>
+    </ingredients>
+    <markers>
+      <marker>
+        <id>49488</id>
+        <position>1</position>
+        <timemarker>25</timemarker>
+        <type>Step</type>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/81134/25.jpg</thumbnail-url>
+        <title>Don&#8217;t panic</title>
+        <textile-text>
+          <![CDATA[Stay calm. In addition to your apparently enthralling scent, fear can be sniffed out by dogs—so panicking may only exacerbate the situation. ]]>
+        </textile-text>
+        <text>
+          <![CDATA[<p>Stay calm. In addition to your apparently enthralling scent, fear can be sniffed out by dogs—so panicking may only exacerbate the situation.</p>]]>
+        </text>
+      </marker>
+      <marker>
+        <id>49489</id>
+        <position>2</position>
+        <timemarker>35</timemarker>
+        <type>Step</type>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/81134/35.jpg</thumbnail-url>
+        <title>Try a bribe</title>
+        <textile-text>
+          <![CDATA[Drag yourself and your frisky friend over to the buffet table and discreetly offer him a tasty treat in exchange for a dismount. ]]>
+        </textile-text>
+        <text>
+          <![CDATA[<p>Drag yourself and your frisky friend over to the buffet table and discreetly offer him a tasty treat in exchange for a dismount.</p>]]>
+        </text>
+      </marker>
+      <marker>
+        <id>49490</id>
+        <position>3</position>
+        <timemarker>43</timemarker>
+        <type>Tip</type>
+        <thumbnail-url></thumbnail-url>
+        <title></title>
+        <textile-text>
+          <![CDATA[Go for a meaty snack; he probably won’t let go of your leg for a celery stick. ]]>
+        </textile-text>
+        <text>
+          <![CDATA[<p>Go for a meaty snack; he probably won’t let go of your leg for a celery stick.</p>]]>
+        </text>
+      </marker>
+      <marker>
+        <id>49491</id>
+        <position>4</position>
+        <timemarker>50</timemarker>
+        <type>Step</type>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/81134/50.jpg</thumbnail-url>
+        <title>Fake him out</title>
+        <textile-text>
+          <![CDATA[If you don’t have a snack, try throwing an imaginary ball across the room.]]>
+        </textile-text>
+        <text>
+          <![CDATA[<p>If you don’t have a snack, try throwing an imaginary ball across the room.</p>]]>
+        </text>
+      </marker>
+      <marker>
+        <id>49492</id>
+        <position>5</position>
+        <timemarker>55</timemarker>
+        <type>Step</type>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/81134/55.jpg</thumbnail-url>
+        <title>Make a joke</title>
+        <textile-text>
+          <![CDATA[If none of your tricks have worked, it’s time to get others involved. Call attention to your predicament with a joke. Just be cool about it. Your host will be embarrassed enough without you piling on.]]>
+        </textile-text>
+        <text>
+          <![CDATA[<p>If none of your tricks have worked, it’s time to get others involved. Call attention to your predicament with a joke. Just be cool about it. Your host will be embarrassed enough without you piling on.</p>]]>
+        </text>
+      </marker>
+      <marker>
+        <id>49493</id>
+        <position>6</position>
+        <timemarker>66</timemarker>
+        <type>Tip</type>
+        <thumbnail-url></thumbnail-url>
+        <title></title>
+        <textile-text>
+          <![CDATA[Try this one: “Whoa, easy there, Fido—that’s not a Milk Bone in my pocket.”]]>
+        </textile-text>
+        <text>
+          <![CDATA[<p>Try this one: “Whoa, easy there, Fido—that’s not a Milk Bone in my pocket.”</p>]]>
+        </text>
+      </marker>
+      <marker>
+        <id>49494</id>
+        <position>7</position>
+        <timemarker>73</timemarker>
+        <type>Step</type>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/81134/73.jpg</thumbnail-url>
+        <title>Demand assistance</title>
+        <textile-text>
+          <![CDATA[At this point, if the mutt has not been removed, all bets are off. You are well within your rights to howl at your host. Feel free to use profanity.]]>
+        </textile-text>
+        <text>
+          <![CDATA[<p>At this point, if the mutt has not been removed, all bets are off. You are well within your rights to howl at your host. Feel free to use profanity.</p>]]>
+        </text>
+      </marker>
+      <marker>
+        <id>49495</id>
+        <position>8</position>
+        <timemarker>84</timemarker>
+        <type>Step</type>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/81134/84.jpg</thumbnail-url>
+        <title>Ride it out</title>
+        <textile-text>
+          <![CDATA[If the dog’s owner is uncooperative, you just may have to weather the storm. Who knows? Maybe you’ll get a new best friend out of the deal.]]>
+        </textile-text>
+        <text>
+          <![CDATA[<p>If the dog’s owner is uncooperative, you just may have to weather the storm. Who knows? Maybe you’ll get a new best friend out of the deal.</p>]]>
+        </text>
+      </marker>
+      <marker>
+        <id>49496</id>
+        <position>9</position>
+        <timemarker>93</timemarker>
+        <type>Fact</type>
+        <thumbnail-url></thumbnail-url>
+        <title></title>
+        <textile-text>
+          <![CDATA[Neutered and female dogs sometimes hump legs as an act of dominance, not sex—so get over yourself already!]]>
+        </textile-text>
+        <text>
+          <![CDATA[<p>Neutered and female dogs sometimes hump legs as an act of dominance, not sex—so get over yourself already!</p>]]>
+        </text>
+      </marker>
+    </markers>
+    <related-videos>
+      <video>
+        <category-id>884</category-id>
+        <id>185824</id>
+        <title>How To Pick a Wedgie in Public</title>
+        <type>AssignmentGuide</type>
+        <views>2876</views>
+        <created-at>Wed, 27 May 2009 14:34:04 -0700</created-at>
+        <rating>6</rating>
+        <username>michaelrsanchez</username>
+        <description>
+          <![CDATA[Discomfort. Embarrassment. The wedgie. Get rid of the problem with these simple tips.]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="273" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=185824"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=185824" type="application/x-shockwave-flash" width="425" height="273" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>71</duration>
+        <filename>http://media.howcast.com/system/videos/2/24/58/18/185824.flv</filename>
+        <tags>etiquette, picking, wedgie, socially, awkward, situations, adjusting, underwear, panties, public</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="875">Etiquette</category>
+          <category parent_id="875" id="884">Socially Awkward Situations</category>
+        </category-hierarchy>
+        <comment-count>2</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/185824/Picture_7_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/185824-How-To-Pick-a-Wedgie-in-Public</permalink>
+      </video>
+      <video>
+        <category-id>876</category-id>
+        <id>169677</id>
+        <title>How To Ask Someone To Be Quiet in a Movie Theater</title>
+        <type>AssignmentGuide</type>
+        <views>9268</views>
+        <created-at>Fri, 10 Apr 2009 09:17:09 -0700</created-at>
+        <rating>13</rating>
+        <username>Equilibrio</username>
+        <description>
+          <![CDATA[Don’t you just hate it when a fellow moviegoer provides a running commentary? Here’s how to silence the squawker.]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="273" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=169677"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=169677" type="application/x-shockwave-flash" width="425" height="273" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>126</duration>
+        <filename>http://media.howcast.com/system/videos/4/77/96/16/169677.flv</filename>
+        <tags>DIY, Instructional, tutorial, Do It Yourself, Tips, Essential Skills, Learn to, language, etiquette, manners</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="875">Etiquette</category>
+          <category parent_id="875" id="876">General Etiquette</category>
+        </category-hierarchy>
+        <comment-count>3</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/169677/Picture_4_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/169677-How-To-Ask-Someone-To-Be-Quiet-in-a-Movie-Theater</permalink>
+      </video>
+      <video>
+        <category-id>880</category-id>
+        <id>223282</id>
+        <title>How To Improve Your Telephone Manner</title>
+        <type>AssignmentGuide</type>
+        <views>421</views>
+        <created-at>Tue, 08 Sep 2009 13:03:22 -0700</created-at>
+        <rating>2</rating>
+        <username>downpourpro</username>
+        <description>
+          <![CDATA[Phone skills lacking polish? Make a professional impression with the help of these steps.]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="352" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=223282"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=223282" type="application/x-shockwave-flash" width="425" height="352" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>84</duration>
+        <filename>http://media.howcast.com/system/videos/2/06/64/23/236406.flv</filename>
+        <tags>improving,telephone,phone,manner,voice,sounding,polishing,skills,professional</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="875">Etiquette</category>
+          <category parent_id="875" id="880">Electronic Communication Etiquette</category>
+        </category-hierarchy>
+        <comment-count>1</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/223282/Picture_11_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/223282-How-To-Improve-Your-Telephone-Manner</permalink>
+      </video>
+      <video>
+        <category-id>883</category-id>
+        <id>19184</id>
+        <title>How To Salute</title>
+        <type>AssignmentGuide</type>
+        <views>3755</views>
+        <created-at>Mon, 21 Jul 2008 05:01:25 -0700</created-at>
+        <rating>5</rating>
+        <username>michaelrsanchez</username>
+        <description>
+          <![CDATA[Everybody who's seen a war movie thinks they know how it's done, but here's how to execute a salute that would make even the toughest drill sergeant proud.]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="352" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=19184"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=19184" type="application/x-shockwave-flash" width="425" height="352" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>79</duration>
+        <filename>http://media.howcast.com/system/videos/4/84/91/01/19184.flv</filename>
+        <tags>DIY, Instructional, tutorial, Do It Yourself, Tips, Essential Skills, Learn to, language, salute, saluting</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="875">Etiquette</category>
+          <category parent_id="875" id="883">Personal Communications Etiquette</category>
+        </category-hierarchy>
+        <comment-count>1</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/19184/Picture_10_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/19184-How-To-Salute</permalink>
+      </video>
+      <video>
+        <category-id>883</category-id>
+        <id>105154</id>
+        <title>How To Shake Hands</title>
+        <type>AssignmentGuide</type>
+        <views>3376</views>
+        <created-at>Thu, 18 Dec 2008 10:16:05 -0800</created-at>
+        <rating>9</rating>
+        <username>michaelrsanchez</username>
+        <description>
+          <![CDATA[Sure, you know how to do it. But do you know how to do it well?]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="273" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=105154"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=105154" type="application/x-shockwave-flash" width="425" height="273" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>73</duration>
+        <filename>http://media.howcast.com/system/videos/0/54/51/10/105154.flv</filename>
+        <tags>DIY, Instructional, tutorial, Do It Yourself, Tips, Essential Skills, Learn to, language, body, etiquette</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="875">Etiquette</category>
+          <category parent_id="875" id="883">Personal Communications Etiquette</category>
+        </category-hierarchy>
+        <comment-count>3</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/105154/35_xxlarge_maintained_aspect.jpg</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/105154-How-To-Shake-Hands</permalink>
+      </video>
+      <video>
+        <category-id>883</category-id>
+        <id>207871</id>
+        <title>How To Train Yourself To Be on Time</title>
+        <type>AssignmentGuide</type>
+        <views>1607</views>
+        <created-at>Thu, 23 Jul 2009 11:17:31 -0700</created-at>
+        <rating>9</rating>
+        <username>downpourpro</username>
+        <description>
+          <![CDATA[In the immortal words of Benjamin Franklin, "time is money." Spend it wisely.]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="352" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=207871"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=207871" type="application/x-shockwave-flash" width="425" height="352" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>80</duration>
+        <filename>http://media.howcast.com/system/videos/6/71/78/20/207871.flv</filename>
+        <tags>on time, train, yourself, not late, late, never late, time, personal, Train yourself, Tips</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="875">Etiquette</category>
+          <category parent_id="875" id="883">Personal Communications Etiquette</category>
+        </category-hierarchy>
+        <comment-count>3</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/207871/Picture_4_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/207871-How-To-Train-Yourself-To-Be-on-Time</permalink>
+      </video>
+      <video>
+        <category-id>885</category-id>
+        <id>218366</id>
+        <title>How To Be a Good Houseguest</title>
+        <type>AssignmentGuide</type>
+        <views>666</views>
+        <created-at>Tue, 25 Aug 2009 13:17:34 -0700</created-at>
+        <rating>1</rating>
+        <username>CinemaSlam</username>
+        <description>
+          <![CDATA[There’s an art to being a good houseguest – now you can master it.]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="273" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=218366"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=218366" type="application/x-shockwave-flash" width="425" height="273" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>91</duration>
+        <filename>http://media.howcast.com/system/videos/1/88/19/23/231988.flv</filename>
+        <tags>houseguest, house, guest, home, good, etiquette, language, social gathering</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="875">Etiquette</category>
+          <category parent_id="875" id="885">Social Gatherings</category>
+        </category-hierarchy>
+        <comment-count>2</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/218366/Picture_2_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/218366-How-To-Be-a-Good-Houseguest</permalink>
+      </video>
+      <video>
+        <category-id>843</category-id>
+        <id>188373</id>
+        <title>How To Research Your Genealogy and Family Tree</title>
+        <type>AssignmentGuide</type>
+        <views>588</views>
+        <created-at>Mon, 01 Jun 2009 13:17:57 -0700</created-at>
+        <rating>2</rating>
+        <username>dogtide</username>
+        <description>
+          <![CDATA[Researching genealogy takes a little enterprise and the skills of a master sleuth.]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="352" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=188373"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=188373" type="application/x-shockwave-flash" width="425" height="352" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>98</duration>
+        <filename>http://media.howcast.com/system/videos/3/73/83/18/188373.flv</filename>
+        <tags>language, researching, Genealogy, genes, genetic, family, tree, roots, history, personal</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="842">Reference</category>
+          <category parent_id="842" id="843">Genealogy</category>
+        </category-hierarchy>
+        <comment-count>1</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/188373/Picture_3_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/188373-How-To-Research-Your-Genealogy-and-Family-Tree</permalink>
+      </video>
+      <video>
+        <category-id>847</category-id>
+        <id>15403</id>
+        <title>How To Write a Love Letter</title>
+        <type>AssignmentGuide</type>
+        <views>6350</views>
+        <created-at>Wed, 25 Jun 2008 08:00:36 -0700</created-at>
+        <rating>3</rating>
+        <username>jeewigz</username>
+        <description>
+          <![CDATA[How much do you love what’s-her-face? Here’s how to count the ways…]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="352" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=15403"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=15403" type="application/x-shockwave-flash" width="425" height="352" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>119</duration>
+        <filename>http://media.howcast.com/system/videos/3/03/54/01/15403.flv</filename>
+        <tags>DIY, Instructional, tutorial, Do It Yourself, Tips, Essential Skills, Learn to, language, writing, write</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="846">Writing</category>
+          <category parent_id="846" id="847">General Writing</category>
+        </category-hierarchy>
+        <comment-count>3</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/15403/Picture_26_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/15403-How-To-Write-a-Love-Letter</permalink>
+      </video>
+      <video>
+        <category-id>847</category-id>
+        <id>92204</id>
+        <title>How To Write a Letter Of Complaint</title>
+        <type>AssignmentGuide</type>
+        <views>3145</views>
+        <created-at>Thu, 04 Dec 2008 14:01:47 -0800</created-at>
+        <rating>9</rating>
+        <username>Equilibrio</username>
+        <description>
+          <![CDATA[They say the pen is mightier than the sword, so if you’ve had a bad experience with a company, use your mightiest weapon to get satisfaction! ]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="273" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=92204"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=92204" type="application/x-shockwave-flash" width="425" height="273" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>150</duration>
+        <filename>http://media.howcast.com/system/videos/0/04/22/09/92204.flv</filename>
+        <tags>DIY, Instructional, tutorial, Do It Yourself, Tips, Essential Skills, Learn to, language, writing, write</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="846">Writing</category>
+          <category parent_id="846" id="847">General Writing</category>
+        </category-hierarchy>
+        <comment-count>4</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/92204/Picture_5_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/92204-How-To-Write-a-Letter-Of-Complaint</permalink>
+      </video>
+      <video>
+        <category-id>847</category-id>
+        <id>174455</id>
+        <title>How To Write a Grant Proposal</title>
+        <type>AssignmentGuide</type>
+        <views>1198</views>
+        <created-at>Wed, 29 Apr 2009 12:32:28 -0700</created-at>
+        <rating>3</rating>
+        <username>rsansivero</username>
+        <description>
+          <![CDATA[If your organization has come up with a great idea that needs money to get off the ground, you'll need a great proposal. Here's how to write one.]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="352" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=174455"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=174455" type="application/x-shockwave-flash" width="425" height="352" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>131</duration>
+        <filename>http://media.howcast.com/system/videos/1/55/44/17/174455.flv</filename>
+        <tags>language, writing, event, fundraising, non-profit, non, profit, money, organization, funding</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="846">Writing</category>
+          <category parent_id="846" id="847">General Writing</category>
+        </category-hierarchy>
+        <comment-count>1</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/174455/Picture_1_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/174455-How-To-Write-a-Grant-Proposal</permalink>
+      </video>
+      <video>
+        <category-id>847</category-id>
+        <id>195717</id>
+        <title>How To Improve Your Handwriting</title>
+        <type>AssignmentGuide</type>
+        <views>5873</views>
+        <created-at>Wed, 17 Jun 2009 12:03:25 -0700</created-at>
+        <rating>10</rating>
+        <username>Leonello_Cineas</username>
+        <description>
+          <![CDATA[Have you been typing at computers for so long that your handwriting has become unreadable? Follow these steps to make your handwriting beautiful again. ]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="352" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=195717"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=195717" type="application/x-shockwave-flash" width="425" height="352" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>87</duration>
+        <filename>http://media.howcast.com/system/videos/4/17/57/19/195717.flv</filename>
+        <tags>language, writing, improving, better, handwriting, penmanship, readable</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="846">Writing</category>
+          <category parent_id="846" id="847">General Writing</category>
+        </category-hierarchy>
+        <comment-count>2</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/195717/Picture_2_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/195717-How-To-Improve-Your-Handwriting</permalink>
+      </video>
+      <video>
+        <category-id>869</category-id>
+        <id>154759</id>
+        <title>How To Get Your FBI File</title>
+        <type>AssignmentGuide</type>
+        <views>2446</views>
+        <created-at>Mon, 02 Mar 2009 13:47:07 -0800</created-at>
+        <rating>12</rating>
+        <username>Michael_Grosse</username>
+        <description>
+          <![CDATA[Thanks to the Freedom of Information and Privacy acts, we’re all entitled to see what the FBI has on us. ]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="352" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=154759"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=154759" type="application/x-shockwave-flash" width="425" height="352" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>96</duration>
+        <filename>http://media.howcast.com/system/videos/3/59/47/15/154759.flv</filename>
+        <tags>DIY, Instructional, tutorial, Do It Yourself, Tips, Essential Skills, Learn to, language, politics, citizenship</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="867">Politics &amp; Citizenship</category>
+          <category parent_id="867" id="869">Citizenship Tasks</category>
+        </category-hierarchy>
+        <comment-count>1</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/154759/Picture_7_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/154759-How-To-Get-Your-FBI-File</permalink>
+      </video>
+      <video>
+        <category-id>870</category-id>
+        <id>170731</id>
+        <title>How To Send Care Packages To Troops Overseas</title>
+        <type>AssignmentGuide</type>
+        <views>11568</views>
+        <created-at>Fri, 10 Apr 2009 09:47:29 -0700</created-at>
+        <rating>6</rating>
+        <username>bry9000</username>
+        <description>
+          <![CDATA[You want to show a special service member – or even a group of troops – that you care. What better way than to send thoughtful gifts?]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="273" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=170731"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=170731" type="application/x-shockwave-flash" width="425" height="273" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>198</duration>
+        <filename>http://media.howcast.com/system/videos/1/31/07/17/170731.flv</filename>
+        <tags>DIY, Instructional, tutorial, Do It Yourself, Tips, Essential Skills, Learn to, language, reference, politics</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="867">Politics &amp; Citizenship</category>
+          <category parent_id="867" id="870">Military &amp; Law Enforcement</category>
+        </category-hierarchy>
+        <comment-count>1</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/170731/Picture_3_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/170731-How-To-Send-Care-Packages-To-Troops-Overseas</permalink>
+      </video>
+      <video>
+        <category-id>873</category-id>
+        <id>174024</id>
+        <title>How To Overcome Speech Anxiety</title>
+        <type>AssignmentGuide</type>
+        <views>1698</views>
+        <created-at>Wed, 22 Apr 2009 13:36:54 -0700</created-at>
+        <rating>5</rating>
+        <username>EthanBorden</username>
+        <description>
+          <![CDATA[Anyone can become a calm, compelling speaker with these pointers. Commit them to memory before you deliver your next address.]]>
+        </description>
+        <embed>
+          <![CDATA[<object width="425" height="352" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="howcastplayer"><param name="movie" value="http://www.howcast.com/flash/howcast_player.swf?file=174024"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.howcast.com/flash/howcast_player.swf?file=174024" type="application/x-shockwave-flash" width="425" height="352" allowFullScreen="true" allowScriptAccess="always" ></embed></object>]]>
+        </embed>
+        <duration>89</duration>
+        <filename>http://media.howcast.com/system/videos/4/24/40/17/174024.flv</filename>
+        <tags>DIY, Instructional, tutorial, Do It Yourself, Tips, Essential Skills, Learn to, mind, overcome, overcoming</tags>
+        <category-hierarchy>
+          <category id="841">Language &amp; Reference</category>
+          <category parent_id="841" id="871">Public Speaking</category>
+          <category parent_id="871" id="873">Speeches</category>
+        </category-hierarchy>
+        <comment-count>1</comment-count>
+        <thumbnail-url>http://img.howcast.com/system/thumbnails/174024/Picture_1_xxlarge_maintained_aspect.png</thumbnail-url>
+        <permalink>http://www.howcast.com/videos/174024-How-To-Overcome-Speech-Anxiety</permalink>
+      </video>
+    </related-videos>
+    <comments count="6"/>
+  </video>
+</howcast>
index a76c725689f01259f3219ca1cc9a0ce48e787b25..aacfcf2d65b670299d66a66188a3a2e4cf2ae868 100644 (file)
@@ -42,7 +42,23 @@ class HowcastTest < Test::Unit::TestCase
     assert(!Howcast.owns_url?('redtube.com/6807'))
   end
 
+  
   def test_doesnt_own_misc_urls
     assert(!Howcast.owns_url?('http://www.howcast.com/abc'))
   end
+
+  
+  def test_parse_file_path_from_xml
+    hc = Howcast.new(nil)
+    
+    page_data = nil
+    
+    File.open('test/fixtures/howcast/81134.xml') do |f|
+      page_data = f.read
+    end
+    
+    test_result = hc.send('parse_file_path_from_xml', page_data)
+    assert_equal('/system/videos/4/34/11/08/81134.flv', test_result)
+  end
+  
 end