{"id":1594,"date":"2010-12-31T20:53:41","date_gmt":"2010-12-31T20:53:41","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=1594"},"modified":"2010-12-31T22:34:16","modified_gmt":"2010-12-31T22:34:16","slug":"an-api-for-twitter-hashtags-for-tv-programmes","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=1594","title":{"rendered":"An API for twitter hashtags for TV programmes"},"content":{"rendered":"<p><strong>Overview<\/strong><br \/>\nHacking together an API that returns commonly-used hashtags for the programme you&#8217;re watching on the TV<\/p>\n<p><strong>Background<\/strong><br \/>\n<a href=\"http:\/\/www.flickr.com\/photos\/dalelane\/4497367013\/\" title=\"tweets on TV by dalelane, on Flickr\"><img loading=\"lazy\" decoding=\"async\" align=\"left\" style=\"border: thin black solid\" hspace=10 vspace=10 src=\"http:\/\/farm3.static.flickr.com\/2759\/4497367013_154f0ebbe0_m.jpg\" width=\"240\" height=\"180\" alt=\"tweets on TV\" \/><\/a>Last April, I wrote a quick-and-dirty <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=1284\">Python script that displays tweets for a given hashtag on my TV screen<\/a> so that I could follow the twitter backchannel about a programme that I watched. <\/p>\n<p>Considering that it was a random idea that was hacked together in a few minutes, I&#8217;ve used it a lot since then: it&#8217;s made watching a bunch of programmes much more entertaining &#8211; Eurovision is probably the best example (the commentary on twitter is hysterical), but there are many others. <\/p>\n<p>But I never made any changes to the script since I first wrote it. If I&#8217;m watching something on TV that I know has a hashtag, I ssh to my set-top box and run my hashtags script, giving it the hashtag to filter on in the command.<\/p>\n<p>I was thinking &#8211; it&#8217;d be much better if it was all automatic. It&#8217;d be better if my set-top box automatically showed tweets with the hashtag for whatever programme I&#8217;m watching. <\/p>\n<p>To do this, I needed some way of knowing what was the right hashtag for the programme currently on a given TV channel. I could&#8217;ve hacked this into my existing script, but I thought it might be a feature that people might find other uses for, so instead I&#8217;ve made a stand-alone thing, available as a web-service. <\/p>\n<p><strong>What it does<\/strong><br \/>\nI&#8217;ve made a web feed that returns a blob of either JSON or XML. You can get either:<\/p>\n<ul>\n<li>the commonly-used hashtag for the programme currently on a specified channel (e.g. &#8220;what is the hashtag for the programme that&#8217;s on BBC 1 now?&#8221;)\n<\/li>\n<li>the next programme on TV that has a commonly-used hashtag (e.g. &#8220;what are the next five programmes on TV that have hashtags?&#8221;)<\/li>\n<\/ul>\n<p><!--more-->I&#8217;ve assumed that discussions on twitter mainly take place the first time that a programme is on, so repeats are generally not included. <\/p>\n<p><strong>How I made it<\/strong><br \/>\nRather than write a bunch of code, I&#8217;ve made it using <a href=\"http:\/\/pipes.yahoo.com\" target=\"_blank\">Yahoo! Pipes<\/a>.  <\/p>\n<p>It&#8217;s a mashup of some <a href=\"http:\/\/www.bbc.co.uk\/programmes\/developers\" target=\"_blank\">BBC Programmes feeds<\/a>, together with a static CSV file I&#8217;ve made that contains a mapping of BBC programme IDs to twitter hashtags. This is a disappointingly manual step &#8211; ideally this would be made in a more dynamic or perhaps crowd-sourced way. But for now, it&#8217;s a CSV file, that I&#8217;m hosting using a public <a href=\"http:\/\/www.dropbox.com\/\" target=\"_blank\">dropbox<\/a> folder.<\/p>\n<p>(<em>As an aside &#8211; it&#8217;d be good to add more to this file. If you can think of any programmes which have common hashtags that I might have missed, please do let me know in the comments.<\/em>)<\/p>\n<p>This does mean that my feed will only work with BBC TV channels. If only other channels put the resources that the BBC do into sharing data and feeds, eh? But for now, it&#8217;s not a major issue for my needs&#8230; to be honest, other than X Factor, I can&#8217;t think of any TV programmes that I follow the twitter back-channel for that isn&#8217;t on a BBC channel.<\/p>\n<p><strong>Where to find it<\/strong><br \/>\n<a href=\"http:\/\/pipes.yahoo.com\/dalelane\/tvhashtagsnow\" target=\"_blank\">hashtags on now<\/a><\/p>\n<p>One required argument :<br \/>\n&#8216;channel&#8217; &#8211; the channel name. This is &#8220;bbcone&#8221;, &#8220;bbctwo&#8221;, &#8220;bbcthree&#8221;, etc.<\/p>\n<p><a href=\"http:\/\/pipes.yahoo.com\/dalelane\/tvhashtagsnext\" target=\"_blank\">hashtags on next<\/a><\/p>\n<p>Two optional filters :<br \/>\n&#8216;limit&#8217; &#8211; how many programmes to return &#8211; e.g. limit==5 shows you the next five programmes that have a known hashtag<br \/>\n&#8216;channel&#8217; &#8211; the name of a channel that you want to see programme(s) for &#8211; e.g. &#8220;bbcone&#8221;, &#8220;bbctwo&#8221;, &#8220;bbcthree&#8221;, etc. <\/p>\n<p>Hope someone finds this useful. It doesn&#8217;t need any authentication, and is just a straight HTTP GET that returns JSON or XML. Hopefully it&#8217;s as simple to use as it was to hack together.<\/p>\n<p>Yahoo! Pipes let you clone other people&#8217;s pipes, which is very cool &#8211; it means that you can take a copy of what I&#8217;ve done, and tweak, extend  and improve it to suit your needs. <\/p>\n<p><strong>Warning<\/strong><\/p>\n<p>I&#8217;ve not done any real testing on these, and this was my first real use of Pipes, so&#8230; use with caution \ud83d\ude42<\/p>\n<p><strong>Some examples<\/strong><\/p>\n<p>hashtags now on BBC 1 &#8211; <code>channel=bbcone&_render=json<\/code><\/p>\n<pre style=\"border: thin solid silver; background-color: #eeeeee; padding: 0.7em; font-size: 1.1em; overflow: auto;\">{\r\n  \"count\": 1,\r\n  \"value\": {\r\n    \"title\": \"TV hashtags - now\",\r\n    \"description\": \"What are the commonly used hashtags on twitter for the BBC TV programme on now?\",\r\n    \"items\": [\r\n      {\r\n        \"hashtag\": \"eastenders\",\r\n\r\n        \"start\": \"2010-12-31T20:00:00Z\",\r\n        \"end\": \"2010-12-31T20:40:00Z\",\r\n        \"duration\": \"2400\",\r\n\r\n        \"programme\": {\r\n          \"programme\": {\r\n            \"title\": \"EastEnders\",\r\n            \"pid\": \"b006m86d\",\r\n            \"type\": \"brand\",\r\n            \"ownership\": {\r\n              \"service\": {\r\n                \"title\": \"BBC One\",\r\n                \"id\": \"bbc_one\",\r\n                \"type\": \"tv\",\r\n                \"key\": \"bbcone\"\r\n              }\r\n            }\r\n          },\r\n          \"display_titles\": {\r\n            \"title\": \"EastEnders\",\r\n            \"subtitle\": \"31\/12\/2010\"\r\n          },\r\n          \"short_synopsis\": \"Ronnie's grief leads to a momentary act of desperation with devastating consequences.\",\r\n          \"pid\": \"b00x2pwx\",\r\n          \"type\": \"episode\",\r\n          \"title\": \"31\/12\/2010\",\r\n          \"ownership\": {\r\n            \"service\": {\r\n              \"title\": \"BBC One\",\r\n              \"id\": \"bbc_one\",\r\n              \"type\": \"tv\",\r\n              \"key\": \"bbcone\"\r\n            }\r\n          }\r\n        },\r\n\r\n        \"src\": \"http:\/\/www.bbc.co.uk\/bbcone\/programmes\/schedules\/london\/today.json\"\r\n      }\r\n    ],\r\n    \"link\": \"http:\/\/pipes.yahoo.com\/pipes\/pipe.info?_id=ef9269bf39bd9d8620356afc3941ee09\",\r\n    \"pubDate\": \"Fri, 31 Dec 2010 20:03:15 +0000\",\r\n    \"generator\": \"http:\/\/pipes.yahoo.com\/pipes\/\"\r\n  }\r\n}<\/pre>\n<p>hashtags on next &#8211; <code>limit=2&_render=json<\/code><\/p>\n<pre style=\"border: thin solid silver; background-color: #eeeeee; padding: 0.7em; font-size: 1.1em; overflow: auto;\">{\r\n    \"count\": 2,\r\n\r\n    \"value\": {\r\n        \"title\": \"TV hashtags - next\",\r\n        \"description\": \"What are the next BBC TV programmes what have commonly used hashtags on twitter?\",\r\n\r\n        \"items\": [\r\n            {\r\n                \"hashtag\": \"eastenders\",\r\n\r\n                \"schedule_date\": \"2010-12-31\",\r\n                \"start\": \"2010-12-31T20:00:00Z\",\r\n                \"end\": \"2010-12-31T20:40:00Z\",\r\n                \"duration\": \"2400\",\r\n\r\n                \"service\": {\r\n                    \"title\": \"BBC One\",\r\n                    \"id\": \"bbc_one\",\r\n                    \"type\": \"tv\",\r\n                    \"key\": \"bbcone\"\r\n                },\r\n\r\n                \"programme\": {\r\n                    \"programme\": {\r\n                        \"title\": \"EastEnders\",\r\n                        \"pid\": \"b006m86d\",\r\n                        \"type\": \"brand\",\r\n                        \"ownership\": {\r\n                            \"service\": {\r\n                                \"title\": \"BBC One\",\r\n                                \"id\": \"bbc_one\",\r\n                                \"type\": \"tv\",\r\n                                \"key\": \"bbcone\"\r\n                            }\r\n                        }\r\n                    },\r\n                    \"display_titles\": {\r\n                        \"title\": \"EastEnders\",\r\n                        \"subtitle\": \"31\/12\/2010\"\r\n                    },\r\n                    \"short_synopsis\": \"Ronnie's grief leads to a momentary act of desperation with devastating consequences.\",\r\n                    \"pid\": \"b00x2pwx\",\r\n                    \"type\": \"episode\",\r\n                    \"title\": \"31\/12\/2010\",\r\n                    \"ownership\": {\r\n                        \"service\": {\r\n                            \"title\": \"BBC One\",\r\n                            \"id\": \"bbc_one\",\r\n                            \"type\": \"tv\",\r\n                            \"key\": \"bbcone\"\r\n                        }\r\n                    }\r\n                },\r\n\r\n                \"src\": \"http:\/\/www.bbc.co.uk\/programmes\/b006m86d\/episodes\/upcoming\/debut.json\"\r\n            },\r\n            {\r\n                \"hashtag\": \"mastermind\",\r\n\r\n                \"schedule_date\": \"2011-01-03\",\r\n                \"start\": \"2011-01-03T20:30:00Z\",\r\n                \"end\": \"2011-01-03T21:00:00Z\",\r\n                \"duration\": \"1800\",\r\n\r\n                \"service\": {\r\n                    \"title\": \"BBC One\",\r\n                    \"id\": \"bbc_one\",\r\n                    \"type\": \"tv\",\r\n                    \"key\": \"bbcone\"\r\n                },\r\n\r\n                \"programme\": {\r\n                    \"programme\": {\r\n                        \"programme\": {\r\n                            \"title\": \"Celebrity Mastermind\",\r\n                            \"pid\": \"b008pc8h\",\r\n                            \"type\": \"brand\",\r\n                            \"ownership\": {\r\n                                \"service\": {\r\n                                    \"title\": \"BBC One\",\r\n                                    \"id\": \"bbc_one\",\r\n                                    \"type\": \"tv\",\r\n                                    \"key\": \"bbcone\"\r\n                                }\r\n                            }\r\n                        },\r\n                        \"pid\": \"b00x864x\",\r\n                        \"title\": \"2010\/2011\",\r\n                        \"type\": \"series\"\r\n                    },\r\n                    \"display_titles\": {\r\n                        \"subtitle\": \"2010\/2011, Episode 6\",\r\n                        \"title\": \"Celebrity Mastermind\"\r\n                    },\r\n                    \"short_synopsis\": \"Guests are Robert Webb, Helen Skelton, Stephen Mangan and Sir Clive Sinclair.\",\r\n                    \"pid\": \"b00xc86z\",\r\n                    \"type\": \"episode\",\r\n                    \"title\": \"Episode 6\",\r\n                    \"ownership\": {\r\n                        \"service\": {\r\n                            \"title\": \"BBC One\",\r\n                            \"id\": \"bbc_one\",\r\n                            \"type\": \"tv\",\r\n                            \"key\": \"bbcone\"\r\n                        }\r\n                    }\r\n                },\r\n\r\n                \"src\": \"http:\/\/www.bbc.co.uk\/programmes\/b008pc8h\/episodes\/upcoming\/debut.json\"\r\n            }\r\n        ],\r\n        \"link\": \"http:\/\/pipes.yahoo.com\/pipes\/pipe.info?_id=614c245ff4100207cd833c31bb7dde50\",\r\n        \"pubDate\": \"Fri, 31 Dec 2010 20:08:16 +0000\",\r\n        \"generator\": \"http:\/\/pipes.yahoo.com\/pipes\/\"\r\n    }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Overview Hacking together an API that returns commonly-used hashtags for the programme you&#8217;re watching on the TV Background Last April, I wrote a quick-and-dirty Python script that displays tweets for a given hashtag on my TV screen so that I could follow the twitter backchannel about a programme that I watched. Considering that it was [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[478,306,398,151,477],"class_list":["post-1594","post","type-post","status-publish","format-standard","hentry","category-code","tag-hashtag","tag-television","tag-tv","tag-twitter","tag-yahoo-pipes"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1594"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1594\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}