{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d62a02e5",
   "metadata": {},
   "outputs": [],
   "source": [
    "from bs4 import BeautifulSoup\n",
    "import feedparser\n",
    "import re\n",
    "import tqdm\n",
    "import os\n",
    "import pandas as pd\n",
    "import sqlite3\n",
    "import time\n",
    "import random\n",
    "import requests\n",
    "import multiprocessing\n",
    "import numpy as np\n",
    "import json\n",
    "import urllib\n",
    "import html\n",
    "from collections import defaultdict\n",
    "\n",
    "from suno_utils.audio import Audio\n",
    "from suno_utils.utils.text import normalize_whitespace\n",
    "from suno_utils.utils.podcasts import load_podcast_db\n",
    "\n",
    "\n",
    "RAW_RSS_DIR = \"/mnt/data-ssd-1/data/podcasts/bulk_rss_feeds/raw_files/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9dc2c520",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a8cc4ac3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "ec79adc1",
   "metadata": {},
   "source": [
    "## Basic set up"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "419f68e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "906592 english anchor podcasts\n"
     ]
    }
   ],
   "source": [
    "main_df = load_podcast_db(\n",
    "    \"/mnt/data-ssd-1/data/podcasts/meta/podcastindex_feeds.db\", english_only=True, anchor_only=True\n",
    ")\n",
    "english_podcast_ids = set(main_df[\"id\"])\n",
    "english_rss_filenames = [fn for fn in os.listdir(RAW_RSS_DIR) if int(fn.split(\".\")[0]) in english_podcast_ids]\n",
    "print(len(english_rss_filenames), \"english anchor podcasts\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9a7410f4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7c044ead",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "34a42247",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c2117602",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "6981dfb9",
   "metadata": {},
   "source": [
    "## get countries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1d789d28",
   "metadata": {},
   "outputs": [],
   "source": [
    "def _decode_rss_bytes(rss_bytes, force_decode=True):\n",
    "    rss_text = str(rss_bytes)[2:-1]\n",
    "    m = re.search(r\"encoding\\=[\\'\\\"\\\\]+(.+?)[\\'\\\"\\\\]+\", rss_text)\n",
    "    if m:\n",
    "        try:\n",
    "            return rss_bytes.decode(m.group(1))\n",
    "        except:\n",
    "            pass\n",
    "    try:\n",
    "        return rss_bytes.decode(\"utf-8\")\n",
    "    except:\n",
    "        pass\n",
    "    return rss_text if force_decode else None\n",
    "\n",
    "\n",
    "def _rss_tag_clean(text, keep_html=False):\n",
    "    text = text.strip()\n",
    "    if keep_html or len(text) < 5 or text[0] != \"<\":\n",
    "        text = html.unescape(text)\n",
    "    else:\n",
    "        text = BeautifulSoup(text).text\n",
    "    text = re.sub(r\"^[\\s\\<\\!\\[]+CDATA[\\s\\[]+\", \"\", text)\n",
    "    text = re.sub(r\"[\\s\\]\\>]+$\", \"\", text)\n",
    "    return normalize_whitespace(text)\n",
    "\n",
    "\n",
    "ALLOWED_AUDIO_EXTENSIONS = set([\"mp3\", \"m4a\", \"wav\", \"wma\", \"ogg\", \"wmv\"])\n",
    "\n",
    "\n",
    "def _get_url_file_ext(url):\n",
    "    return url.lower().split(\".\")[-1].split(\"?\")[0]\n",
    "\n",
    "\n",
    "ANCHOR_LINK_PTN = re.compile(r\"^https\\:\\/\\/anchor\\.fm\\/.+?(https\\%3A\\%2F\\%2F)\")\n",
    "\n",
    "\n",
    "def _clean_episode_url(url):\n",
    "    url_components = [c for c in re.split(r\"(https?\\:\\/\\/)\", url) if len(c) > 0]\n",
    "    url = \"\".join(url_components[-2:])\n",
    "    if ANCHOR_LINK_PTN.search(url):\n",
    "        url = urllib.parse.unquote(ANCHOR_LINK_PTN.sub(\"\\\\1\", url))\n",
    "    return url\n",
    "\n",
    "\n",
    "def _check_url_active(url):\n",
    "    b_exists = False\n",
    "    try:\n",
    "        response = requests.head(url, timeout=2)\n",
    "        if response.status_code < 400:\n",
    "            b_exists = True\n",
    "    except:\n",
    "        pass\n",
    "    return b_exists\n",
    "\n",
    "\n",
    "def load_rss_text(filepath, force_decode=True):\n",
    "    with open(filepath, \"rb\") as f:\n",
    "        rss_bytes = f.read()\n",
    "    return _decode_rss_bytes(rss_bytes, force_decode=force_decode)\n",
    "\n",
    "\n",
    "def load_rss_feed(filepath):\n",
    "    with open(filepath, \"rb\") as f:\n",
    "        rss_bytes = f.read()\n",
    "    return feedparser.parse(rss_bytes)\n",
    "\n",
    "\n",
    "def get_rss_tag(tagname, rss_text):\n",
    "    m = re.search(tagname + r\"\\>(.+?)\\<\\/\" + tagname, rss_text, flags=re.DOTALL)\n",
    "    if m:\n",
    "        return _rss_tag_clean(m.group(1))\n",
    "    return \"\"\n",
    "\n",
    "\n",
    "def get_latest_episode_url(feed):\n",
    "    if len(feed[\"entries\"]) < 3:\n",
    "        return None\n",
    "    latest_episode = feed[\"entries\"][0]\n",
    "    episode_urls = [\n",
    "        _clean_episode_url(e[\"href\"])\n",
    "        for e in latest_episode.get(\"links\", []) \n",
    "        if (\n",
    "            \"audio\" in e.get(\"type\", \"\") and \n",
    "            \"href\" in e\n",
    "        )\n",
    "    ]\n",
    "    episode_urls = [e for e in episode_urls if _get_url_file_ext(e) in ALLOWED_AUDIO_EXTENSIONS]\n",
    "    episode_urls = [e for e in episode_urls if _check_url_active(e)]\n",
    "    if len(episode_urls) == 0:\n",
    "        return None\n",
    "    return episode_urls[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cf4f7c7b",
   "metadata": {},
   "outputs": [],
   "source": [
    "BLOCKLIST = set([\"AND\", \"EST\", \"Jersey\"])\n",
    "\n",
    "def _is_valid_country_term(s):\n",
    "    if len(s) <= 2 or len(s) > 50 or s in BLOCKLIST:\n",
    "        return False\n",
    "    if len(s) <= 3 and not s.isupper():\n",
    "        return False\n",
    "    if not s[0].isupper():\n",
    "        return False\n",
    "    return True\n",
    "\n",
    "def _simplify_country_term(s):\n",
    "    s = s.strip()\n",
    "#     s = s[:1].upper() + s[1:]\n",
    "#     if len(s) <= 3:\n",
    "#         s = s.upper()\n",
    "    return s\n",
    "\n",
    "aliases_df = pd.read_json(\"meta_data/country_aliases.json\")\n",
    "aliases_df[\"entity_id\"] = aliases_df[\"entity_id\"].str.split(\"/\").str[-1]\n",
    "\n",
    "demonyms_df = pd.read_json(\"meta_data/demonyms.json\")\n",
    "demonyms_df[\"entity_id\"] = demonyms_df[\"entity_id\"].str.split(\"/\").str[-1]\n",
    "\n",
    "country_alias_map = defaultdict(set)\n",
    "country_name_map = {}\n",
    "for _, row in aliases_df.iterrows():\n",
    "    s = _simplify_country_term(row[\"country_name\"])\n",
    "    if _is_valid_country_term(s):\n",
    "        country_name_map[row[\"entity_id\"]] = s\n",
    "        country_alias_map[row[\"entity_id\"]].add(s)\n",
    "    s = _simplify_country_term(row[\"country_name_alias\"])\n",
    "    if _is_valid_country_term(s):\n",
    "        country_alias_map[row[\"entity_id\"]].add(s)\n",
    "for _, row in demonyms_df.iterrows():\n",
    "    s = row[\"demonym\"]\n",
    "    if _is_valid_country_term(s):\n",
    "        country_alias_map[row[\"entity_id\"]].add(_simplify_country_term(s))\n",
    "\n",
    "inv_country_alias_map = defaultdict(set)\n",
    "for k, v in country_alias_map.items():\n",
    "    for vv in v:\n",
    "        inv_country_alias_map[vv].add(k)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c32ab530",
   "metadata": {},
   "outputs": [],
   "source": [
    "SORTED_SEARCH_TERMS = sorted(list(inv_country_alias_map.keys()), key=len, reverse=True)\n",
    "\n",
    "SEARCH_PTN = re.compile(\n",
    "    r\"\\b({})\\b\".format(r\"|\".join([re.escape(s) for s in SORTED_SEARCH_TERMS])), \n",
    ")\n",
    "\n",
    "def _search_podcast(filename):\n",
    "    rss_text = load_rss_text(RAW_RSS_DIR + filename)\n",
    "    podcast_title = get_rss_tag(\"title\", rss_text)\n",
    "    podcast_description = get_rss_tag(\"description\", rss_text)\n",
    "    search_text = podcast_title + \" \" + podcast_description\n",
    "    terms_found = set(SEARCH_PTN.findall(search_text))\n",
    "    # TODO: if we match multiple countries we punt but could be mistake\n",
    "    countries_found = []\n",
    "    for s in terms_found:\n",
    "        for c in inv_country_alias_map[s]:\n",
    "            countries_found.append(country_name_map[c])\n",
    "    countries_found = sorted(set(countries_found))\n",
    "    if len(countries_found) != 1:\n",
    "        return None\n",
    "    country_found = countries_found[0]\n",
    "    rss_feed = load_rss_feed(RAW_RSS_DIR + filename)\n",
    "    episode_url = get_latest_episode_url(rss_feed)\n",
    "    if episode_url is None:\n",
    "        return None\n",
    "    author_detail = rss_feed[\"feed\"].get(\"publisher_detail\", {})\n",
    "    author_name = author_detail.get(\"name\")\n",
    "    author_email = author_detail.get(\"email\")\n",
    "    if author_email is None:\n",
    "        return None\n",
    "    tags = set([e[\"term\"].lower() for e in rss_feed[\"feed\"].get(\"tags\", [])])\n",
    "    if \"music\" in tags:\n",
    "        return None\n",
    "    tag_str = \";\".join(sorted(tags))\n",
    "    podcast_id = int(filename.split(\".\")[0])\n",
    "    evidence = \";\".join(terms_found)\n",
    "    return (\n",
    "        podcast_id, podcast_title, podcast_description, country_found, evidence, episode_url, \n",
    "        tag_str, author_name, author_email,\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ed9322c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# results = []\n",
    "# for filename in english_rss_filenames:\n",
    "#     out = _search_podcast(filename)\n",
    "#     if out is not None:\n",
    "#         results.append(out)\n",
    "#     if len(results) >= 10:\n",
    "#         break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "6b08b58b",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "25086 podcasts found\n"
     ]
    }
   ],
   "source": [
    "p = multiprocessing.Pool(20)\n",
    "out = p.map(_search_podcast, english_rss_filenames)\n",
    "episode_infos = [e for e in out if e is not None]\n",
    "p.close()\n",
    "p.join()\n",
    "print(len(episode_infos), \"podcasts found\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "49225956",
   "metadata": {},
   "outputs": [],
   "source": [
    "country_podcasts_df = pd.DataFrame(episode_infos, columns=[\n",
    "    \"id\", \"title\", \"description\", \"country\", \"evidence_terms\", \"latest_episode_url\", \n",
    "    \"tags\", \"author_name\", \"author_email\",\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "7a07bda4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# country_podcasts_df[\"country\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "f6a3cd9f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# explore data\n",
    "_df = main_df.set_index(\"id\")\n",
    "country_podcasts_df[\"n_episodes\"] = country_podcasts_df[\"id\"].map(_df[\"episodeCount\"])\n",
    "country_podcasts_df[\"rss_url\"] = country_podcasts_df[\"id\"].map(_df[\"url\"])\n",
    "country_podcasts_df[\"url\"] = country_podcasts_df[\"id\"].map(_df[\"link\"])\n",
    "country_podcasts_df[\"last_updated\"] = country_podcasts_df[\"id\"].map(_df[\"lastUpdate\"])\n",
    "country_podcasts_df.to_csv(\"country_podcasts.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "988a0a04",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# for k, v in country_podcasts_df[\"country\"].value_counts().items():\n",
    "#     if v < 10:\n",
    "#         break\n",
    "#     print(k + \" \" * (50 - len(k) - len(str(v))) + str(v))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "054b8e00",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d337b313",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "38abbaa1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "2a8de960",
   "metadata": {},
   "source": [
    "## Plot data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0c98d830",
   "metadata": {},
   "outputs": [],
   "source": [
    "# country heatmap: https://medium.com/analytics-vidhya/plotly-for-geomaps-bb75d1de189f\n",
    "# https://plotly.com/python-api-reference/generated/plotly.express.scatter_geo\n",
    "import plotly.graph_objects as go\n",
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "701bdbb5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>n_podcasts</th>\n",
       "      <th>country_iso</th>\n",
       "      <th>frac</th>\n",
       "      <th>n_hours_tot</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>United States of America</td>\n",
       "      <td>6998</td>\n",
       "      <td>USA</td>\n",
       "      <td>0.278960</td>\n",
       "      <td>1.322705e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Canada</td>\n",
       "      <td>1765</td>\n",
       "      <td>CAN</td>\n",
       "      <td>0.070358</td>\n",
       "      <td>3.336060e+06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    country  n_podcasts country_iso      frac   n_hours_tot\n",
       "0  United States of America        6998         USA  0.278960  1.322705e+07\n",
       "1                    Canada        1765         CAN  0.070358  3.336060e+06"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "country_podcasts_df = pd.read_csv(\"country_podcasts.csv\")\n",
    "\n",
    "countries_df = pd.read_json(\"meta_data/country_aliases.json\")\n",
    "name2iso = (\n",
    "    countries_df.drop_duplicates(subset=[\"country_name\"], keep=\"first\")\n",
    "    .set_index(\"country_name\")[\"country_iso\"].to_dict()\n",
    ")\n",
    "\n",
    "plot_df = country_podcasts_df[\"country\"].value_counts().to_frame(\"n_podcasts\")\n",
    "plot_df = plot_df.rename_axis(\"country\").reset_index()\n",
    "plot_df[\"country_iso\"] = plot_df[\"country\"].map(name2iso)\n",
    "plot_df = plot_df.dropna().reset_index(drop=True)\n",
    "en_tot_podcasts = 2_155_251\n",
    "avg_hours = 22\n",
    "plot_df[\"frac\"] = plot_df[\"n_podcasts\"] / plot_df[\"n_podcasts\"].sum()\n",
    "plot_df[\"n_hours_tot\"] = plot_df[\"frac\"] * en_tot_podcasts * avg_hours\n",
    "plot_df.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "c38a850d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "autocolorscale": false,
         "colorbar": {
          "tickmode": "array",
          "ticktext": [
           "10k",
           "100k",
           "1M",
           "10M"
          ],
          "tickvals": [
           9.210340371976184,
           11.512925464970229,
           13.815510557964274,
           16.11809565095832
          ],
          "title": {
           "text": "hours"
          }
         },
         "colorscale": [
          [
           0,
           "#00224e"
          ],
          [
           0.1111111111111111,
           "#123570"
          ],
          [
           0.2222222222222222,
           "#3b496c"
          ],
          [
           0.3333333333333333,
           "#575d6d"
          ],
          [
           0.4444444444444444,
           "#707173"
          ],
          [
           0.5555555555555556,
           "#8a8678"
          ],
          [
           0.6666666666666666,
           "#a59c74"
          ],
          [
           0.7777777777777778,
           "#c3b369"
          ],
          [
           0.8888888888888888,
           "#e1cc55"
          ],
          [
           1,
           "#fee838"
          ]
         ],
         "locationmode": "ISO-3",
         "locations": [
          "USA",
          "CAN",
          "IND",
          "AUS",
          "JOR",
          "NGA",
          "IRL",
          "PHL",
          "GBR",
          "JPN",
          "ISL",
          "GEO",
          "ESP",
          "CHN",
          "FRA",
          "SGP",
          "ZAF",
          "KEN",
          "MEX",
          "IDN",
          "DEU",
          "MYS",
          "NZL",
          "GRC",
          "JAM",
          "TCD",
          "ISR",
          "ITA",
          "COM",
          "THA",
          "BRA",
          "DNK",
          "GHA",
          "FIN",
          "VNM",
          "RUS",
          "PAK",
          "ZWE",
          "PRT",
          "UGA",
          "EGY",
          "SWE",
          "HKG",
          "IRN",
          "IMN",
          "CHE",
          "HTI",
          "NLD",
          "TWN",
          "ZMB",
          "MUS",
          "ARE",
          "TUR",
          "NPL",
          "POL",
          "PRI",
          "NOR",
          "MDG",
          "CHL",
          "LKA",
          "ETH",
          "COL",
          "GUY",
          "CRI",
          "CUB",
          "LBN",
          "SOM",
          "MMR",
          "AUT",
          "PER",
          "MNG",
          "CMR",
          "KOR",
          "IRQ",
          "SLV",
          "REU",
          "BHS",
          "MWI",
          "AFG",
          "BGD",
          "ARG",
          "CAF",
          "UKR",
          "COD",
          "BRB",
          "SUN",
          "MAR",
          "TTO",
          "ECU",
          "TZA",
          "BEL",
          "BLZ",
          "PAN",
          "GUM",
          "BEN",
          "LUX",
          "GTM",
          "CZE",
          "SLE",
          "VEN",
          "SSD",
          "ARM",
          "FJI",
          "KHM",
          "BMU",
          "MLT",
          "RWA",
          "ASM",
          "SLB",
          "DMA",
          "QAT",
          "MCO",
          "PNG",
          "HUN",
          "OMN",
          "NAM",
          "BWA",
          "HRV",
          "DZA",
          "SAU",
          "NIC",
          "GIN",
          "BIH",
          "EST",
          "BGR",
          "MLI",
          "LSO",
          "VUT",
          "SVN",
          "MID",
          "WSM",
          "ROU",
          "LIE",
          "MDV",
          "BTN",
          "SVK",
          "GGY",
          "GAB",
          "CYP",
          "ERI",
          "ATG",
          "FSM",
          "GNB",
          "AGO",
          "VCT",
          "BHR",
          "TLS",
          "TON",
          "BRN",
          "GMB",
          "GIB",
          "KAZ",
          "HND",
          "SDN",
          "SYR",
          "VAT",
          "PRK",
          "TCA",
          "CYM",
          "SRB",
          "VGB",
          "TUN",
          "SMR",
          "MRT",
          "ALB",
          "MNE",
          "YEM",
          "GRD",
          "BOL",
          "CUW",
          "LTU",
          "ABW",
          "CSK",
          "KWT",
          "DOM",
          "PLW",
          "LBY",
          "DJI",
          "LBR",
          "SGS",
          "MKD",
          "SEN",
          "MDA",
          "KNA",
          "STP",
          "URY",
          "VIR",
          "NER",
          "CIV",
          "MOZ",
          "BFA",
          "LVA",
          "MAF",
          "PRY",
          "MHL",
          "MTQ",
          "GRL",
          "PSE",
          "TGO",
          "UZB",
          "XKS",
          "AZE",
          "LCA",
          "MAC",
          "MNP",
          "BLR",
          "DDR",
          "NCL",
          "AND",
          "ATA",
          "SWZ",
          "TUV",
          "SUR",
          "SYC",
          "AIA",
          "COK",
          "SXM",
          "MSR",
          "FRO",
          "COG",
          "GLP",
          "TKM",
          "NIU",
          "YUG",
          "GUF",
          "CPV",
          "BDI"
         ],
         "reversescale": false,
         "type": "choropleth",
         "z": [
          16.39777467375669,
          15.020300970196454,
          14.996797452052695,
          14.627782848454352,
          14.225249679619271,
          14.146982893018393,
          14.136068732837714,
          14.082534824596726,
          14.04418204148491,
          13.711911491717398,
          13.666887810343443,
          13.523280765730178,
          13.500232370293887,
          13.364477931181417,
          13.318946546373464,
          13.164795866546207,
          13.164795866546207,
          13.153866796014016,
          13.124124826815278,
          13.061847897293763,
          13.049726536761419,
          13.020858552760567,
          12.96934501831046,
          12.964930000101342,
          12.960495403033477,
          12.847699908888131,
          12.817394559392802,
          12.812253159892384,
          12.619568816062884,
          12.548341306774516,
          12.404207405190729,
          12.372708738131358,
          12.289327129192307,
          12.207834094941123,
          12.159515517670316,
          11.998742297082565,
          11.987046257319372,
          11.97521179967237,
          11.901103827518648,
          11.901103827518648,
          11.875128341115387,
          11.834854441977447,
          11.807074877870372,
          11.778501505426316,
          11.778501505426316,
          11.703278084188728,
          11.671529385874148,
          11.621932444734776,
          11.604838011375476,
          11.604838011375476,
          11.569746691564205,
          11.569746691564205,
          11.569746691564205,
          11.551728186061528,
          11.514686914381178,
          11.495638719410483,
          11.476220633553382,
          11.415596011736946,
          11.394542602539115,
          11.37303639731815,
          11.328584634747317,
          11.328584634747317,
          11.30559511652262,
          11.207956646958703,
          11.09974306231847,
          11.040902562295537,
          11.010130903628783,
          11.010130903628783,
          11.010130903628783,
          10.978382205314203,
          10.978382205314203,
          10.91169083081553,
          10.87659951100426,
          10.87659951100426,
          10.840231866833385,
          10.840231866833385,
          10.802491538850537,
          10.763270825697257,
          10.763270825697257,
          10.763270825697257,
          10.722448831177001,
          10.679889216758205,
          10.635437454187372,
          10.635437454187372,
          10.635437454187372,
          10.58891743855248,
          10.58891743855248,
          10.540127274383048,
          10.488833979995496,
          10.488833979995496,
          10.488833979995496,
          10.488833979995496,
          10.488833979995496,
          10.434766758725221,
          10.377608344885273,
          10.377608344885273,
          10.377608344885273,
          10.377608344885273,
          10.377608344885273,
          10.316983723068837,
          10.316983723068837,
          10.316983723068837,
          10.316983723068837,
          10.316983723068837,
          10.316983723068837,
          10.252445201931266,
          10.252445201931266,
          10.252445201931266,
          10.252445201931266,
          10.183452330444315,
          10.183452330444315,
          10.183452330444315,
          10.109344358290594,
          10.109344358290594,
          10.109344358290594,
          10.109344358290594,
          10.029301650617057,
          10.029301650617057,
          10.029301650617057,
          10.029301650617057,
          10.029301650617057,
          9.942290273627426,
          9.942290273627426,
          9.942290273627426,
          9.942290273627426,
          9.942290273627426,
          9.942290273627426,
          9.846980093823102,
          9.846980093823102,
          9.846980093823102,
          9.846980093823102,
          9.846980093823102,
          9.846980093823102,
          9.846980093823102,
          9.741619578165276,
          9.741619578165276,
          9.623836542508892,
          9.623836542508892,
          9.623836542508892,
          9.623836542508892,
          9.623836542508892,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.49030514988437,
          9.336154470057112,
          9.336154470057112,
          9.336154470057112,
          9.336154470057112,
          9.336154470057112,
          9.336154470057112,
          9.336154470057112,
          9.336154470057112,
          9.336154470057112,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          9.153832913263157,
          8.930689361948946,
          8.930689361948946,
          8.930689361948946,
          8.930689361948946,
          8.930689361948946,
          8.930689361948946,
          8.930689361948946,
          8.930689361948946,
          8.930689361948946,
          8.643007289497167,
          8.643007289497167,
          8.643007289497167,
          8.643007289497167,
          8.643007289497167,
          8.643007289497167,
          8.643007289497167,
          8.643007289497167,
          8.643007289497167,
          8.643007289497167,
          8.643007289497167,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          8.237542181389001,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057,
          7.544395000829057
         ]
        }
       ],
       "layout": {
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "title": {
         "text": "Global \"English\" Podcast Distribution",
         "x": 0.5
        }
       }
      },
      "text/html": [
       "<div>                            <div id=\"0dc1a2de-f9d8-4e60-9b37-8ecca97b6e5b\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                require([\"plotly\"], function(Plotly) {                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"0dc1a2de-f9d8-4e60-9b37-8ecca97b6e5b\")) {                    Plotly.newPlot(                        \"0dc1a2de-f9d8-4e60-9b37-8ecca97b6e5b\",                        [{\"autocolorscale\":false,\"colorscale\":[[0.0,\"#00224e\"],[0.1111111111111111,\"#123570\"],[0.2222222222222222,\"#3b496c\"],[0.3333333333333333,\"#575d6d\"],[0.4444444444444444,\"#707173\"],[0.5555555555555556,\"#8a8678\"],[0.6666666666666666,\"#a59c74\"],[0.7777777777777778,\"#c3b369\"],[0.8888888888888888,\"#e1cc55\"],[1.0,\"#fee838\"]],\"locationmode\":\"ISO-3\",\"locations\":[\"USA\",\"CAN\",\"IND\",\"AUS\",\"JOR\",\"NGA\",\"IRL\",\"PHL\",\"GBR\",\"JPN\",\"ISL\",\"GEO\",\"ESP\",\"CHN\",\"FRA\",\"SGP\",\"ZAF\",\"KEN\",\"MEX\",\"IDN\",\"DEU\",\"MYS\",\"NZL\",\"GRC\",\"JAM\",\"TCD\",\"ISR\",\"ITA\",\"COM\",\"THA\",\"BRA\",\"DNK\",\"GHA\",\"FIN\",\"VNM\",\"RUS\",\"PAK\",\"ZWE\",\"PRT\",\"UGA\",\"EGY\",\"SWE\",\"HKG\",\"IRN\",\"IMN\",\"CHE\",\"HTI\",\"NLD\",\"TWN\",\"ZMB\",\"MUS\",\"ARE\",\"TUR\",\"NPL\",\"POL\",\"PRI\",\"NOR\",\"MDG\",\"CHL\",\"LKA\",\"ETH\",\"COL\",\"GUY\",\"CRI\",\"CUB\",\"LBN\",\"SOM\",\"MMR\",\"AUT\",\"PER\",\"MNG\",\"CMR\",\"KOR\",\"IRQ\",\"SLV\",\"REU\",\"BHS\",\"MWI\",\"AFG\",\"BGD\",\"ARG\",\"CAF\",\"UKR\",\"COD\",\"BRB\",\"SUN\",\"MAR\",\"TTO\",\"ECU\",\"TZA\",\"BEL\",\"BLZ\",\"PAN\",\"GUM\",\"BEN\",\"LUX\",\"GTM\",\"CZE\",\"SLE\",\"VEN\",\"SSD\",\"ARM\",\"FJI\",\"KHM\",\"BMU\",\"MLT\",\"RWA\",\"ASM\",\"SLB\",\"DMA\",\"QAT\",\"MCO\",\"PNG\",\"HUN\",\"OMN\",\"NAM\",\"BWA\",\"HRV\",\"DZA\",\"SAU\",\"NIC\",\"GIN\",\"BIH\",\"EST\",\"BGR\",\"MLI\",\"LSO\",\"VUT\",\"SVN\",\"MID\",\"WSM\",\"ROU\",\"LIE\",\"MDV\",\"BTN\",\"SVK\",\"GGY\",\"GAB\",\"CYP\",\"ERI\",\"ATG\",\"FSM\",\"GNB\",\"AGO\",\"VCT\",\"BHR\",\"TLS\",\"TON\",\"BRN\",\"GMB\",\"GIB\",\"KAZ\",\"HND\",\"SDN\",\"SYR\",\"VAT\",\"PRK\",\"TCA\",\"CYM\",\"SRB\",\"VGB\",\"TUN\",\"SMR\",\"MRT\",\"ALB\",\"MNE\",\"YEM\",\"GRD\",\"BOL\",\"CUW\",\"LTU\",\"ABW\",\"CSK\",\"KWT\",\"DOM\",\"PLW\",\"LBY\",\"DJI\",\"LBR\",\"SGS\",\"MKD\",\"SEN\",\"MDA\",\"KNA\",\"STP\",\"URY\",\"VIR\",\"NER\",\"CIV\",\"MOZ\",\"BFA\",\"LVA\",\"MAF\",\"PRY\",\"MHL\",\"MTQ\",\"GRL\",\"PSE\",\"TGO\",\"UZB\",\"XKS\",\"AZE\",\"LCA\",\"MAC\",\"MNP\",\"BLR\",\"DDR\",\"NCL\",\"AND\",\"ATA\",\"SWZ\",\"TUV\",\"SUR\",\"SYC\",\"AIA\",\"COK\",\"SXM\",\"MSR\",\"FRO\",\"COG\",\"GLP\",\"TKM\",\"NIU\",\"YUG\",\"GUF\",\"CPV\",\"BDI\"],\"reversescale\":false,\"z\":[16.39777467375669,15.020300970196454,14.996797452052695,14.627782848454352,14.225249679619271,14.146982893018393,14.136068732837714,14.082534824596726,14.04418204148491,13.711911491717398,13.666887810343443,13.523280765730178,13.500232370293887,13.364477931181417,13.318946546373464,13.164795866546207,13.164795866546207,13.153866796014016,13.124124826815278,13.061847897293763,13.049726536761419,13.020858552760567,12.96934501831046,12.964930000101342,12.960495403033477,12.847699908888131,12.817394559392802,12.812253159892384,12.619568816062884,12.548341306774516,12.404207405190729,12.372708738131358,12.289327129192307,12.207834094941123,12.159515517670316,11.998742297082565,11.987046257319372,11.97521179967237,11.901103827518648,11.901103827518648,11.875128341115387,11.834854441977447,11.807074877870372,11.778501505426316,11.778501505426316,11.703278084188728,11.671529385874148,11.621932444734776,11.604838011375476,11.604838011375476,11.569746691564205,11.569746691564205,11.569746691564205,11.551728186061528,11.514686914381178,11.495638719410483,11.476220633553382,11.415596011736946,11.394542602539115,11.37303639731815,11.328584634747317,11.328584634747317,11.30559511652262,11.207956646958703,11.09974306231847,11.040902562295537,11.010130903628783,11.010130903628783,11.010130903628783,10.978382205314203,10.978382205314203,10.91169083081553,10.87659951100426,10.87659951100426,10.840231866833385,10.840231866833385,10.802491538850537,10.763270825697257,10.763270825697257,10.763270825697257,10.722448831177001,10.679889216758205,10.635437454187372,10.635437454187372,10.635437454187372,10.58891743855248,10.58891743855248,10.540127274383048,10.488833979995496,10.488833979995496,10.488833979995496,10.488833979995496,10.488833979995496,10.434766758725221,10.377608344885273,10.377608344885273,10.377608344885273,10.377608344885273,10.377608344885273,10.316983723068837,10.316983723068837,10.316983723068837,10.316983723068837,10.316983723068837,10.316983723068837,10.252445201931266,10.252445201931266,10.252445201931266,10.252445201931266,10.183452330444315,10.183452330444315,10.183452330444315,10.109344358290594,10.109344358290594,10.109344358290594,10.109344358290594,10.029301650617057,10.029301650617057,10.029301650617057,10.029301650617057,10.029301650617057,9.942290273627426,9.942290273627426,9.942290273627426,9.942290273627426,9.942290273627426,9.942290273627426,9.846980093823102,9.846980093823102,9.846980093823102,9.846980093823102,9.846980093823102,9.846980093823102,9.846980093823102,9.741619578165276,9.741619578165276,9.623836542508892,9.623836542508892,9.623836542508892,9.623836542508892,9.623836542508892,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.49030514988437,9.336154470057112,9.336154470057112,9.336154470057112,9.336154470057112,9.336154470057112,9.336154470057112,9.336154470057112,9.336154470057112,9.336154470057112,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,9.153832913263157,8.930689361948946,8.930689361948946,8.930689361948946,8.930689361948946,8.930689361948946,8.930689361948946,8.930689361948946,8.930689361948946,8.930689361948946,8.643007289497167,8.643007289497167,8.643007289497167,8.643007289497167,8.643007289497167,8.643007289497167,8.643007289497167,8.643007289497167,8.643007289497167,8.643007289497167,8.643007289497167,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,8.237542181389001,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057,7.544395000829057],\"type\":\"choropleth\",\"colorbar\":{\"tickmode\":\"array\",\"ticktext\":[\"10k\",\"100k\",\"1M\",\"10M\"],\"tickvals\":[9.210340371976184,11.512925464970229,13.815510557964274,16.11809565095832],\"title\":{\"text\":\"hours\"}}}],                        {\"template\":{\"data\":{\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"choropleth\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"choropleth\"}],\"contour\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"contour\"}],\"contourcarpet\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"contourcarpet\"}],\"heatmap\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"heatmap\"}],\"heatmapgl\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"heatmapgl\"}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"histogram2d\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"histogram2d\"}],\"histogram2dcontour\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"histogram2dcontour\"}],\"mesh3d\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"mesh3d\"}],\"parcoords\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"parcoords\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}],\"scatter\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatter\"}],\"scatter3d\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatter3d\"}],\"scattercarpet\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattercarpet\"}],\"scattergeo\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattergeo\"}],\"scattergl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattergl\"}],\"scattermapbox\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattermapbox\"}],\"scatterpolar\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterpolar\"}],\"scatterpolargl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterpolargl\"}],\"scatterternary\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterternary\"}],\"surface\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"surface\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}]},\"layout\":{\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"autotypenumbers\":\"strict\",\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"geo\":{\"bgcolor\":\"white\",\"lakecolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"showlakes\":true,\"showland\":true,\"subunitcolor\":\"white\"},\"hoverlabel\":{\"align\":\"left\"},\"hovermode\":\"closest\",\"mapbox\":{\"style\":\"light\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"bgcolor\":\"#E5ECF6\",\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"ternary\":{\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"bgcolor\":\"#E5ECF6\",\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"title\":{\"x\":0.05},\"xaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"zerolinewidth\":2},\"yaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"zerolinewidth\":2}}},\"title\":{\"text\":\"Global \\\"English\\\" Podcast Distribution\",\"x\":0.5}},                        {\"responsive\": true}                    ).then(function(){\n",
       "                            \n",
       "var gd = document.getElementById('0dc1a2de-f9d8-4e60-9b37-8ecca97b6e5b');\n",
       "var x = new MutationObserver(function (mutations, observer) {{\n",
       "        var display = window.getComputedStyle(gd).display;\n",
       "        if (!display || display === 'none') {{\n",
       "            console.log([gd, 'removed!']);\n",
       "            Plotly.purge(gd);\n",
       "            observer.disconnect();\n",
       "        }}\n",
       "}});\n",
       "\n",
       "// Listen for the removal of the full notebook cells\n",
       "var notebookContainer = gd.closest('#notebook-container');\n",
       "if (notebookContainer) {{\n",
       "    x.observe(notebookContainer, {childList: true});\n",
       "}}\n",
       "\n",
       "// Listen for the clearing of the current output cell\n",
       "var outputEl = gd.closest('.output');\n",
       "if (outputEl) {{\n",
       "    x.observe(outputEl, {childList: true});\n",
       "}}\n",
       "\n",
       "                        })                };                });            </script>        </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = go.Figure(\n",
    "        data=go.Choropleth(\n",
    "        locations=plot_df[\"country_iso\"],\n",
    "        z=np.log(plot_df[\"n_hours_tot\"]),\n",
    "        locationmode=\"ISO-3\",\n",
    "        colorscale=\"cividis\",\n",
    "        autocolorscale=False,\n",
    "        reversescale=False,\n",
    "    )\n",
    ")\n",
    "fig.update_layout(\n",
    "    title={\n",
    "        \"text\": \"Global \\\"English\\\" Podcast Distribution\",\n",
    "        \"x\": 0.5,\n",
    "    },\n",
    ")\n",
    "fig.data[0].colorbar={\n",
    "    \"title\": \"hours\",\n",
    "    \"tickmode\": \"array\",\n",
    "    \"tickvals\": [np.log(10_000), np.log(100_000), np.log(1_000_000), np.log(10_000_000)],\n",
    "    \"ticktext\": [\"10k\", \"100k\", \"1M\", \"10M\"],\n",
    "}\n",
    "fig.show();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "5f922025",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = load_podcast_db(\"/mnt/data-ssd-1/data/podcasts/meta/podcastindex_feeds.db\", english_only=False, anchor_only=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5e89f32d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b688b7c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6a0e561d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3c56bc81",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "fc556523",
   "metadata": {},
   "source": [
    "## Playground"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0afb0b64",
   "metadata": {},
   "source": [
    "### check cities"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "c9c9f2ff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city_name</th>\n",
       "      <th>city</th>\n",
       "      <th>location</th>\n",
       "      <th>country</th>\n",
       "      <th>x</th>\n",
       "      <th>y</th>\n",
       "      <th>county_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Brühl</td>\n",
       "      <td>http://www.wikidata.org/entity/Q7036</td>\n",
       "      <td>Point(6.9 50.833333333)</td>\n",
       "      <td>http://www.wikidata.org/entity/Q183</td>\n",
       "      <td>6.900000</td>\n",
       "      <td>50.833333</td>\n",
       "      <td>Germany</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Køge</td>\n",
       "      <td>http://www.wikidata.org/entity/Q21184</td>\n",
       "      <td>Point(12.183333333 55.45)</td>\n",
       "      <td>http://www.wikidata.org/entity/Q35</td>\n",
       "      <td>12.183333</td>\n",
       "      <td>55.450000</td>\n",
       "      <td>Denmark</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  city_name                                   city                   location  \\\n",
       "0     Brühl   http://www.wikidata.org/entity/Q7036    Point(6.9 50.833333333)   \n",
       "1      Køge  http://www.wikidata.org/entity/Q21184  Point(12.183333333 55.45)   \n",
       "\n",
       "                               country          x          y county_name  \n",
       "0  http://www.wikidata.org/entity/Q183   6.900000  50.833333     Germany  \n",
       "1   http://www.wikidata.org/entity/Q35  12.183333  55.450000     Denmark  "
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cities_df = pd.read_json(\"meta_data/cities.json\")\n",
    "cities_df = cities_df[~cities_df[\"location\"].str.contains(\"www\")].reset_index(drop=True)\n",
    "cities_df[\"x\"] = cities_df[\"location\"].str[6:-1].str.split().str[0].astype(float)\n",
    "cities_df[\"y\"] = cities_df[\"location\"].str[6:-1].str.split().str[1].astype(float)\n",
    "cities_df = cities_df.rename({\"label_en\": \"city_name\"}, axis=1)\n",
    "\n",
    "countries_df = pd.read_json(\"meta_data/countries.json\")\n",
    "cities_df[\"country_name\"] = cities_df[\"country\"].map(countries_df.set_index(\"country\")[\"label_en\"])\n",
    "\n",
    "cities_df.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "755acb16",
   "metadata": {},
   "outputs": [],
   "source": [
    "# block_set = set([\n",
    "#     \"David\", \"Martin\", \"Best\",\n",
    "# ])\n",
    "\n",
    "search_terms = [\n",
    "    s_clean for s in cities_df[\"city_name\"].unique() \n",
    "    if 50 >= len(s_clean := s.strip()) >= 4# and s_clean not in block_set\n",
    "]\n",
    "search_ptn = re.compile(\n",
    "    r\"in ({})\\b\".format(r\"|\".join([re.escape(s) for s in sorted(search_terms, key=len, reverse=True)])), \n",
    ")\n",
    "\n",
    "def _get_stuff(fn):\n",
    "    found_fns = []\n",
    "    with open(RAW_RSS_DIR + fn, \"rb\") as f:\n",
    "        xml_str = f.read()\n",
    "    string_rep = str(xml_str)\n",
    "    for m in set(search_ptn.findall(string_rep)):\n",
    "        found_fns.append((m, fn))\n",
    "    return found_fns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "a4f069b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# found_fns = []\n",
    "# for fn in tqdm.tqdm(english_rss_filenames[:100]):\n",
    "#     found_fns.extend(_get_stuff(fn))\n",
    "# print(len(set([e[0] for e in found_fns])), \"cities found\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "860cda9c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "988 cities found\n"
     ]
    }
   ],
   "source": [
    "p = multiprocessing.Pool(20)\n",
    "tmp = p.map(_get_stuff, english_rss_filenames[:100000])\n",
    "city_matches = []\n",
    "for e in tmp:\n",
    "    city_matches.extend(e)\n",
    "p.close()\n",
    "p.join()\n",
    "print(len(set([e[0] for e in city_matches])), \"cities found\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "994376a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "London           1063\n",
       "Los Angeles       761\n",
       "China             721\n",
       "New York City     692\n",
       "Florida           609\n",
       "dtype: int64"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series([e[0] for e in city_matches]).value_counts().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e5dd514",
   "metadata": {},
   "source": [
    "### check countries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "9126932f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>country_name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>http://www.wikidata.org/entity/Q16</td>\n",
       "      <td>Canada</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>http://www.wikidata.org/entity/Q805</td>\n",
       "      <td>Yemen</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               country country_name\n",
       "0   http://www.wikidata.org/entity/Q16       Canada\n",
       "1  http://www.wikidata.org/entity/Q805        Yemen"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "countries_df = pd.read_json(\"meta_data/countries.json\")\n",
    "countries_df = countries_df.rename({\"label_en\": \"country_name\"}, axis=1)\n",
    "countries_df.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "f5cd74ef",
   "metadata": {},
   "outputs": [],
   "source": [
    "# block_set = set([\n",
    "#     \"David\", \"Martin\", \"Best\",\n",
    "# ])\n",
    "\n",
    "search_terms = [\n",
    "    s_clean for s in countries_df[\"country_name\"].unique() \n",
    "    if 50 >= len(s_clean := s.strip()) >= 2# and s_clean not in block_set\n",
    "]\n",
    "search_ptn = re.compile(\n",
    "    r\"in (?:the )?({})\\b\".format(r\"|\".join([re.escape(s) for s in sorted(search_terms, key=len, reverse=True)])), \n",
    ")\n",
    "\n",
    "def _get_stuff(fn):\n",
    "    found_fns = []\n",
    "    with open(RAW_RSS_DIR + fn, \"rb\") as f:\n",
    "        xml_str = f.read()\n",
    "    string_rep = str(xml_str)\n",
    "    for m in set(search_ptn.findall(string_rep)):\n",
    "        found_fns.append((m, fn))\n",
    "    return found_fns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "a739d78d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# found_fns = []\n",
    "# for fn in tqdm.tqdm(english_rss_filenames[:100]):\n",
    "#     found_fns.extend(_get_stuff(fn))\n",
    "# print(len(set([e[0] for e in found_fns])), \"countries found\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "76801cd4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "988 countries found\n"
     ]
    }
   ],
   "source": [
    "p = multiprocessing.Pool(20)\n",
    "tmp = p.map(_get_stuff, english_rss_filenames[:100000])\n",
    "country_matches = []\n",
    "for e in tmp:\n",
    "    country_matches.extend(e)\n",
    "p.close()\n",
    "p.join()\n",
    "print(len(set([e[0] for e in city_matches])), \"countries found\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "7ce4a9fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Canada       872\n",
       "Australia    846\n",
       "India        745\n",
       "Japan        607\n",
       "Germany      486\n",
       "dtype: int64"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series([e[0] for e in country_matches]).value_counts().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c25d344",
   "metadata": {},
   "source": [
    "### find where both matches"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "495b129a",
   "metadata": {},
   "outputs": [],
   "source": [
    "city_to_country_map = cities_df.groupby(\"city_name\")[\"country_name\"].apply(list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "f36e8d85",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 3172/3172 [00:03<00:00, 817.87it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1306 matches\n",
      "994 unambiguous country matches\n",
      "747 unambiguous city matches\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "common_fps = set([e[1] for e in city_matches]) & set([e[1] for e in country_matches])\n",
    "matches = []\n",
    "for fp in tqdm.tqdm(common_fps):\n",
    "    cities = [e[0] for e in city_matches if e[1] == fp]\n",
    "    countries = [e[0] for e in country_matches if e[1] == fp]\n",
    "    local_matches = []\n",
    "    for city in cities:\n",
    "        h = [c in set(countries) for c in city_to_country_map[city] if c in set(countries)]\n",
    "        for c in city_to_country_map[city]:\n",
    "            if c in set(countries):\n",
    "                local_matches.append((city, c))\n",
    "    if len(local_matches) > 0:\n",
    "        matches.append((fp, local_matches))\n",
    "print(len(matches), \"matches\")\n",
    "unambig_country_matches = [m for m in matches if len(set([e[1] for e in m[1]])) == 1]\n",
    "print(len(unambig_country_matches), \"unambiguous country matches\")\n",
    "unambig_city_matches = [m for m in matches if len(set([e[0] for e in m[1]])) == 1]\n",
    "print(len(unambig_city_matches), \"unambiguous city matches\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6140e278",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TODO: redo the same but look for country in title and summary, and then next figure out how to do city if this works"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3ece5eb0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0227361c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "01ec24e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(RAW_RSS_DIR + fp, \"rb\") as f:\n",
    "    xml_str = f.read()\n",
    "feed = feedparser.parse(xml_str)\n",
    "feed[\"feed\"][\"title\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c879267a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "id": "6f354538",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [e for e in unambig_city_matches]\n",
    "random.seed(6006)\n",
    "random.shuffle(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "id": "ccbc937f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('Helsinki', 'Finland')]"
      ]
     },
     "execution_count": 161,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n = 10\n",
    "fp, matches = a[n]\n",
    "matches"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "id": "08664c29",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(RAW_RSS_DIR + fp, \"rb\") as f:\n",
    "    rss_bytes = f.read()\n",
    "feed = feedparser.parse(xml_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 260,
   "id": "729ce198",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "видео — Russian Progress\n",
      "Канал и подкаст для изучения русского\n"
     ]
    }
   ],
   "source": [
    "def _html_clean(text):\n",
    "    text = BeautifulSoup(text).text\n",
    "    text = re.sub(r\"^\\s*\\<\\!\\[CDATA\\[\", \"\", text)\n",
    "    text = re.sub(r\"\\]\\>\\s*$\", \"\", text)\n",
    "    return normalize_whitespace(text)\n",
    "\n",
    "podcast_title = (\n",
    "    _html_clean(s.group(1))\n",
    "    if (s := re.search(r\"title\\>(.+?)\\<\\/title\", rss_bytes.decode(\"UTF-8\"))) else \"\"\n",
    ")\n",
    "podcast_summary = (\n",
    "    _html_clean(s.group(1))\n",
    "    if (s := re.search(r\"description\\>(.+?)\\<\\/description\", rss_bytes.decode(\"UTF-8\"))) else \"\"\n",
    ")\n",
    "\n",
    "print(podcast_title)\n",
    "print(podcast_summary)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "990e3561",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 228,
   "id": "746e10b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\"\\n\\txmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\\n\\txmlns:wfw=\"http://wellformedweb.org/CommentAPI/\"\\n\\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\\n\\txmlns:atom=\"http://www.w3.org/2005/Atom\"\\n\\txmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"\\n\\txmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\\n\\txmlns:georss=\"http://www.georss.org/georss\" xmlns:geo=\"http://www.w3.org/2003/01/geo/wgs84_pos#\" xmlns:media=\"http://search.yahoo.com/mrss/\"\\n\\t>\\n\\n<channel>\\n\\t<title>\\xd0\\xb2\\xd0\\xb8\\xd0\\xb4\\xd0\\xb5\\xd0\\xbe &#8212; Russian Progress</title>\\n\\t<atom:link href=\"https://russianprogress.com/category/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE/feed/\" rel=\"self\" type=\"application/rss+xml\" />\\n\\t<link>https://russianprogress.com</link>\\n\\t<description>\\xd0\\x9a\\xd0\\xb0\\xd0\\xbd\\xd0\\xb0\\xd0\\xbb \\xd0\\xb8 \\xd0\\xbf\\xd0\\xbe\\xd0\\xb4\\xd0\\xba\\xd0\\xb0\\xd1\\x81\\xd1\\x82 \\xd0\\xb4\\xd0\\xbb\\xd1\\x8f \\xd0\\xb8\\xd0\\xb7\\xd1\\x83\\xd1\\x87\\xd0\\xb5\\xd0\\xbd\\xd0\\xb8\\xd1\\x8f \\xd1\\x80\\xd1\\x83\\xd1\\x81\\xd1\\x81\\xd0\\xba\\xd0\\xbe\\xd0\\xb3\\xd0\\xbe</description>\\n\\t<lastBuildDate>Fri, 04 Feb 2022 20:45:27 +0000</lastBuildDate>\\n\\t<language>ru-RU</language>\\n\\t<sy:updatePeriod>\\n\\thourly\\t</sy:updatePeriod>\\n\\t<sy:updateFreque'"
      ]
     },
     "execution_count": 228,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# encoding=\"UTF-8\"\n",
    "rss_bytes[:1000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 265,
   "id": "d6eec794",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "59385"
      ]
     },
     "execution_count": 265,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d = []\n",
    "n = 0\n",
    "for fn in english_rss_filenames:\n",
    "    with open(RAW_RSS_DIR + fn, \"rb\") as f:\n",
    "        rss_bytes = f.read()\n",
    "    try:\n",
    "        rss_bytes.decode(\"UTF-8\")\n",
    "    except:\n",
    "        d.append(rss_bytes)\n",
    "    if len(d) >= 100:\n",
    "        break\n",
    "    n += 1\n",
    "n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "df5070fc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f66f73ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "UnicodeDecodeError"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 312,
   "id": "d0d30199",
   "metadata": {},
   "outputs": [
    {
     "ename": "UnicodeDecodeError",
     "evalue": "'utf-8' codec can't decode byte 0x88 in position 599: invalid start byte",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mUnicodeDecodeError\u001b[0m                        Traceback (most recent call last)",
      "\u001b[0;32m/tmp/ipykernel_3305229/4031881846.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      7\u001b[0m     \u001b[0;32mif\u001b[0m \u001b[0mm\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      8\u001b[0m         \u001b[0mencoding_type\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mm\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgroup\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m         \u001b[0mrss_str\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrss_bytes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mencoding_type\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     10\u001b[0m     \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     11\u001b[0m         \u001b[0mnf\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mUnicodeDecodeError\u001b[0m: 'utf-8' codec can't decode byte 0x88 in position 599: invalid start byte"
     ]
    }
   ],
   "source": [
    "nf = 0\n",
    "n = 0\n",
    "for fn in english_rss_filenames:\n",
    "    with open(RAW_RSS_DIR + fn, \"rb\") as f:\n",
    "        rss_bytes = f.read()\n",
    "        .decode(\"unicode_escape\")\n",
    "    m = re.search(r\"encoding\\=[\\'\\\"](.+?)[\\'\\\"]\", str(rss_bytes))\n",
    "    if m:\n",
    "        encoding_type = m.group(1)\n",
    "        rss_str = rss_bytes.decode(encoding_type)\n",
    "    else:\n",
    "        nf += 1\n",
    "    n += 1\n",
    "    if n >= 10000:\n",
    "        break\n",
    "n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 313,
   "id": "4a92489d",
   "metadata": {},
   "outputs": [
    {
     "ename": "UnicodeDecodeError",
     "evalue": "'utf-8' codec can't decode byte 0x88 in position 599: invalid start byte",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mUnicodeDecodeError\u001b[0m                        Traceback (most recent call last)",
      "\u001b[0;32m/tmp/ipykernel_3305229/1895581437.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mrss_bytes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mencoding_type\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mUnicodeDecodeError\u001b[0m: 'utf-8' codec can't decode byte 0x88 in position 599: invalid start byte"
     ]
    }
   ],
   "source": [
    "rss_bytes.decode(encoding_type)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 315,
   "id": "1618f54b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\r\\n<rss xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\" xmlns:itunesu=\"http://www.itunesu.com/feed\" version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\\r\\n  <channel>\\r\\n    <title>Reid Hoffman &amp; Joi Ito</title>\\r\\n    <language>en-us</language>\\r\\n    <copyright>2014 Academy of Achievement</copyright>\\r\\n    <itunes:explicit>no</itunes:explicit>\\r\\n    <description>\\r\\n      This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"\\x88ºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n    </description>\\r\\n    <link>http://www.achievement.org</link>\\r\\n    <itunes:image href=\"http://media.achievement.org/artwork/h/AA_iTunesAlbum_hoffmanito.png\"/>\\r\\n    <item>\\r\\n      <itunes:order>995</itunes:order>\\r\\n      <title>Reid Hoffman &amp; Joi Ito (SD) Part 1</title>\\r\\n      <itunes:subtitle>Social Media Pioneers</itunes:subtitle>\\r\\n      <itunes:author>Academy of Achievement</itunes:author>\\r\\n      <enclosure url=\"http://podcasts.achievement.org.s3.amazonaws.com/sd/2014/hoffman-and-ito-2014-part-1-vid.m4v\" length=\"179981955\" type=\"video/x-m4v\" />\\r\\n      <itunes:image href=\"http://media.achievement.org/artwork/h/AA_iTunesAlbum_hoffmanito.png\"/>\\r\\n      <pubDate>13 Sept 2014 09:00:00 EST</pubDate>\\r\\n      <itunes:duration>14:54</itunes:duration>\\r\\n      <itunesu:category itunesu:code=\"100107\" />\\r\\n      <itunes:summary>\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"\\x88ºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      </itunes:summary>\\r\\n      <guid>http://podcasts.achievement.org.s3.amazonaws.com/sd/2014/hoffman-and-ito-2014-part-1-vid.m4v</guid>\\r\\n      <itunes:keywords>Entrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity</itunes:keywords>\\r\\n    </item>\\r\\n        <item>\\r\\n      <itunes:order>996</itunes:order>\\r\\n      <title>Reid Hoffman &amp; Joi Ito (SD) Part 2</title>\\r\\n      <itunes:subtitle>Social Media Pioneers</itunes:subtitle>\\r\\n      <itunes:author>Academy of Achievement</itunes:author>\\r\\n      <enclosure url=\"http://podcasts.achievement.org.s3.amazonaws.com/sd/2014/hoffman-and-ito-2014-part-2-vid.m4v\" length=\"142236270\" type=\"video/x-m4v\" />\\r\\n      <itunes:image href=\"http://media.achievement.org/artwork/h/AA_iTunesAlbum_hoffmanito.png\"/>\\r\\n      <pubDate>13 Sept 2014 09:00:00 EST</pubDate>\\r\\n      <itunes:duration>11:13</itunes:duration>\\r\\n      <itunesu:category itunesu:code=\"100107\" />\\r\\n      <itunes:summary>\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"\\x88ºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      </itunes:summary>\\r\\n      <guid>http://podcasts.achievement.org.s3.amazonaws.com/sd/2014/hoffman-and-ito-2014-part-2-vid.m4v</guid>\\r\\n      <itunes:keywords>Entrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity</itunes:keywords>\\r\\n    </item>\\r\\n        <item>\\r\\n      <itunes:order>997</itunes:order>\\r\\n      <title>Reid Hoffman &amp; Joi Ito (HD) Part 1</title>\\r\\n      <itunes:subtitle>Social Media Pioneers</itunes:subtitle>\\r\\n      <itunes:author>Academy of Achievement</itunes:author>\\r\\n      <enclosure url=\"http://podcasts.achievement.org.s3.amazonaws.com/hd/2014/hoffman-and-ito-2014-part-1-hd-vid.m4v\" length=\"1152746752\" type=\"video/x-m4v\" />\\r\\n      <itunes:image href=\"http://media.achievement.org/artwork/h/AA_iTunesAlbum_hoffmanito.png\"/>\\r\\n      <pubDate>13 Sept 2014 09:00:00 EST</pubDate>\\r\\n      <itunes:duration>14:54</itunes:duration>\\r\\n      <itunesu:category itunesu:code=\"100107\" />\\r\\n      <itunes:summary>\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"\\x88ºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      </itunes:summary>\\r\\n      <guid>http://podcasts.achievement.org.s3.amazonaws.com/hd/2014/hoffman-and-ito-2014-part-1-hd-vid.m4v</guid>\\r\\n      <itunes:keywords>Entrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity</itunes:keywords>\\r\\n    </item>\\r\\n    <item>\\r\\n      <itunes:order>998</itunes:order>\\r\\n      <title>Reid Hoffman &amp; Joi Ito (HD) Part 2</title>\\r\\n      <itunes:subtitle>Social Media Pioneers</itunes:subtitle>\\r\\n      <itunes:author>Academy of Achievement</itunes:author>\\r\\n      <enclosure url=\"http://podcasts.achievement.org.s3.amazonaws.com/hd/2014/hoffman-and-ito-2014-part-2-hd-vid.m4v\" length=\"866683940\" type=\"video/x-m4v\" />\\r\\n      <itunes:image href=\"http://media.achievement.org/artwork/h/AA_iTunesAlbum_hoffmanito.png\"/>\\r\\n      <pubDate>13 Sept 2014 09:00:00 EST</pubDate>\\r\\n      <itunes:duration>11:13</itunes:duration>\\r\\n      <itunesu:category itunesu:code=\"100107\" />\\r\\n      <itunes:summary>\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"\\x88ºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      </itunes:summary>\\r\\n      <guid>http://podcasts.achievement.org.s3.amazonaws.com/hd/2014/hoffman-and-ito-2014-part-2-hd-vid.m4v</guid>\\r\\n      <itunes:keywords>Entrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity</itunes:keywords>\\r\\n    </item>\\r\\n        <item>\\r\\n      <itunes:order>999</itunes:order>\\r\\n      <title>Reid Hoffman &amp; Joi Ito (Audio) Part 1</title>\\r\\n      <itunes:subtitle>Social Media Pioneers</itunes:subtitle>\\r\\n      <itunes:author>Academy of Achievement</itunes:author>\\r\\n      <enclosure url=\"http://podcasts.achievement.org.s3.amazonaws.com/audio/2014/hoffman-and-ito-2014-part-1-aud.mp3\" length=\"14320616\" type=\"audio/mpeg\" />\\r\\n      <itunes:image href=\"http://media.achievement.org/artwork/h/AA_iTunesAlbum_hoffmanito.png\"/>\\r\\n      <pubDate>13 Sept 2014 09:00:00 EST</pubDate>\\r\\n      <itunes:duration>14:54</itunes:duration>\\r\\n      <itunesu:category itunesu:code=\"100107\" />\\r\\n      <itunes:summary>\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"\\x88ºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      </itunes:summary>\\r\\n      <guid>http://podcasts.achievement.org.s3.amazonaws.com/audio/2014/hoffman-and-ito-2014-part-1-aud.mp3</guid>\\r\\n      <itunes:keywords>Entrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity</itunes:keywords>\\r\\n    </item>\\r\\n    <item>\\r\\n      <itunes:order>1000</itunes:order>\\r\\n      <title>Reid Hoffman &amp; Joi Ito (Audio) Part 2</title>\\r\\n      <itunes:subtitle>Social Media Pioneers</itunes:subtitle>\\r\\n      <itunes:author>Academy of Achievement</itunes:author>\\r\\n      <enclosure url=\"http://podcasts.achievement.org.s3.amazonaws.com/audio/2014/hoffman-and-ito-2014-part-2-aud.mp3\" length=\"10775904\" type=\"audio/mpeg\" />\\r\\n      <itunes:image href=\"http://media.achievement.org/artwork/h/AA_iTunesAlbum_hoffmanito.png\"/>\\r\\n      <pubDate>13 Sept 2014 09:00:00 EST</pubDate>\\r\\n      <itunes:duration>11:13</itunes:duration>\\r\\n      <itunesu:category itunesu:code=\"100107\" />\\r\\n      <itunes:summary>\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"\\x88ºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      </itunes:summary>\\r\\n      <guid>http://podcasts.achievement.org.s3.amazonaws.com/audio/2014/hoffman-and-ito-2014-part-2-aud.mp3</guid>\\r\\n      <itunes:keywords>Entrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity</itunes:keywords>\\r\\n    </item>\\r\\n  </channel>\\r\\n</rss>\\r\\n'"
      ]
     },
     "execution_count": 315,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rss_bytes.decode(\"unicode_escape\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 314,
   "id": "8adb24d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\r\\n<rss xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\" xmlns:itunesu=\"http://www.itunesu.com/feed\" version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\\r\\n  <channel>\\r\\n    <title>Reid Hoffman &amp; Joi Ito</title>\\r\\n    <language>en-us</language>\\r\\n    <copyright>2014 Academy of Achievement</copyright>\\r\\n    <itunes:explicit>no</itunes:explicit>\\r\\n    <description>\\r\\n      This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"\\x88\\xbaber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he foun'"
      ]
     },
     "execution_count": 314,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rss_bytes[:1000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d217a7f4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 292,
   "id": "c3493b58",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'\\x88\\xba'"
      ]
     },
     "execution_count": 292,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d[1][599:601]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7fdcdc77",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "35ffefbe",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 268,
   "id": "35773ae4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\n\\nReid Hoffman & Joi Ito\\nen-us\\n2014 Academy of Achievement\\nno\\n\\r\\n      This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"ˆºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n    \\nhttp://www.achievement.org\\r\\n    \\n\\n995\\nReid Hoffman & Joi Ito (SD) Part 1\\nSocial Media Pioneers\\nAcademy of Achievement\\n\\n\\n13 Sept 2014 09:00:00 EST\\n14:54\\n\\n\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"ˆºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      \\nhttp://podcasts.achievement.org.s3.amazonaws.com/sd/2014/hoffman-and-ito-2014-part-1-vid.m4v\\nEntrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity\\n\\n\\n996\\nReid Hoffman & Joi Ito (SD) Part 2\\nSocial Media Pioneers\\nAcademy of Achievement\\n\\n\\n13 Sept 2014 09:00:00 EST\\n11:13\\n\\n\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"ˆºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      \\nhttp://podcasts.achievement.org.s3.amazonaws.com/sd/2014/hoffman-and-ito-2014-part-2-vid.m4v\\nEntrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity\\n\\n\\n997\\nReid Hoffman & Joi Ito (HD) Part 1\\nSocial Media Pioneers\\nAcademy of Achievement\\n\\n\\n13 Sept 2014 09:00:00 EST\\n14:54\\n\\n\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"ˆºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      \\nhttp://podcasts.achievement.org.s3.amazonaws.com/hd/2014/hoffman-and-ito-2014-part-1-hd-vid.m4v\\nEntrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity\\n\\n\\n998\\nReid Hoffman & Joi Ito (HD) Part 2\\nSocial Media Pioneers\\nAcademy of Achievement\\n\\n\\n13 Sept 2014 09:00:00 EST\\n11:13\\n\\n\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"ˆºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      \\nhttp://podcasts.achievement.org.s3.amazonaws.com/hd/2014/hoffman-and-ito-2014-part-2-hd-vid.m4v\\nEntrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity\\n\\n\\n999\\nReid Hoffman & Joi Ito (Audio) Part 1\\nSocial Media Pioneers\\nAcademy of Achievement\\n\\n\\n13 Sept 2014 09:00:00 EST\\n14:54\\n\\n\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"ˆºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      \\nhttp://podcasts.achievement.org.s3.amazonaws.com/audio/2014/hoffman-and-ito-2014-part-1-aud.mp3\\nEntrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity\\n\\n\\n1000\\nReid Hoffman & Joi Ito (Audio) Part 2\\nSocial Media Pioneers\\nAcademy of Achievement\\n\\n\\n13 Sept 2014 09:00:00 EST\\n11:13\\n\\n\\r\\n        This podcast features two of the visionaries of today\\'s world of Internet commerce and social media. Reid Hoffman has been called \"the most connected man in Silicon Valley,\" the \"ˆºber-investor\" who \"has had a hand in creating nearly every lucrative social media startup.\" He was the originator of the PayPal online commerce tool and is the founder and Chairman of LinkedIn, as well as an early investor in Facebook, GroupOn and Airbnb. Joi Ito, a social media entrepreneur in his own right, is now Director of the MIT Media Lab. A techno-prodigy and onetime nightclub DJ, he founded the venture capital firm Neoteny Co., Ltd., and was an early investor in Kickstarter, Twitter and many other innovative Internet companies. One of the world\\'s leading advocates of Internet freedom, he has described his vision of a decentralized political structure, mediated through the Internet, in the widely-disseminated essay Emergent Democracy.  In this podcast, recorded at the 2014 International Achievement Summit in San Francisco, the two friends engage in a freewheeling discussion of today\\'s media landscape, with personal observations of the industry\\'s leaders and a tantalizing peek at its future.\\r\\n      \\nhttp://podcasts.achievement.org.s3.amazonaws.com/audio/2014/hoffman-and-ito-2014-part-2-aud.mp3\\nEntrepreneurs, Lessons of Leadership, My Path to Success, Change Agents, Overcoming Adversity\\n\\n\\n\\n'"
      ]
     },
     "execution_count": 268,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "BeautifulSoup(d[1]).text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c4123ed",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "163f2391",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8b6ddfc8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bab57536",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "a61dc8e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 'tags': [{'term': 'Uncategorized', 'scheme': None, 'label': None},\n",
    "#     {'term': 'Afghanistan', 'scheme': None, 'label': None},\n",
    "#     {'term': 'Iran', 'scheme': None, 'label': None}],"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "id": "f5690444",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'видео — Russian Progress'"
      ]
     },
     "execution_count": 166,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "feed[\"feed\"][\"title\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 485,
   "id": "1a00b47a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['bozo', 'entries', 'feed', 'headers', 'encoding', 'version', 'namespaces'])"
      ]
     },
     "execution_count": 485,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "feed.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 488,
   "id": "858e6b73",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Music']"
      ]
     },
     "execution_count": 488,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7e71a38b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0f51af48",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6775b443",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Findings:\n",
    "# countries could be OK per episode for interviews??"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d408aefb",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b58100f4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "3fd54e58",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [e for e in found_fns]\n",
    "random.seed(6006)\n",
    "random.shuffle(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "afeac741",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>label_en</th>\n",
       "      <th>city</th>\n",
       "      <th>location</th>\n",
       "      <th>country</th>\n",
       "      <th>x</th>\n",
       "      <th>y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3048</th>\n",
       "      <td>Florida</td>\n",
       "      <td>http://www.wikidata.org/entity/Q842472</td>\n",
       "      <td>Point(-56.216666666 -34.1)</td>\n",
       "      <td>http://www.wikidata.org/entity/Q77</td>\n",
       "      <td>-56.216667</td>\n",
       "      <td>-34.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7209</th>\n",
       "      <td>Florida</td>\n",
       "      <td>http://www.wikidata.org/entity/Q643617</td>\n",
       "      <td>Point(-78.222777777 21.529444444)</td>\n",
       "      <td>http://www.wikidata.org/entity/Q241</td>\n",
       "      <td>-78.222778</td>\n",
       "      <td>21.529444</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     label_en                                    city  \\\n",
       "3048  Florida  http://www.wikidata.org/entity/Q842472   \n",
       "7209  Florida  http://www.wikidata.org/entity/Q643617   \n",
       "\n",
       "                               location                              country  \\\n",
       "3048         Point(-56.216666666 -34.1)   http://www.wikidata.org/entity/Q77   \n",
       "7209  Point(-78.222777777 21.529444444)  http://www.wikidata.org/entity/Q241   \n",
       "\n",
       "              x          y  \n",
       "3048 -56.216667 -34.100000  \n",
       "7209 -78.222778  21.529444  "
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cities_df[cities_df[\"label_en\"] == \"Florida\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "cdf7a95f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[' Relief Therapy Los Angeles</title><link>ht']"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "q = \"Los Angeles\"\n",
    "n = 6\n",
    "_, fn = [e for e in a if e[0] == q][n]\n",
    "with open(RAW_RSS_DIR + fn, \"rb\") as f:\n",
    "    xml_str = f.read()\n",
    "string_rep = str(xml_str)\n",
    "re.findall(r\"................{}................\".format(q), string_rep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1ff7c586",
   "metadata": {},
   "outputs": [],
   "source": [
    "in, to"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "bc1d56d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['aaa']"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.findall(r\"in (aaa|bbb)\\b\", \"aaa in lkjnsd in aaa\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "466e72b1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fa4693cf",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "250d8ab4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d3c07f4e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "6b75e3a0",
   "metadata": {},
   "source": [
    "## Playground"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "12d87798",
   "metadata": {},
   "source": [
    "### Check India"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "2462425a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2485876 rss feeds\n"
     ]
    }
   ],
   "source": [
    "rss_filenames = [fn for fn in os.listdir(RSS_DIR) if fn.endswith(\"feed\")]\n",
    "print(len(rss_filenames), \"rss feeds\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "d27ac597",
   "metadata": {},
   "outputs": [],
   "source": [
    "english_ids = set(main_df[main_df[\"language\"] == \"en\"][\"id\"])\n",
    "india_ids = set(main_df[main_df[\"language\"] == \"en-in\"][\"id\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "8b8f4fb1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "295 podcasts labeled as 'en-in'\n"
     ]
    }
   ],
   "source": [
    "print(len(india_ids), \"podcasts labeled as 'en-in'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "affd10fe",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "56cf2cbf",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 911/2485876 [00:04<3:50:16, 179.85it/s][NeMo W 2022-05-06 22:16:13 nemo_logging:349] /home/georg/venvs/ml/lib/python3.8/site-packages/bs4/__init__.py:431: MarkupResemblesLocatorWarning: \"http://www.horrortheque.com/public-domain-horror-movies/jesse-james-meets-frankensteins-daughter/\" looks like a URL. Beautiful Soup is not an HTTP client. You should probably use an HTTP client like requests to get the document behind the URL, and feed that document to Beautiful Soup.\n",
      "      warnings.warn(\n",
      "    \n",
      "  0%|          | 2086/2485876 [00:11<2:17:20, 301.40it/s][NeMo W 2022-05-06 22:16:17 nemo_logging:349] /home/georg/venvs/ml/lib/python3.8/site-packages/bs4/__init__.py:337: MarkupResemblesLocatorWarning: \".\" looks like a directory name, not markup. You may want to open a file found in this directory and pass the filehandle into Beautiful Soup.\n",
      "      warnings.warn(\n",
      "    \n",
      "  0%|          | 5092/2485876 [00:21<2:54:24, 237.06it/s]\n"
     ]
    }
   ],
   "source": [
    "terms = [\n",
    "    \"Ludhiana\", \"Chandigarh\", \"Punjab\", \"India\"\n",
    "]\n",
    "search_ptn = re.compile(r\"({})\".format(r\"|\".join([re.escape(s) for s in terms])))\n",
    "\n",
    "def _html_clean(text):\n",
    "    return BeautifulSoup(text).text.replace(\"<![CDATA[\", \"\").rstrip(\"]>\\n \")\n",
    "\n",
    "data = []\n",
    "for fn in tqdm.tqdm(rss_filenames):\n",
    "    podcast_id = int(fn.split(\".\")[0])\n",
    "    if podcast_id not in english_ids:\n",
    "        continue\n",
    "    with open(RSS_DIR + fn, \"rb\") as f:\n",
    "        rss_bytes = f.read()\n",
    "    if not search_ptn.search(str(rss_bytes)):\n",
    "        continue\n",
    "    feed = feedparser.parse(rss_bytes)\n",
    "    \n",
    "    podcast_title = normalize_whitespace(feed[\"feed\"].get(\"title\", \"\"))\n",
    "    podcast_summary = normalize_whitespace(\n",
    "        _html_clean(s.group(1))\n",
    "        if (s := re.search(r\"description>(.+?)</description\", str(rss_bytes))) else \"\"\n",
    "    )\n",
    "    result_type = \"episode\"\n",
    "    terms_found = set()\n",
    "    if (m := search_ptn.search(podcast_title + \" \" + podcast_summary)):\n",
    "        result_type = \"podcast\"\n",
    "        terms_found.add(m.group(1))\n",
    "    relevant_episode_data = []\n",
    "    for episode in feed[\"entries\"]:\n",
    "        episode_title = normalize_whitespace(episode.get(\"title\", \"\"))\n",
    "        episode_summary = _html_clean(normalize_whitespace(episode.get(\"summary\", \"\")))\n",
    "        audio_links = [\n",
    "            l.get(\"href\", \"\") for l in episode.get(\"links\", []) \n",
    "            if l.get(\"rel\", \"\") == \"enclosure\" and \"audio\" in l.get(\"type\", \"\")\n",
    "        ]\n",
    "        if len(audio_links) == 0:\n",
    "            continue\n",
    "        audio_link = audio_links[0]\n",
    "        if (m := search_ptn.search(episode_title + \" \" + episode_summary)):\n",
    "            terms_found.add(m.group(1))\n",
    "        if result_type == \"podcast\" or m:\n",
    "            relevant_episode_data.append({\n",
    "                \"audio_uri\": audio_link, \n",
    "                \"title\": episode_title, \n",
    "                \"summary\": episode_summary,\n",
    "            })  \n",
    "    if len(relevant_episode_data) > 0:\n",
    "        data.append({\n",
    "            \"result_type\": result_type, \n",
    "            \"terms_found\": list(terms_found), \n",
    "            \"id\": podcast_id, \n",
    "            \"title\": podcast_title, \n",
    "            \"summary\": podcast_summary, \n",
    "            \"episodes\": relevant_episode_data,\n",
    "        })\n",
    "    if len(data) >= 100:\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bc5dd139",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TODO: better html clean than beautiful soup\n",
    "# TODO: filter tunes, music, Mashup\n",
    "# TODO: lots of sports filter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "291dfd0f",
   "metadata": {},
   "outputs": [],
   "source": [
    "for e in data:\n",
    "    if \"Punjab\" in e[\"terms_found\"] and e[\"result_type\"] == \"podcast\":\n",
    "        print(e[\"title\"])\n",
    "        print(e[\"summary\"])\n",
    "        print(\"-\"*10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "267300eb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sanem re Mashup Dj Nitz Punjabi style\n",
      "\n",
      "----------\n",
      "India vs Pakistan: Live Reactions from India\n",
      "It was a horrible night for Team India and Manchester United fans. Finally, the streak is broken. Pakistan has defeated India in the WC for the first time. With this thumping loss, Team India's chances have taken a major hit. With the next match against NZ, we could be looking at an early exit for Team India.  #IndvsPak\n",
      "The Most Blunt T20 2021 World Cup Preview\n",
      "Happy World Cup day! With the world cup starting today after a gap of 5 years we analyze the chances of each team. Can India and Virat Kohli break the jinx of the knockouts?  #WT20 #T20WorldCup\n",
      "India will BEAT England at Lord’s? - India vs England 2nd Test| Lord's 2021\n",
      "We answer the 11 most important questions regarding the ongoing test series between India and England.  Will India pick Ashwin? Is Kohli Finished? KL Rahul next Mark Waugh? Sam Curran England's Jadeja? Favorite Dom Sibley shot? Why do England batsmen suck? Is Bumrah the greatest number 10? Whose 5-for at Trentbridge? Rohit and Rahane? Why is Siraj Sledging Sam Curran? Can India win at the Lord's?\n",
      "Will England Whitewash India 5-0? India Vs England Test Series Preview\n",
      "I know millions of patriotic fans & pundits — suffering from Toxic Optimism — are dismissing the WTC final as a one-off loss & attributing it to India’s recent —& well-earned— reputation as slow-starters.  But correlation is not causation — And England isn’t India or Australia. There will be no viciously spinning pitches and Duke's ball demands rock-solid test technique to score more than 10 runs.  #IndiavsEngland #IndvsEng #EngvsIndia\n",
      "Shilpa refuses Black Widow, Badshah saves India Cultural Music & more - Funniest News of the Week#10\n",
      "This week in the Funniest News  I refused major stuff in H'wood as I didn't want to shift base to US: Shilpa  Want to focus on bringing Indian music on the global map: Badshah  US man threatens to bomb McDonald's outlet for not sending sauce  UK man 'identifies as Korean' after 18 surgeries to look like BTS' Jimin  Man in UK sells car to pay iTunes bill after son buys game top-ups of ₹1.3 lakh  The Humans of the United States finally discover Cricket  Our Novels at Amazon: https://www.amazon.in/Evil-Z-Blunt/e/B081Z53PM1%3Fref=dbs_a_mng_rwt_scns_share Our Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com​ T-Shirt Partner: https://www.spawnpoint.in​\n",
      "Warne Schooled, Akshay's Success Mantra, Weirdest Auctions & more - Funniest News of the Week#7\n",
      "- Paul Walker's Toyota Supra from 'Fast & Furious' sells for over ₹4 crore - He's like my brother: Gwyneth Paltrow on ex-husband Chris Martin - Yoga is India's unique gift to the world, says Anupam Kher - I was once accused of stealing money by PG landlady, I vacated it in 2 days: Minissha - My songs made Akshay a star, he was called 'Gareebo Ka Mithun': Abhijeet - Will never stereotype them by gender: Karan Johar on kids Yash, Roohi - Does Shane Warne know anything about Spin?\n",
      "Who will win WTC? India or New Zealand?\n",
      "The final preview of the contest between India and New Zealand at The Ageas Bowl, Southampton. We think NZ is the favorite to win it. Why? Check it out inside.  Our Novels at Amazon: https://www.amazon.in/Evil-Z-Blunt/e/B081Z53PM1%3Fref=dbs_a_mng_rwt_scns_share Our Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com​ T-Shirt Partner: https://www.spawnpoint.in​\n",
      "IPL to UAE, Sushil Caught, Kane and Messi moving to India? | Sexiest News of the Week| Episode 2\n",
      "We are back with the 2nd Episode of the Sexiest News of the Week. This week's news:  IPL moves to UAE  Kangana Ranaut (KaRa) has now tested negative for Corona  Sushil Kumar Arrested By Delhi Police In Murder Case  Liverpool Goalkeeper Alisson Creates History  AB confirms permanent International Retirement  Second Wave of Sandpaper Gate is Back  Harry Kane is Leaving Tottenham  Messi leaving Barcelona Karim  Benzema is Back, He will play for France after 6 years\n",
      "Cricket Podcast - India’s Squad for The England Tour\n",
      "Akash Chopra wanted Prithvi, Hardik, Kuldeep, Bhuveneshwar in the squad — except he forgot to tell us, who will he drop because this is not a Shaadi that you can take a squad of 50.  We analyze the team selection for the World Test Championship Final and the England Test series.  https://www.espncricinfo.com/video/aakash-chopra-i-would-have-liked-prithvi-shaw-and-bhuvneshwar-kumar-in-the-squad-1262514  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blun... ​Our Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com​ T-Shirt Partner: https://www.spawnpoint.in​\n",
      "IPL Cancelled or Postponed?\n",
      "Wokes were asking for it, Instagram influencers were crying for it. And it finally happened. IPL 2021 is canceled. Well not really. It has just been suspended for a while. But should it have been played at all? Will India become a better place now since IPL is suspended? Is it wrong to earn money during a pandemic? How much money we are even talking about? All that and more in this edition of Blunt Basterds Podcast\n",
      "IPL 2021 Review - Warner Sacked !!!\n",
      "It was an eventful week in the IPL 2021. Warner was sacked and dropped from the team, KL Rahul was rushed for surgery, and several teams and players came out to donate. We discuss the current state of IPL 2021 at the end of the 3rd week.  #IPL2021 #DavidWarner #KLRahul 00:00 Intro  3:06 Was it right to drop Warner?  6:35 RR vs SRH  8:04 CSK vs MI  12:44 Same old problems with RCB  19:52 Punjab vs DC  24:23 Top 4\n",
      "India DESTROYS England to Win Test Series 3-1\n",
      "What happened to Dom Bess? Is Rishabh Pant the next Adam Gilchrist? Can Axar break Murali’s record of 800 Test wickets? Is Washington Sundar the Next Steven Smith? All this and more in this edition of the Blunt Basterd podcast.   Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in #IndiavsEngland #RishabhPant #AxarPatel\n",
      "Will India BEAT England in the 3rd Test in Ahmedabad?\n",
      "It's gonna be a mouth-watering contest in the brand new - biggest ever in the world - stadium. And the icing on the cake is that it's a Pink Ball - Day-Night Test - which I believe is the future of Test Cricket.  Let's hope the 3rd Test lives up to the expectations :)  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "Can India Save the 1st Test Match - India vs England\n",
      "India is in deep trouble in the 1st Test match in Chennai. Despite Pant's blitz, India is a long way behind in the game. What went wrong? Can they make a comeback 4th time in the row? Is there even a possibility of an Indian win? We discuss all these and more.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in #IndiavsEngland #1stTestMatch\n",
      "Why India's Covid-19 Lockdown Flopped\n",
      "Here’s my view: India should never have had the lockdown - none whatsoever - ever.   Why? Because Cure can’t be worse than the Disease.   Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2  Our Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com  T-Shirt Partner: https://www.spawnpoint.in\n",
      "Will India BEAT England at Home in the TEST series?\n",
      "India is on a high after beating the Aussies at their home. And England is also on a little \"tiny\" High after beating Sri Lanka at their home.   This is going to be a mouthwatering contest. Let's hope it lives up to the billing & gives us the goosebumps that the recently concluded Border-Gavaskar Trophy did. Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in 00:00 Start 00:58 Why Kuldeep is picked over Chahal? 02:58 Moeen Ali better than Shane Warne? 04:16 England's rotation policy 08:09 Joe Root the next Bradman? 12:16 English Openers   14:33 Do we even need Virat Kohli anymore? 15:13 The English Winning Template 19:00 Sundar over Pandya? 22:39 James Anderson is a Legend 29:00 Prediction Time\n",
      "Can India Win At Brisbane? Ind vs Aus - 4th Test 2021\n",
      "Blunt Analysis of the ongoing 4th Test match between India and Australia at Gabba, Brisbane. Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "Can A Beefed-Up India Outwit Australia Again? - 3rd Test Match Preview\n",
      "After all the controversies and injuries. it's finally time for the 3rd Test Match between India and Australia. Both teams will be bolstered by inclusion of senior players. But at the same time injuries to key Indian bowlers will be a cause of concern for the Indian Team Management. Will India be able to brush aside those concerns and defeat Australia again?  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "36 All Out: Are Test Batsmen Dead?\n",
      "We analyze the horrific Adelaide test and discuss what went wrong. Why batsmen keep failing at the test level. Can India bounce back from this drubbing? Is Prithvi's test career over? All that and much more.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "India vs. Australia - 1st Test Prediction\n",
      "Our prediction for the 1st Test Match between India and Australia being played at Adelaide. Both Gav and Bik predict different outcomes. Whose prediction will come true? Let us know in the comments.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "India Wins T20 Series in Australia\n",
      "We dissect the India-Australia series so far. How did Virat Kohli fare as a captain? Smith & Warner's impact. Jadeja's super-sub. And many more. Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in 00:00 Intro 02:24 Is Virat A Bad Captain? 07:47 When Should Chahal Play? 10:24 Time to Bring New Subscribers 14:17 Why No One Cares about T20s 23:19 Importance of Warner & Smith 26:53 Will Virat Stay? 35:43 Was Jadeja's Sub Like for Like? 42:12 Test Series Prediction\n",
      "India vs Australia Cricket Series [Preview] - Blunt Basterds\n",
      "This year's biggest cricket clash is starting from tomorrow. India's tour of Australia starts off with One Day Internationals(ODI). We discuss both the teams and how the series could pan out. Virat Kohli's paternity leave and Rohit Sharma's injury. We discuss all that and more.  Something shocking happened while recording the podcast.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "Why Trump Lost | Blunt Analysis\n",
      "How did Donald Trump lose? How did Covid-19 affect his campaign? Was he the worst president the United States has ever seen? Will Biden be a significantly better leader? Can Biden upsurge the right-wing forces in India like the Indian liberals hope? We answer all these questions and more. But are we qualified to analyze something complex like the US elections? Hmm.. maybe not. But like one 19 years old guy from Pune said. We won't let you down, Joe.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "SRH Breaks RCB Hearts...Again | IPL 2020 | Blunt Basterds\n",
      "SRH has always knocked RCB from IPL. This year is no different as SRH beats RCB in a tightly contested match in the first Eliminator. While Mumbai Indians cruise past the Delhi Capitals with ease, to enter yet another IPL Finals. Our analysis for the both the matches.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "SRH Destroyed Mumbai Indians | Blunt Basterds | IPL 2020\n",
      "Sunrisers Hyderabad has shown the way to defeat Mumbai Indians. Will Delhi Capitals be able to emulate what SRH did last night? Can Royal Challengers Bangalore lift their game to get past Sunrisers Hyderabad in the IPL 2020 playoffs. All that and more.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "RCB Lose and KKR Eliminated? | IPL 2020 | Blunt Analysis\n",
      "Royal Challengers Bangalore suffered their second loss while Mumbai Indians ensure qualification. Chennai Super Kings spoil Kolkata Knight Rider's party and knock them off.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "Delhi Out of IPL? | Blunt Analysis | IPL 2020\n",
      "It is getting harder for Delhi Capitals with their 3rd straight loss in IPL 2020. Their next two matches are against the table toppers Mumbai Indians and Royal Challengers Bangalore. Will they be able to win these matches and qualify for the playoffs? On the other hand Kings XI Punjab is a rolling juggernaut which looks all set to make it to the playoffs. Our analysis of match # 46 & 47. We also predict the outcome of match #48 & 49; MI vs RCB and CSK vs RR.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "IPL Review: Week 5 | Stokes Century & CSK Victory | IPL 2020\n",
      "End of the 5th week brought out some shocking results where the top three teams went down to lower teams. This opens up interesting possibilities for rest of the IPL 2020.  We analyze the last 4 games which have opened up the tournament for everyone. We also review each and every team's performance and tell you where they are headed. We predict the winners of the next two matches; Kolkata Knight Riders vs Kings XI Punjab and Sunrisers Hyderabad vs Delhi Capitals.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "CSK will finish LAST | Blunt Analysis | IPL 2020\n",
      "Our Analysis of IPL 2020 matches Mumbai Indians vs Kings XI Punjab and Chennai Super Kings vs Sunrisers Hyderabad.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2  Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com  T-Shirt Partner: https://www.spawnpoint.in\n",
      "Tewatia is the New Tendulkar | Blunt Analysis | IPL 2020\n",
      "Our Analysis of IPL 2020 matches Rajasthan Royals vs Kings XI Punjab and Royal Challengers Bangalore vs Mumbai Indians.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2  Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com  T-Shirt Partner: https://www.spawnpoint.in\n",
      "Blunt Analysis| CSK Beats MI in IPL 2020 Match 01\n",
      "We analyze how did Chennai Super Kings beat Mumbai Indians in the IPL opener. A game which we predicted would be won my Mumbai Indians comprehensively. We also predict the outcomes of the next couple of matches in the IPL 2020.  Our Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2  Our Blog at Blogger: https://fake-chetan-bhagat.blogspot.com  T-Shirt Partner: https://www.spawnpoint.in\n",
      "EP#7 - Dhoni RETIRES - “BEST & WORST” Career Moments\n",
      "In this podcast, we discuss Dhoni’s career, starting even before he began playing for India on 23rd December 2004. We ‘intensely & honestly’ talk about the BEST & WORST moment of his India career that he called curtains on 15 August 2020.  My Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 My Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "EP#6 - Were West Indies the Greatest Cricket Team Ever?\n",
      "Fire in Babylon [2010]: Documentary on the Rise of West Indian Cricket in the 70s & how they dominated Cricket for the next 20 years & they dominated the Real Cricket: Test Cricket. But there was a lot more. It was about forging an identity for themselves - as Black people - showing their old masters - The English - that they were equal & can beat them at the sport that the English invented. Cricket brought all the West Indian islands together. Cricket is one of the rarest sports they play as West Indies - otherwise, the islands are all independent.\n",
      "EP#5 - Why India Loves Cricket?\n",
      "In this Podcast, we take a walk down the memory lane to unearth the moment, we found Cricket or as the romantics would say - Cricket found ‘us’ :) These are the Questions we Answer in this Podcast. Why don’t you send us your Answers too? We would love to read your stories of Cricket & Sport.  My Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2 My Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com T-Shirt Partner: https://www.spawnpoint.in\n",
      "EP#4 - Greatest Indian ODI XI EVER\n",
      "After the amazing success of our best one day international team. We set out to select the best Indian ODI team since we are Indians (at least Bikram is). We compiled the best Indian XI and this is what we came up with.    My Novels at Amazon: https://www.amazon.in/s?k=Evil+Z+Blunt&ref=nb_sb_noss_2  My Blogs at Blogger: https://fake-chetan-bhagat.blogspot.com  T-Shirt Partner: https://www.spawnpoint.in\n",
      "----------\n",
      "Episode 13: Samai Di Pukar (Punjabi) by Jaswant Bhatia\n",
      "The call of time in support of Indian farmers.\n",
      "Episode 12: Dil Di Awaaz\n",
      "Voice for the Indian Farmers. Inspired by Guru Nanak Dev JI’s farming\n",
      "Episode 11: Farmer’s Protest\n",
      "Shaan and Jyoti learn about the three laws that Punjabi farmers are protesting. They learn about the promise children must make to their people.\n",
      "----------\n"
     ]
    }
   ],
   "source": [
    "for e in data:\n",
    "    if \"Punjab\" in e[\"terms_found\"] and e[\"result_type\"] == \"episode\":\n",
    "        for ee in e[\"episodes\"]:\n",
    "            print(ee[\"title\"])\n",
    "            print(ee[\"summary\"])\n",
    "        print(\"-\"*10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1d107678",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ee8bb9a2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dae971e4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d942b825",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ddb7abd0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "ee3bd539",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "51338 mentions of 'India'\n",
      "1270 mentions of 'Punjab'\n",
      "177 mentions of 'Chandigarh'\n",
      "34 mentions of 'Ludhiana'\n"
     ]
    }
   ],
   "source": [
    "print(len(potential_fps), \"mentions of 'India'\")\n",
    "print(len(a), \"mentions of 'Punjab'\")\n",
    "print(len(b), \"mentions of 'Chandigarh'\")\n",
    "print(len(c), \"mentions of 'Ludhiana'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "25ccd844",
   "metadata": {},
   "outputs": [],
   "source": [
    "fn = c[6]\n",
    "with open(RSS_DIR + fn, \"rb\") as f:\n",
    "    rss_bytes = f.read()\n",
    "feed = feedparser.parse(rss_bytes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "47e0145c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'bozo': False,\n",
       " 'entries': [{'title': 'Kahaani: Ten Rupees',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': 'Kahaani: Ten Rupees'},\n",
       "   'summary': '<p>Namaskar Doston</p>\\n<p><br /></p>\\n<p>Reborn Studios Presents A Brand New Series - Kahaaniyaan</p>\\n<p><br /></p>\\n<p>*Episode - Ten Rupees: A short story by Saadat Hasan Manto</p>\\n<p><br /></p>\\n<p>Saadat Hasan Manto was a colonial Indian and Pakistani writer, playwright, and author born in Ludhiana, India. Writing mainly in the Urdu language, he produced 22 collections of short stories, a novel, five series of radio plays, three collections of essays, and two collections of personal sketches.</p>\\n<p>E-mail: rebornstudio8@gmail.com</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Rewritten by - Rohit Khurana</p>\\n<p>Sound Design &amp; Edit: Rohit Agarwal</p>\\n<p>This Piece has been Narrated By:</p>\\n<p>*Aryan Sharma, Rebecca Gola, Disha Thanky, Prajjval Khakharia, Pranay Jha, Hitul Pujara *&nbsp;</p>\\n<p>Poster: Rohit Agarwal</p>\\n<p><br /></p>\\n<p>We hope you enjoy it!</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>',\n",
       "   'summary_detail': {'type': 'text/html',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': '<p>Namaskar Doston</p>\\n<p><br /></p>\\n<p>Reborn Studios Presents A Brand New Series - Kahaaniyaan</p>\\n<p><br /></p>\\n<p>*Episode - Ten Rupees: A short story by Saadat Hasan Manto</p>\\n<p><br /></p>\\n<p>Saadat Hasan Manto was a colonial Indian and Pakistani writer, playwright, and author born in Ludhiana, India. Writing mainly in the Urdu language, he produced 22 collections of short stories, a novel, five series of radio plays, three collections of essays, and two collections of personal sketches.</p>\\n<p>E-mail: rebornstudio8@gmail.com</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Rewritten by - Rohit Khurana</p>\\n<p>Sound Design &amp; Edit: Rohit Agarwal</p>\\n<p>This Piece has been Narrated By:</p>\\n<p>*Aryan Sharma, Rebecca Gola, Disha Thanky, Prajjval Khakharia, Pranay Jha, Hitul Pujara *&nbsp;</p>\\n<p>Poster: Rohit Agarwal</p>\\n<p><br /></p>\\n<p>We hope you enjoy it!</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'},\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Ten-Rupees-eif8pe'},\n",
       "    {'length': '10758050',\n",
       "     'type': 'audio/x-m4a',\n",
       "     'href': 'https://anchor.fm/s/29cb040c/podcast/play/18374894/sponsor/a2o9so3/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fstaging%2F2021-05-03%2F0c0e1ccbb40628622aad800037d48cb7.m4a',\n",
       "     'rel': 'enclosure'}],\n",
       "   'link': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Ten-Rupees-eif8pe',\n",
       "   'id': '8879de4e-ab9b-4477-b6dd-07712628cfa3',\n",
       "   'guidislink': False,\n",
       "   'authors': [{'name': 'Reborn Studio'}],\n",
       "   'author': 'Reborn Studio',\n",
       "   'author_detail': {'name': 'Reborn Studio'},\n",
       "   'published': 'Fri, 21 Aug 2020 15:05:09 GMT',\n",
       "   'published_parsed': time.struct_time(tm_year=2020, tm_mon=8, tm_mday=21, tm_hour=15, tm_min=5, tm_sec=9, tm_wday=4, tm_yday=234, tm_isdst=0),\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': '',\n",
       "     'value': '<p>Namaskar Doston</p>\\n<p><br /></p>\\n<p>Reborn Studios Presents A Brand New Series - Kahaaniyaan</p>\\n<p><br /></p>\\n<p>*Episode - Ten Rupees: A short story by Saadat Hasan Manto</p>\\n<p><br /></p>\\n<p>Saadat Hasan Manto was a colonial Indian and Pakistani writer, playwright, and author born in Ludhiana, India. Writing mainly in the Urdu language, he produced 22 collections of short stories, a novel, five series of radio plays, three collections of essays, and two collections of personal sketches.</p>\\n<p>E-mail: rebornstudio8@gmail.com</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Rewritten by - Rohit Khurana</p>\\n<p>Sound Design &amp; Edit: Rohit Agarwal</p>\\n<p>This Piece has been Narrated By:</p>\\n<p>*Aryan Sharma, Rebecca Gola, Disha Thanky, Prajjval Khakharia, Pranay Jha, Hitul Pujara *&nbsp;</p>\\n<p>Poster: Rohit Agarwal</p>\\n<p><br /></p>\\n<p>We hope you enjoy it!</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'}],\n",
       "   'itunes_explicit': None,\n",
       "   'itunes_duration': '665',\n",
       "   'image': {'href': 'https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded_episode/6911707/6911707-1598022317504-9895db47521e9.jpg'},\n",
       "   'itunes_season': '1',\n",
       "   'itunes_episode': '6',\n",
       "   'itunes_episodetype': 'full'},\n",
       "  {'title': 'Kahaani: Ek Sookha Gulaab',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': 'Kahaani: Ek Sookha Gulaab'},\n",
       "   'summary': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 5 - EK SOOKHA GULAAB - A short story by Junaid Chaudhry.</p>\\n<p>E-mail: rebornstudio8@gmail.com</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Aryan Sharma &amp; Rohan Satish&nbsp;</p>\\n<p>Sound Design &amp; Edit: Aryan Sharma</p>\\n<p>Poster: Rohit Agarwal</p>\\n<p>We hope you enjoy it!</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>',\n",
       "   'summary_detail': {'type': 'text/html',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 5 - EK SOOKHA GULAAB - A short story by Junaid Chaudhry.</p>\\n<p>E-mail: rebornstudio8@gmail.com</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Aryan Sharma &amp; Rohan Satish&nbsp;</p>\\n<p>Sound Design &amp; Edit: Aryan Sharma</p>\\n<p>Poster: Rohit Agarwal</p>\\n<p>We hope you enjoy it!</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'},\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Ek-Sookha-Gulaab-ehipjd'},\n",
       "    {'length': '11200376',\n",
       "     'type': 'audio/x-m4a',\n",
       "     'href': 'https://anchor.fm/s/29cb040c/podcast/play/17441837/sponsor/a2o9so3/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fstaging%2F2021-05-03%2Fc5b5f0105acf610c324fb34b02552df4.m4a',\n",
       "     'rel': 'enclosure'}],\n",
       "   'link': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Ek-Sookha-Gulaab-ehipjd',\n",
       "   'id': '09119b9a-167b-4255-90ab-3ef68e8e2d42',\n",
       "   'guidislink': False,\n",
       "   'authors': [{'name': 'Reborn Studio'}],\n",
       "   'author': 'Reborn Studio',\n",
       "   'author_detail': {'name': 'Reborn Studio'},\n",
       "   'published': 'Sun, 02 Aug 2020 12:21:26 GMT',\n",
       "   'published_parsed': time.struct_time(tm_year=2020, tm_mon=8, tm_mday=2, tm_hour=12, tm_min=21, tm_sec=26, tm_wday=6, tm_yday=215, tm_isdst=0),\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': '',\n",
       "     'value': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 5 - EK SOOKHA GULAAB - A short story by Junaid Chaudhry.</p>\\n<p>E-mail: rebornstudio8@gmail.com</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Aryan Sharma &amp; Rohan Satish&nbsp;</p>\\n<p>Sound Design &amp; Edit: Aryan Sharma</p>\\n<p>Poster: Rohit Agarwal</p>\\n<p>We hope you enjoy it!</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'}],\n",
       "   'itunes_explicit': None,\n",
       "   'itunes_duration': '692',\n",
       "   'image': {'href': 'https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded_episode/6911707/6911707-1596370894493-9c270836818ff.jpg'},\n",
       "   'itunes_season': '1',\n",
       "   'itunes_episode': '5',\n",
       "   'itunes_episodetype': 'full'},\n",
       "  {'title': 'Kahaani: Ginni',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': 'Kahaani: Ginni'},\n",
       "   'summary': \"<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 4 - Ginni - Rabindranath Tagore</p>\\n<p>Rabindranath Tagore FRAS, also known by his pen name Bhanu Singha Thakur, and also known by his sobriquets Gurudev, Kabiguru, and Biswakabi, was a Bengali poet, writer, music composer, and painter in the late 19th and early 20th centuries.&nbsp;</p>\\n<p>E-mail: rebornstudio8@gmail.com</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Aryan Sharma</p>\\n<p>Asst.Producer: Mariam D'mello</p>\\n<p>Narrated By: Aryan Sharma &amp; Hitul Pujara</p>\\n<p>Sound Design &amp; Edit: Aryan Sharma</p>\\n<p>Poster: Rohit Agarwal</p>\\n<p>We hope you enjoy it!</p>\",\n",
       "   'summary_detail': {'type': 'text/html',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': \"<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 4 - Ginni - Rabindranath Tagore</p>\\n<p>Rabindranath Tagore FRAS, also known by his pen name Bhanu Singha Thakur, and also known by his sobriquets Gurudev, Kabiguru, and Biswakabi, was a Bengali poet, writer, music composer, and painter in the late 19th and early 20th centuries.&nbsp;</p>\\n<p>E-mail: rebornstudio8@gmail.com</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Aryan Sharma</p>\\n<p>Asst.Producer: Mariam D'mello</p>\\n<p>Narrated By: Aryan Sharma &amp; Hitul Pujara</p>\\n<p>Sound Design &amp; Edit: Aryan Sharma</p>\\n<p>Poster: Rohit Agarwal</p>\\n<p>We hope you enjoy it!</p>\"},\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Ginni-egvure'},\n",
       "    {'length': '9861550',\n",
       "     'type': 'audio/mpeg',\n",
       "     'href': 'https://anchor.fm/s/29cb040c/podcast/play/16824622/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fstaging%2F2020-6-20%2Faec6c00f-e7a1-b715-8a7f-b352ad1fafc4.mp3',\n",
       "     'rel': 'enclosure'}],\n",
       "   'link': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Ginni-egvure',\n",
       "   'id': '8849b66e-2a3d-46bf-bcf0-1fcdfc2200bb',\n",
       "   'guidislink': False,\n",
       "   'authors': [{'name': 'Reborn Studio'}],\n",
       "   'author': 'Reborn Studio',\n",
       "   'author_detail': {'name': 'Reborn Studio'},\n",
       "   'published': 'Mon, 20 Jul 2020 08:09:02 GMT',\n",
       "   'published_parsed': time.struct_time(tm_year=2020, tm_mon=7, tm_mday=20, tm_hour=8, tm_min=9, tm_sec=2, tm_wday=0, tm_yday=202, tm_isdst=0),\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': '',\n",
       "     'value': \"<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 4 - Ginni - Rabindranath Tagore</p>\\n<p>Rabindranath Tagore FRAS, also known by his pen name Bhanu Singha Thakur, and also known by his sobriquets Gurudev, Kabiguru, and Biswakabi, was a Bengali poet, writer, music composer, and painter in the late 19th and early 20th centuries.&nbsp;</p>\\n<p>E-mail: rebornstudio8@gmail.com</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Aryan Sharma</p>\\n<p>Asst.Producer: Mariam D'mello</p>\\n<p>Narrated By: Aryan Sharma &amp; Hitul Pujara</p>\\n<p>Sound Design &amp; Edit: Aryan Sharma</p>\\n<p>Poster: Rohit Agarwal</p>\\n<p>We hope you enjoy it!</p>\"}],\n",
       "   'itunes_explicit': None,\n",
       "   'itunes_duration': '615',\n",
       "   'image': {'href': 'https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded_episode/6911707/6911707-1595232550771-a79e4c5c66a01.jpg'},\n",
       "   'itunes_season': '1',\n",
       "   'itunes_episode': '4',\n",
       "   'itunes_episodetype': 'full'},\n",
       "  {'title': 'Kahaani: Akal Daad',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': 'Kahaani: Akal Daad'},\n",
       "   'summary': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 3 - Akal daad - Story by Sadat Hasan Manto..</p>\\n<p>&nbsp;Ishq-e-dastoor ki ek pyaari si nok-jhok.</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Rebecca and Rohit</p>\\n<p>Sound Design &amp; Edit: Rohit</p>\\n<p>Poster: Rohit Agarwal</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>',\n",
       "   'summary_detail': {'type': 'text/html',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 3 - Akal daad - Story by Sadat Hasan Manto..</p>\\n<p>&nbsp;Ishq-e-dastoor ki ek pyaari si nok-jhok.</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Rebecca and Rohit</p>\\n<p>Sound Design &amp; Edit: Rohit</p>\\n<p>Poster: Rohit Agarwal</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'},\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Akal-Daad-egpbpq'},\n",
       "    {'length': '10980721',\n",
       "     'type': 'audio/x-m4a',\n",
       "     'href': 'https://anchor.fm/s/29cb040c/podcast/play/16608506/sponsor/a2o9so3/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fstaging%2F2021-05-03%2Fa697901b7933193667e0ff52d5e9fad9.m4a',\n",
       "     'rel': 'enclosure'}],\n",
       "   'link': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Akal-Daad-egpbpq',\n",
       "   'id': 'adb6e768-f48e-4538-bd7b-bdba3b3564a6',\n",
       "   'guidislink': False,\n",
       "   'authors': [{'name': 'Reborn Studio'}],\n",
       "   'author': 'Reborn Studio',\n",
       "   'author_detail': {'name': 'Reborn Studio'},\n",
       "   'published': 'Wed, 15 Jul 2020 13:11:23 GMT',\n",
       "   'published_parsed': time.struct_time(tm_year=2020, tm_mon=7, tm_mday=15, tm_hour=13, tm_min=11, tm_sec=23, tm_wday=2, tm_yday=197, tm_isdst=0),\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': '',\n",
       "     'value': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 3 - Akal daad - Story by Sadat Hasan Manto..</p>\\n<p>&nbsp;Ishq-e-dastoor ki ek pyaari si nok-jhok.</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Rebecca and Rohit</p>\\n<p>Sound Design &amp; Edit: Rohit</p>\\n<p>Poster: Rohit Agarwal</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'}],\n",
       "   'itunes_explicit': None,\n",
       "   'itunes_duration': '678',\n",
       "   'image': {'href': 'https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded_episode/6911707/6911707-1594818691590-b6ca0bbdfed4e.jpg'},\n",
       "   'itunes_season': '1',\n",
       "   'itunes_episode': '3',\n",
       "   'itunes_episodetype': 'full'},\n",
       "  {'title': 'Kahaani: Aatma ki Aavaz',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': 'Kahaani: Aatma ki Aavaz'},\n",
       "   'summary': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 2 - Aatma ki Aavaz - Story by Kamleshwar.</p>\\n<p>Kaha jata hai insaan marta hai par uski aatma kabhi nahi marti, toh sunte hai inki aatma ki aavaz humse kya kenhna chahti hai.</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Disha and Prajjval</p>\\n<p>Sound Design &amp; Edit: Prajjval</p>\\n<p>Poster: Rohit Agarwal</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>',\n",
       "   'summary_detail': {'type': 'text/html',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 2 - Aatma ki Aavaz - Story by Kamleshwar.</p>\\n<p>Kaha jata hai insaan marta hai par uski aatma kabhi nahi marti, toh sunte hai inki aatma ki aavaz humse kya kenhna chahti hai.</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Disha and Prajjval</p>\\n<p>Sound Design &amp; Edit: Prajjval</p>\\n<p>Poster: Rohit Agarwal</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'},\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Aatma-ki-Aavaz-egjhuf'},\n",
       "    {'length': '12873746',\n",
       "     'type': 'audio/x-m4a',\n",
       "     'href': 'https://anchor.fm/s/29cb040c/podcast/play/16418191/sponsor/a2o9so3/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fstaging%2F2021-05-03%2Fc48da20b7280ffbf69f8b10867014fb2.m4a',\n",
       "     'rel': 'enclosure'}],\n",
       "   'link': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Aatma-ki-Aavaz-egjhuf',\n",
       "   'id': '4b22ffa2-e3b2-4ab0-8a35-f7dd93f3642e',\n",
       "   'guidislink': False,\n",
       "   'authors': [{'name': 'Reborn Studio'}],\n",
       "   'author': 'Reborn Studio',\n",
       "   'author_detail': {'name': 'Reborn Studio'},\n",
       "   'published': 'Sat, 11 Jul 2020 12:30:27 GMT',\n",
       "   'published_parsed': time.struct_time(tm_year=2020, tm_mon=7, tm_mday=11, tm_hour=12, tm_min=30, tm_sec=27, tm_wday=5, tm_yday=193, tm_isdst=0),\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': '',\n",
       "     'value': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p>Episode 2 - Aatma ki Aavaz - Story by Kamleshwar.</p>\\n<p>Kaha jata hai insaan marta hai par uski aatma kabhi nahi marti, toh sunte hai inki aatma ki aavaz humse kya kenhna chahti hai.</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Disha and Prajjval</p>\\n<p>Sound Design &amp; Edit: Prajjval</p>\\n<p>Poster: Rohit Agarwal</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'}],\n",
       "   'itunes_explicit': None,\n",
       "   'itunes_duration': '795',\n",
       "   'image': {'href': 'https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded_episode/6911707/6911707-1594470635454-7e64d964cab62.jpg'},\n",
       "   'itunes_season': '1',\n",
       "   'itunes_episode': '2',\n",
       "   'itunes_episodetype': 'full'},\n",
       "  {'title': 'Kahaani: Ab Aur Kehne Ki Zaroorat Nahi',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': 'Kahaani: Ab Aur Kehne Ki Zaroorat Nahi'},\n",
       "   'summary': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p><br /></p>\\n<p>Episode 1 - Ab Aur Kehne Ki Zaroorat Nahi - Saadat Hasan Manto</p>\\n<p><br /></p>\\n<p>Saadat Hasan Manto was one of the most prolific Urdu writers of the 21st Century. With works such as \\'Toba Tek Singh\\', \\'Thanda Ghost\\', \\'Das Rupiye\\' and many more, we bring to you one of his underrated gems, \\'Ab Aur Kehne Ki Zaroorat Nahi\\'</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Aryan Sharma &amp; Hitul Pujara</p>\\n<p>Sound Design &amp; Edit: Aryan Sharma</p>\\n<p>Poster: Rohit Agarwal</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>',\n",
       "   'summary_detail': {'type': 'text/html',\n",
       "    'language': None,\n",
       "    'base': '',\n",
       "    'value': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p><br /></p>\\n<p>Episode 1 - Ab Aur Kehne Ki Zaroorat Nahi - Saadat Hasan Manto</p>\\n<p><br /></p>\\n<p>Saadat Hasan Manto was one of the most prolific Urdu writers of the 21st Century. With works such as \\'Toba Tek Singh\\', \\'Thanda Ghost\\', \\'Das Rupiye\\' and many more, we bring to you one of his underrated gems, \\'Ab Aur Kehne Ki Zaroorat Nahi\\'</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Aryan Sharma &amp; Hitul Pujara</p>\\n<p>Sound Design &amp; Edit: Aryan Sharma</p>\\n<p>Poster: Rohit Agarwal</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'},\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Ab-Aur-Kehne-Ki-Zaroorat-Nahi-eg7p8i'},\n",
       "    {'length': '15944742',\n",
       "     'type': 'audio/x-m4a',\n",
       "     'href': 'https://anchor.fm/s/29cb040c/podcast/play/16032466/sponsor/a2o9so3/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fstaging%2F2021-05-03%2F40222d7883647d26e71ca0821ba6b95e.m4a',\n",
       "     'rel': 'enclosure'}],\n",
       "   'link': 'https://anchor.fm/reborn-studio/episodes/Kahaani-Ab-Aur-Kehne-Ki-Zaroorat-Nahi-eg7p8i',\n",
       "   'id': 'a02c01a6-c8a0-41a7-99e5-510be86df552',\n",
       "   'guidislink': False,\n",
       "   'authors': [{'name': 'Reborn Studio'}],\n",
       "   'author': 'Reborn Studio',\n",
       "   'author_detail': {'name': 'Reborn Studio'},\n",
       "   'published': 'Thu, 02 Jul 2020 19:27:45 GMT',\n",
       "   'published_parsed': time.struct_time(tm_year=2020, tm_mon=7, tm_mday=2, tm_hour=19, tm_min=27, tm_sec=45, tm_wday=3, tm_yday=184, tm_isdst=0),\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': '',\n",
       "     'value': '<p>Reborn Studios Presents A Brand New Series - Kahaani</p>\\n<p><br /></p>\\n<p>Episode 1 - Ab Aur Kehne Ki Zaroorat Nahi - Saadat Hasan Manto</p>\\n<p><br /></p>\\n<p>Saadat Hasan Manto was one of the most prolific Urdu writers of the 21st Century. With works such as \\'Toba Tek Singh\\', \\'Thanda Ghost\\', \\'Das Rupiye\\' and many more, we bring to you one of his underrated gems, \\'Ab Aur Kehne Ki Zaroorat Nahi\\'</p>\\n<p>Instagram: @therebornstudio</p>\\n<p>Producer: Rohit Agarwal &amp; Rahul Agarwal</p>\\n<p>Director: Hitul Pujara</p>\\n<p>Asst.Producer: Mariam D\\'mello</p>\\n<p>Narrated By: Aryan Sharma &amp; Hitul Pujara</p>\\n<p>Sound Design &amp; Edit: Aryan Sharma</p>\\n<p>Poster: Rohit Agarwal</p>\\n\\n--- \\n\\nThis episode is sponsored by \\n· Anchor: The easiest way to make a podcast.  <a href=\"https://anchor.fm/app\">https://anchor.fm/app</a>'}],\n",
       "   'itunes_explicit': None,\n",
       "   'itunes_duration': '985',\n",
       "   'image': {'href': 'https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded_episode/6911707/6911707-1594470307064-a8ea6f72f8a0a.jpg'},\n",
       "   'itunes_season': '1',\n",
       "   'itunes_episode': '1',\n",
       "   'itunes_episodetype': 'full'}],\n",
       " 'feed': {'title': 'The Reborn Studio Podcast',\n",
       "  'title_detail': {'type': 'text/plain',\n",
       "   'language': None,\n",
       "   'base': '',\n",
       "   'value': 'The Reborn Studio Podcast'},\n",
       "  'subtitle': 'Creative content that converts Audio + Social.',\n",
       "  'subtitle_detail': {'type': 'text/html',\n",
       "   'language': None,\n",
       "   'base': '',\n",
       "   'value': 'Creative content that converts Audio + Social.'},\n",
       "  'links': [{'rel': 'alternate',\n",
       "    'type': 'text/html',\n",
       "    'href': 'https://anchor.fm/reborn-studio'},\n",
       "   {'href': 'https://anchor.fm/s/29cb040c/podcast/rss',\n",
       "    'rel': 'self',\n",
       "    'type': 'application/rss+xml'},\n",
       "   {'rel': 'hub',\n",
       "    'href': 'https://pubsubhubbub.appspot.com/',\n",
       "    'type': 'text/html'}],\n",
       "  'link': 'https://anchor.fm/reborn-studio',\n",
       "  'image': {'href': 'https://d3t3ozftmdmh3i.cloudfront.net/production/podcast_uploaded/6911707/6911707-1593718549936-2f94ec92a9fea.jpg'},\n",
       "  'generator_detail': {'name': 'Anchor Podcasts'},\n",
       "  'generator': 'Anchor Podcasts',\n",
       "  'updated': 'Tue, 26 Apr 2022 08:26:58 GMT',\n",
       "  'updated_parsed': time.struct_time(tm_year=2022, tm_mon=4, tm_mday=26, tm_hour=8, tm_min=26, tm_sec=58, tm_wday=1, tm_yday=116, tm_isdst=0),\n",
       "  'authors': [{'name': 'Reborn Studio'},\n",
       "   {'name': 'Reborn Studio', 'email': 'podcasts60+29cb040c@anchor.fm'}],\n",
       "  'author': 'Reborn Studio',\n",
       "  'author_detail': {'name': 'Reborn Studio'},\n",
       "  'rights': 'Reborn Studio',\n",
       "  'rights_detail': {'type': 'text/plain',\n",
       "   'language': None,\n",
       "   'base': '',\n",
       "   'value': 'Reborn Studio'},\n",
       "  'language': 'en',\n",
       "  'summary': 'Creative content that converts Audio + Social.',\n",
       "  'summary_detail': {'type': 'text/plain',\n",
       "   'language': None,\n",
       "   'base': '',\n",
       "   'value': 'Creative content that converts Audio + Social.'},\n",
       "  'itunes_type': 'episodic',\n",
       "  'publisher_detail': {'name': 'Reborn Studio',\n",
       "   'email': 'podcasts60+29cb040c@anchor.fm'},\n",
       "  'itunes_explicit': None,\n",
       "  'tags': [{'term': 'Fiction',\n",
       "    'scheme': 'http://www.itunes.com/',\n",
       "    'label': None}]},\n",
       " 'headers': {},\n",
       " 'encoding': 'utf-8',\n",
       " 'version': 'rss20',\n",
       " 'namespaces': {'dc': 'http://purl.org/dc/elements/1.1/',\n",
       "  'content': 'http://purl.org/rss/1.0/modules/content/',\n",
       "  '': 'http://www.w3.org/2005/Atom',\n",
       "  'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd',\n",
       "  'anchor': 'https://anchor.fm/xmlns'}}"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "feed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "143e0df2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6718e676",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "05a2f02a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b7115ef6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "459f9a00",
   "metadata": {},
   "source": [
    "## Playground"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "93ef42be",
   "metadata": {},
   "outputs": [],
   "source": [
    "DATA_DIR = \"/mnt/data-ssd-1/data/podcasts/cc_episodes/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "2601fe61",
   "metadata": {},
   "outputs": [],
   "source": [
    "license_df.to_csv(DATA_DIR + \"cc_episodes.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "id": "d4efa8a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# !mkdir /mnt/data-ssd-1/data/podcasts/cc_episodes/raw_audio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "102d0a88",
   "metadata": {},
   "outputs": [],
   "source": [
    "# !ls /mnt/data-ssd-1/data/podcasts/cc_episodes/raw_audio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1432bb1b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "3495it [29:35:33,  8.45s/it]   "
     ]
    }
   ],
   "source": [
    "import uuid\n",
    "\n",
    "uuids = []\n",
    "filenames = []\n",
    "for _, row in tqdm.tqdm(license_df.iterrows()):\n",
    "    episode_url = row[\"audio_uri\"]\n",
    "    if \"blip.tv\" in episode_url:\n",
    "        # site dead\n",
    "        # TODO: maybe go by date?\n",
    "        uuids.append(None)\n",
    "        filenames.append(None)\n",
    "        continue\n",
    "    try:\n",
    "        out = requests.get(episode_url, timeout=10)  # timeout only for inactive\n",
    "    except:\n",
    "        uuids.append(None)\n",
    "        filenames.append(None)\n",
    "        continue\n",
    "    if out.ok:\n",
    "        episode_id = str(uuid.uuid4())\n",
    "        file_ext = row[\"audio_uri\"].lower().split(\".\")[-1].split(\"?\")[0]\n",
    "        filename = f\"{episode_id}.{file_ext}\"\n",
    "        with open(f\"{DATA_DIR}raw_audio/{filename}\", \"wb\") as f:\n",
    "            f.write(out.content)\n",
    "        uuids.append(episode_id)\n",
    "        filenames.append(filename)\n",
    "    else:\n",
    "        uuids.append(None)\n",
    "        filenames.append(None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "02fbde73",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2706it\n",
    "# TODO: make sure this lines up :/ (some issues at 2601 plus minus)\n",
    "# TODO: maybe try to filter out music podcasts or too old podcasts from the get-go\n",
    "#   also shuffle, also max timeout for slow transfer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c452dff",
   "metadata": {},
   "outputs": [],
   "source": [
    "license_df[\"uuid\"] = uuids\n",
    "license_df[\"filepath\"] = filenames"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c345e670",
   "metadata": {},
   "outputs": [],
   "source": [
    "# !ls /mnt/data-ssd-1/data/podcasts/cc_episodes/raw_audio | wc -l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "83f442ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "license_df.to_csv(DATA_DIR + \"cc_episodes_dl.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85e8ddd2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# TODO how to filter music:\n",
    "# \"mix\" in episode title or summary\n",
    "# \"mix\" in podcast title\n",
    "# audio url for episode https://orionbreaks.jellycast.com\n",
    "# en-PI for podcast language"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ee18bbb4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49fe80e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "SORTED_SEARCH_TERMS = sorted(list(inv_country_alias_map.keys()), key=len, reverse=True)\n",
    "\n",
    "SEARCH_PTN = re.compile(\n",
    "    r\"\\b({})\\b\".format(r\"|\".join([re.escape(s) for s in SORTED_SEARCH_TERMS])), \n",
    ")\n",
    "\n",
    "def _search_podcast(filename):\n",
    "    rss_text = load_rss_text(RAW_RSS_DIR + filename)\n",
    "    podcast_title = get_rss_tag(\"title\", rss_text)\n",
    "    podcast_description = get_rss_tag(\"description\", rss_text)\n",
    "    search_text = podcast_title + \" \" + podcast_description\n",
    "    terms_found = set(SEARCH_PTN.findall(search_text))\n",
    "    # TODO: if we match multiple countries we punt but could be mistake\n",
    "    countries_found = []\n",
    "    for s in terms_found:\n",
    "        for c in inv_country_alias_map[s]:\n",
    "            countries_found.append(country_name_map[c])\n",
    "    countries_found = sorted(set(countries_found))\n",
    "    if len(countries_found) != 1:\n",
    "        return None\n",
    "    country_found = countries_found[0]\n",
    "    rss_feed = load_rss_feed(RAW_RSS_DIR + filename)\n",
    "    episode_url = get_latest_episode_url(rss_feed)\n",
    "    if episode_url is None:\n",
    "        return None\n",
    "    author_detail = rss_feed[\"feed\"].get(\"publisher_detail\", {})\n",
    "    author_name = author_detail.get(\"name\")\n",
    "    author_email = author_detail.get(\"email\")\n",
    "    if author_email is None:\n",
    "        return None\n",
    "    tags = set([e[\"term\"].lower() for e in rss_feed[\"feed\"].get(\"tags\", [])])\n",
    "    if \"music\" in tags:\n",
    "        return None\n",
    "    tag_str = \";\".join(sorted(tags))\n",
    "    podcast_id = int(filename.split(\".\")[0])\n",
    "    evidence = \";\".join(terms_found)\n",
    "    return (\n",
    "        podcast_id, podcast_title, podcast_description, country_found, evidence, episode_url, \n",
    "        tag_str, author_name, author_email,\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "75d05e3b",
   "metadata": {},
   "outputs": [],
   "source": [
    "english_rss_filenames = [fn for fn in os.listdir(RAW_RSS_DIR) if int(fn.split(\".\")[0]) in english_podcast_ids]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b2d09803",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "57dc19dc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9bf645d9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11e1c3e9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aa47c481",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
