Skip to content

Instantly share code, notes, and snippets.

@psychemedia
Created April 16, 2019 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psychemedia/5b0dd4119ad4ed6a6d8705eb94e07f19 to your computer and use it in GitHub Desktop.
Save psychemedia/5b0dd4119ad4ed6a6d8705eb94e07f19 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# BBC Programme Info\n",
"\n",
"Throwaway script for grabbing and displaying BBC programme info based on series and programme PIDs."
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Parent name: The Rise of the Robots\n",
"Parent PID: b08fg08m\n",
"Parent link: https://www.bbc.co.uk/programmes/b08fg08m\n",
"Title: Series 1 — \n",
"Channel: BBC Radio 4\n",
"Short synopsis: Adam Rutherford explores the role of robots in science and culture across the ages.\n",
"Medium synopsis: Adam Rutherford explores the role of robots in science and culture across the ages.\n",
"First broadcast date\" 2017-02-07T11:00:00Z\n",
"PID: b08ff40m\n",
"Link: https://www.bbc.co.uk/programmes/b08ff40m\n",
"\n",
"\tTitle: Where is my mind?\n",
"\tShort synopsis: Adam Rutherford asks if we are ready for artificial intelligences making decisions for us.\n",
"\tFirst broadcast date\" 2017-02-21T11:00:00Z\n",
"\tPID: b08ffv2v\n",
"\tLink: https://www.bbc.co.uk/programmes/b08ffv2v\n",
"\n",
"\tTitle: More human than human\n",
"\tShort synopsis: Adam Rutherford explores our relationship with contemporary humanoid robots.\n",
"\tFirst broadcast date\" 2017-02-14T11:00:00Z\n",
"\tPID: b08dnr3r\n",
"\tLink: https://www.bbc.co.uk/programmes/b08dnr3r\n",
"\n",
"\tTitle: The history of things to come\n",
"\tShort synopsis: From the Ancient Greeks to Maria in Metropolis, Adam Rutherford explores robots in culture\n",
"\tFirst broadcast date\" 2017-02-07T11:00:00Z\n",
"\tPID: b08crvz3\n",
"\tLink: https://www.bbc.co.uk/programmes/b08crvz3\n",
"\n",
"\n",
"-------------------\n",
"\n",
"Parent name: The Public Philosopher\n",
"Parent PID: b01nmlh2\n",
"Parent link: https://www.bbc.co.uk/programmes/b01nmlh2\n",
"Title: The Public Philosopher — Would life be better if robots did all the work?\n",
"Channel: BBC Radio 4\n",
"Short synopsis: Harvard philosopher Michael Sandel asks if life would be better if robots did all the work\n",
"Medium synopsis: Eminent Harvard political philosopher Michael Sandel explores the philosophical issues around work in a rapidly automating world in a special edition recorded in Dagenham.\n",
"Long synopsis: Harvard philosopher Michael Sandel asks if life would be better if robots did all the work. Professor Sandel skilfully and entertainingly uses live audiences to help address important ethical and philosophical questions. He has travelled across the world and brought together global audiences for his method of Socratic dialogue. \n",
"\n",
"Michael gathers an audience in a secondary school in Dagenham, East London, to address one of the most pressing issues of our times - the future of work in a world where automation threatens to replace more and more workers with robots. A much-cited Oxford University report predicts that 35% of jobs in the UK are at risk.\n",
"\n",
"There is nowhere better to examine this issue than Dagenham, where once 40,000 people built cars at the famous Ford factory. The plant stopped making cars in 2002 and now makes vast numbers of car engines, but with fewer than 3,000 employees. Barking and Dagenham is judged by the Legatum Institute as the least prosperous borough in London and among the 10 least prosperous in the UK. The unemployment rate is one of the highest in London. As automation moves from the factory floor to the office, Michael Sandel and his audience will try to understand how we regard the ethics surrounding this profound shift.\n",
"\n",
"Producer: Tim Mansel.\n",
"First broadcast date\" 2017-03-07T09:00:00Z\n",
"PID: b08gxndc\n",
"Link: https://www.bbc.co.uk/programmes/b08gxndc\n",
"\n",
"\n",
"-------------------\n",
"\n",
"Parent name: Beyond Belief\n",
"Parent PID: b006s6p6\n",
"Parent link: https://www.bbc.co.uk/programmes/b006s6p6\n",
"Title: Beyond Belief — Artificial Intelligence\n",
"Channel: BBC Radio 4Short synopsis: Shelina Janmohamed discusses the impact of AI on religion.\n",
"Medium synopsis: Shelina Janmohamed discusses the impact of AI on religion.\n",
"Long synopsis: The relationship between religion and science has always been complex. Some see it as a threat, whilst others are inspired by it. The development of Artificial Intelligence has thrown up a number of interesting questions. For instance, in Japan a robot called Pepper delivers Buddhist funeral rites because it’s cheaper and more practical than getting a real priest. In Germany, a robot priest called BlessU2 can deliver blessings in five different languages. But does the use of robots in the ritual and practice of religion change the nature of our relationship with it? Can AI help us to lead better lives?\n",
"\n",
"Joining Shelina Janmohamed to discuss the relationship between artificial intelligence and religion are Dr Paula Boddington, senior Research Fellow at the University of Cardiff; Rabbi Dr Raphael Zarum; Dean of the London School of Jewish Studies and Dr Scott Midson, Postdoctoral Research Associate at the Lincoln Theological Institute, University of Manchester.\n",
"\n",
"Producer: Helen Lee\n",
"First broadcast date\" 2018-11-26T16:30:00Z\n",
"PID: m00019my\n",
"Link: https://www.bbc.co.uk/programmes/m00019my\n",
"\n",
"\n",
"-------------------\n",
"\n",
"Parent name: Science Cafe\n",
"Parent PID: b00848zw\n",
"Parent link: https://www.bbc.co.uk/programmes/b00848zw\n",
"Title: Science Cafe — Artificial Intelligence\n",
"Channel: BBC Radio Wales\n",
"Short synopsis: Adam Walton and guests discuss the latest developments in artificial intelligence.\n",
"Medium synopsis: Adam Walton and guests discuss the latest developments in artificial intelligence including how robots and virtual systems may impact on the future of jobs and education.\n",
"First broadcast date\" 2018-09-04T18:30:00+01:00\n",
"PID: b0bhwp6j\n",
"Link: https://www.bbc.co.uk/programmes/b0bhwp6j\n",
"\n",
"\n",
"-------------------\n",
"\n",
"Parent name: Analysis\n",
"Parent PID: b006r4vz\n",
"Parent link: https://www.bbc.co.uk/programmes/b006r4vz\n",
"Title: Analysis — When Robots Steal Our Jobs\n",
"Channel: BBC Radio 4\n",
"Short synopsis: Technology has decimated manual labour. Now it has its sights on white-collar work.\n",
"Medium synopsis: Technology has been replacing manufacturing jobs for years and now it has white-collar jobs in its sights. David Baker asks what we will do if robots take over the workplace.\n",
"Long synopsis: Technology has been replacing manufacturing jobs for years. Is the same about to happen to white-collar work? Will new faster, smarter computers start destroying more jobs than they create?\n",
"\n",
"Technologists and economists are now arguing that we are approaching a turning point, where professional jobs are becoming automated, leaving less and less work for humans to do. David Baker investigates the evidence and asks what this means for society, the individual and equality.\n",
"Producer: Charlotte McDonald.\n",
"First broadcast date\" 2015-03-02T20:30:00Z\n",
"PID: b0540h85\n",
"Link: https://www.bbc.co.uk/programmes/b0540h85\n",
"\n",
"\n",
"-------------------\n",
"\n",
"Parent name: Analysis\n",
"Parent PID: b006r4vz\n",
"Parent link: https://www.bbc.co.uk/programmes/b006r4vz\n",
"Title: Analysis — Can We Teach Robots Ethics?\n",
"Channel: BBC Radio 4\n",
"Short synopsis: What happens when a machine faces a moral dilemma? David Edmonds investigates.\n",
"Medium synopsis: From driverless cars to 'carebots', machines are entering the realm of right and wrong. David Edmonds explores how the challenges facing AI are not just technical, but moral.\n",
"Long synopsis: From driverless cars to \"carebots\", machines are entering the realm of right and wrong. Should an autonomous vehicle prioritise the lives of its passengers over pedestrians? Should a robot caring for an elderly woman respect her right to life ahead of her right to make her own decisions? And who gets to decide? The challenges facing artificial intelligence are not just technical, but moral - and raise hard questions about what it means to be human.\n",
"\n",
"Presenter: David Edmonds\n",
"Producer: Simon Maybin.\n",
"First broadcast date\" 2017-10-16T20:30:00+01:00\n",
"PID: b098ht04\n",
"Link: https://www.bbc.co.uk/programmes/b098ht04\n",
"\n",
"\n",
"-------------------\n",
"\n",
"Parent name: The Life Scientific\n",
"Parent PID: b015sqc7\n",
"Parent link: https://www.bbc.co.uk/programmes/b015sqc7\n",
"Title: The Life Scientific — Alan Winfield on robot ethics\n",
"Channel: BBC Radio 4\n",
"Short synopsis: Alan Winfield talks to Jim Al-Khalili about the ethics of robots, from drones to androids.\n",
"Medium synopsis: Alan Winfield, Professor of Robot Ethics in Bristol, discusses ethical and unethical robots, and the behaviour of swarms of small biologically inspired robots with Jim Al-Khalili.\n",
"Long synopsis: Alan Winfield is the only Professor of Robot Ethics in the world. He is a voice of reason amid the growing sense of unease at the pace of progress in the field of artificial intelligence. He believes that robots aren't going to take over the world - at least not any time soon. But that doesn't mean we should be complacent.\n",
"\n",
"Alan Winfield talks to Jim al-Khalili about how, at a young age, he delighted in taking things apart. After his degree in microelectronics and a PhD in digital communication at Hull University, he set up a software company in the mid-80s, which he ran for the best part of a decade before returning to academia. In 1993, he co-founded the Bristol Robotics Laboratory at the University of the West of England, by far the largest centre of robotics in the UK. Today, he is a leading authority, not only on robot ethics, but on the idea of swarm robotics and biologically-inspired robotics. Alan explains to Jim that what drives many of his enquiries is the deeply profound question: how can 'stuff' become intelligent.\n",
"First broadcast date\" 2017-02-21T09:00:00Z\n",
"PID: b08ffv2l\n",
"Link: https://www.bbc.co.uk/programmes/b08ffv2l\n",
"\n",
"\n",
"-------------------\n",
"\n"
]
}
],
"source": [
"#http://lists.infradead.org/pipermail/get_iplayer/2017-July/010906.html\n",
"import requests\n",
"\n",
"\n",
"seriesids=['b08ff40m']\n",
"pids = ['b08gxndc','m00019my','b0bhwp6j','b0540h85','b098ht04','b08ffv2l']\n",
"\n",
"t=''\n",
"\n",
" \n",
"def printProg(j, prefix='', t=''):\n",
" \n",
" sbits = {'short_synopsis':'Short', 'medium_synopsis':'Medium', 'long_synopsis':'Long'}\n",
" \n",
" if 'parent' in j:\n",
" t = t+'{}Parent name: {}\\n'.format(prefix,j['parent']['programme']['title'])\n",
" t = t+'{}Parent PID: {}\\n'.format(prefix,j['parent']['programme']['pid'])\n",
" t = t+'{}Parent link: https://www.bbc.co.uk/programmes/{}\\n'.format(prefix,j['parent']['programme']['pid'])\n",
" if 'display_title' in j and 'subtitle' in j['display_title']:\n",
" t = t+ '{}Title: {} — {}\\n'.format(prefix,j['display_title']['title'],j['display_title']['subtitle'])\n",
" else:\n",
" t = t+'{}Title: {}\\n'.format(prefix,j['title'])\n",
" if 'ownership' in j:\n",
" t = t+ '{}Channel: {}\\n'.format(prefix,j['ownership']['service']['title'])\n",
" elif 'parent' in j:\n",
" t = t+ '{}Channel: {}'.format(prefix,j['parent']['programme']['ownership']['service']['title'])\n",
"\n",
" for s in sbits:\n",
" if s in j and j[s]:\n",
" t = t+'{}{} synopsis: {}\\n'.format(prefix, sbits[s],j[s])\n",
" \n",
" t = t+'{}First broadcast date\" {}\\n'.format(prefix,j['first_broadcast_date'])\n",
"\n",
" t = t+'{}PID: {}\\n'.format(prefix,j['pid'])\n",
" t = t+'{}Link: https://www.bbc.co.uk/programmes/{}'.format(prefix,j['pid'])\n",
"\n",
" t=t+'\\n'\n",
" return t\n",
"\n",
"for seriesid in seriesids:\n",
" series_url = 'https://www.bbc.co.uk/programmes/{}.json'.format(seriesid)\n",
" series_data = requests.get( series_url ).json()\n",
" print(printProg(series_data['programme']))\n",
" \n",
" seriesprogrammes_url = \"http://www.bbc.co.uk/programmes/{}/children.json\".format(seriesid)\n",
" seriesprogrammes_data = requests.get( seriesprogrammes_url ).json()\n",
" for programme in seriesprogrammes_data['children']['programmes']:\n",
" print(printProg(programme,'\\t'))\n",
" print('\\n-------------------\\n')\n",
" \n",
"for pid in pids:\n",
" programme_url = 'https://www.bbc.co.uk/programmes/{}.json'.format(pid)\n",
" programme_data = requests.get(programme_url).json()\n",
" print(printProg(programme_data['programme']))\n",
" print('\\n-------------------\\n')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"jupytext": {
"main_language": "python",
"text_representation": {
"extension": ".md",
"format_name": "markdown",
"format_version": "1.0",
"jupytext_version": "0.8.6"
}
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment