{"id":11,"date":"2005-04-10T23:44:15","date_gmt":"2005-04-11T06:44:15","guid":{"rendered":"http:\/\/thecompany.net\/jason\/posts\/2005\/netflix-plugin\/"},"modified":"2005-04-11T00:28:27","modified_gmt":"2005-04-11T07:28:27","slug":"netflix-plugin","status":"publish","type":"post","link":"https:\/\/thecompany.net\/jason\/posts\/2005\/netflix-plugin\/","title":{"rendered":"Netflix plugin"},"content":{"rendered":"<p>The Netflix plugin that I first started using wasn&#8217;t all to feature-oriented. It basically took a Netflix RSS feed and dumped it without any processing or formatting. That is, if you wanted to display your activity queue, it just spit the 3 (or however many DVDs you can have out at one time) most recent discs shipped to you, and the most recent discs you returned. Plus, it didn&#8217;t have any way of displaying your rental queue.<\/p>\n<p>Well, I didn&#8217;t think that was too cool, so I decided to hack away at it.<\/p>\n<p>First, I modified it so that it would only show the discs most recently shipped to you. Then I realized that it might be cool, also, to show the discs you most recently returned. So I took the function and gave it some arguments &#8212; you can specify an &#8220;action&#8221; as &#8220;rented&#8221; and &#8220;returned.&#8221; Then I realized that you might want to see both in the same list, so I added an &#8220;activity&#8221; variable as well.<\/p>\n<p>To that, I added the &#8220;queue&#8221; action which spit out your rental queue&#8230; Well, my queue has over 100 discs, so that was overkill, so I added the ability to limit (mine is current set at six, since that&#8217;s about as far ahead as I plan my queue).<\/p>\n<p>After I finished all of that, I thought sometime in the future it might be nice to customize the way the list is presented (mainly, whether it should be an ordered list &#8212; &lt;ol&gt; &#8212; or an unordered list &#8212; &lt;ul&gt;), so I added arguments for those elements as well.<\/p>\n<p>I&#8217;m not sure exactly how to go ahead and submit these modifications as a plugin, but I&#8217;ll look into that. For the time being, here is the code if anyone else uses WordPress and wants the functionality:<\/p>\n<pre>\r\nfunction mynetflix(\r\n $action,\r\n $listtag=\"ul\",\r\n $itemtag=\"li\",\r\n $count=10) {\r\n\r\nglobal $activityurl;\r\nglobal $queueurl;\r\n\r\nswitch ($action) {\r\n\r\n case \"rented\" :\r\n case \"returned\" :\r\n case \"activity\" : {\r\n\r\n  $rss = fetch_rss($activityurl);\r\n  echo \"&lt;\".$listtag.\"&gt;\\n\";\r\n  \r\n  foreach($rss-&gt;items as $item) {\r\n   $title = $item[\"title\"];\r\n   $link = $item[\"link\"];\r\n   $desc = $item[\"description\"];\r\n   \r\n   $parts = explode(\":\", $title, 2);\r\n   $act = trim($parts[0]);\r\n   $title = trim($parts[1]);\r\n   \r\n   $parts = explode(\".\", $desc, 2);\r\n   $date = strip_tags(trim($parts[0]));\r\n\r\n   $a = \"&lt;\".$itemtag.\"&gt;\\n\";\r\n   $b = \"&lt;\/\".$itemtag.\"&gt;\\n\";\r\n  \r\n   if($act == \"Shipped\" && $action == \"rented\")\r\n    echo wptexturize($a.\"&lt;a href=\"\".$link.\"\"&gt;\".\r\n     $title.\"&lt;\/a&gt;&amp;nbsp;\".$date.$b);\r\n   else if($act == \"Received\" && $action == \"returned\")\r\n    echo wptexturize($a.\"&lt;a href=\"\".$link.\"\"&gt;\".\r\n     $title.\"&lt;\/a&gt;&amp;nbsp;\".$date.$b);\r\n   else if($action == \"activity\")\r\n    echo wptexturize($a.\"&lt;a href=\"\".$link.\"\"&gt;\".\r\n     $title.\"&lt;\/a&gt;&amp;nbsp;\".$date.$b);   \r\n  }\r\n \r\n  echo \"&lt;\/\".$listtag.\"&gt;\\n\";\r\n \r\n  break;\r\n }\r\n\r\n case \"queue\" : {\r\n  $rss = fetch_rss($queueurl);\r\n  \r\n  echo \"&lt;\".$listtag.\"&gt;\\n\";\r\n  \r\n  $i=0;\r\n  foreach($rss-&gt;items as $item) {\r\n   if($i &gt;= $count) break;\r\n   \r\n   $parts = explode(\"-\", $item[\"title\"], 2);\r\n   $num = trim($parts[0]);\r\n   $title = trim($parts[1]);\r\n   $link = $item[\"link\"];\r\n\r\n   echo \"&lt;\".$itemtag.\" value=\"\".$num.\"\"&gt;\\n\";\r\n   echo wptexturize(\"&lt;a href=\"\".$link.\"\"&gt;\".$title.\"&lt;\/a&gt;\");\r\n   echo \"&lt;\/\".$itemtag.\"&gt;\\n\";\r\n   $i++;\r\n  }\r\n  \r\n  echo \"&lt;\/\".$listtag.\"&gt;\\n\"; \r\n  break;\r\n }\r\n}\r\n}\r\n<\/pre>\n<p>To use it, you define two varibles:<\/p>\n<pre>\r\n$activityurl\t= \"look on your Netflix RSS page\"; \r\n$queueurl\t\t= \"look on your Netflix RSS page\";\r\n<\/pre>\n<p>And call the function like:<\/p>\n<pre>\r\n&lt;?php mynetflix('rented'); echo \"\\n\"; ?&gt;\r\n<\/pre>\n<p>or<\/p>\n<pre>\r\n&lt;?php mynetflix('queue', 'ol', 'li', 6); echo \"\\n\"; ?&gt;\r\n<\/pre>\n<p>Magic! I love this stuff!<\/p>\n<p><strong>Update:<\/strong><br \/>\nI really do impress myself \ud83d\ude42 I just added some more functionality so that a page like <a href=\"my-entire-netflix-queue\/\">My Entire Netflix Queue<\/a> works&#8230; check it out. The biggest addition was the ability to show the description (which Netflix feeds in the RSS).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Netflix plugin that I first started using wasn&#8217;t all to feature-oriented. It basically took a Netflix RSS feed and dumped it without any processing or formatting. That is, if you wanted to display your activity queue, it just spit the 3 (or however many DVDs you can have out at one time) most recent &hellip; <a href=\"https:\/\/thecompany.net\/jason\/posts\/2005\/netflix-plugin\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Netflix plugin<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[2],"tags":[],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/thecompany.net\/jason\/wp-json\/wp\/v2\/posts\/11"}],"collection":[{"href":"https:\/\/thecompany.net\/jason\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thecompany.net\/jason\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thecompany.net\/jason\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thecompany.net\/jason\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":0,"href":"https:\/\/thecompany.net\/jason\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"wp:attachment":[{"href":"https:\/\/thecompany.net\/jason\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thecompany.net\/jason\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thecompany.net\/jason\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}