{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sys.path.insert(0, '/Users/joel/src/thundr/tracker/')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from tracker import db, spotify"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from tracker.youtube import youtube\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "db.setup_session()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Engine(postgres://joel:***@localhost:5432/test)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "db.Session.rollback(); db.Session.get_bind()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "print(\n",
    "    \"\\n\".join([\n",
    "        r[0] for r in db.Session.execute(\n",
    "            \"\"\"select track_spyid from spy_playlist_track \n",
    "            where playlist_spyid = '1a5ECwY7KHnYSoAjOct2By'\n",
    "              and random() > 0.5 limit 5\"\"\"\n",
    "        ).fetchall()])\n",
    ")\n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This are the tracks we'll use."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ids = '''083EMqBFc5pcZiROFRuxA8\n",
    "0lJkyn1Cc0Udvb1TpHhUZN\n",
    "100LxoDRqtA3iH6GCz7X3e\n",
    "15Ks919VIFLlbw0rCXLTmO\n",
    "1cTzp1xs3ROQxMzIomSQOg'''.split()\n",
    "\n",
    "pd.read_sql_query(\n",
    "    '''select * from spy_tracks where spyid = any(array[\n",
    "'083EMqBFc5pcZiROFRuxA8',\n",
    "'0lJkyn1Cc0Udvb1TpHhUZN',\n",
    "'100LxoDRqtA3iH6GCz7X3e',\n",
    "'15Ks919VIFLlbw0rCXLTmO',\n",
    "'1cTzp1xs3ROQxMzIomSQOg'\n",
    "    ])''', \n",
    "    db.Session.get_bind(), \n",
    "    index_col='spyid'\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "tracks = db.Session.query(db.SpyTrack).filter(db.SpyTrack.spyid.in_(ids)).all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "names = [(t.name, t.data['artists'][0]['name']) for t in tracks]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "names = [('Swim', 'Loyal Lobos'),\n",
    " ('Más De Una', 'Jhay Cortez'),\n",
    " ('Hey Frank', 'Tangowhiskyman'),\n",
    " (\"Let's Go Home\", 'Foliage'),\n",
    " ('Zoroastro', 'Boris Vian')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "yt = youtube.setup_youtube()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_playlists_for_channel(channel_id):\n",
    "    yt = youtube.setup_youtube()\n",
    "    playlist_ids = set([r.get('id') for r in (\n",
    "        yt.playlists()\n",
    "        .list(channelId=channel_id, part='id', maxResults=20)\n",
    "        .execute().get('items') \n",
    "        or []\n",
    "    )])\n",
    "    channel_sections = (\n",
    "        yt.channelSections().list(channelId=channel_id, part='snippet,contentDetails').execute()\n",
    "    )\n",
    "\n",
    "    for section in (channel_sections.get('items') or []):\n",
    "        if (section.get('contentDetails') or {}).get('playlists'):\n",
    "            playlist_ids.update(section['contentDetails']['playlists'])\n",
    "    \n",
    "    return (\n",
    "        yt.playlists()\n",
    "        .list(id=\",\".join(playlist_ids), part='snippet,contentDetails,status', maxResults=20)\n",
    "        .execute().get('items') \n",
    "        or []\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [],
   "source": [
    "r = get_playlists_for_channel('UCUUNMri9GAoH2PiXCQJ6aWw')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('OLAK5uy_ld0Hq_aefGxdye9nQ0sPpsy_sI0Cpfzkk',\n",
       "  'Throne',\n",
       "  'youtube#playlist',\n",
       "  1,\n",
       "  'UCBR8-60-B28hp2BmDPdntcQ',\n",
       "  'YouTube Spotlight'),\n",
       " ('OLAK5uy_mWuwFYnA63J5zKq1Aro5sre8wh7SOdKtc',\n",
       "  'Raggamuffin',\n",
       "  'youtube#playlist',\n",
       "  1,\n",
       "  'UCBR8-60-B28hp2BmDPdntcQ',\n",
       "  'YouTube Spotlight'),\n",
       " ('PLUoJlD1Ntdn9poCnJgOXKj9qZvylVsanp',\n",
       "  'Music videos',\n",
       "  'youtube#playlist',\n",
       "  4,\n",
       "  'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "  'Koffee - Topic'),\n",
       " ('OLAK5uy_nSLxqPsLyrE-Dl-_CJjyBlGk7C4gCUPcw',\n",
       "  'Throne',\n",
       "  'youtube#playlist',\n",
       "  1,\n",
       "  'UCBR8-60-B28hp2BmDPdntcQ',\n",
       "  'YouTube Spotlight'),\n",
       " ('PLCVUuQDxFCSc07JHU7BQ2TK2Pgdl4OhtH',\n",
       "  'OFFICIAL VIDEOS',\n",
       "  'youtube#playlist',\n",
       "  2,\n",
       "  'UCUUNMri9GAoH2PiXCQJ6aWw',\n",
       "  'Original Koffee'),\n",
       " ('OLAK5uy_n4F_k7SccOYtTkgpFQb7hL8of0QG15Li8',\n",
       "  'Toast',\n",
       "  'youtube#playlist',\n",
       "  1,\n",
       "  'UCBR8-60-B28hp2BmDPdntcQ',\n",
       "  'YouTube Spotlight'),\n",
       " ('PLUoJlD1Ntdn_VE7cMffpOBX7LJGGTYnDY',\n",
       "  'Music videos',\n",
       "  'youtube#playlist',\n",
       "  4,\n",
       "  'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "  'Koffee - Topic')]"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[\n",
    "    (item['id'], item['snippet']['title'], item['kind'], item['contentDetails'].get('itemCount'), \n",
    "     item['snippet']['channelId'], item['snippet']['channelTitle']) \n",
    "    for item in r\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_videos = []\n",
    "for playlist in r:\n",
    "    items = yt.playlistItems().list(playlistId=playlist['id'], part=\"snippet\").execute().get('items') or []\n",
    "    all_videos.extend(items)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/sspDG-71nVHdcrF8nVlWnOnR42U\"',\n",
       "  'id': 'T0xBSzV1eV9sZDBIcV9hZWZHeGR5ZTluUTBzUHBzeV9zSTBDcGZ6a2suRDBBMEVGOTNEQ0U1NzQyQg==',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCBR8-60-B28hp2BmDPdntcQ',\n",
       "   'channelTitle': 'YouTube Spotlight',\n",
       "   'description': 'Provided to YouTube by Sony Music Entertainment\\n\\nThrone · Koffee\\n\\nThrone\\n\\n℗ 2019 Promised Land Recordings Limited\\n\\nReleased on: 2019-01-18\\n\\nComposer, Lyricist: Mikayla Simpson\\nArranger, Producer: Walshy Fire\\nArranger, Engineer, Producer: EchoSlim\\nProducer: Nicko Rebel\\nProducer: Sean Alaric\\nEngineer: Nicholas \"Nicko Rebel\" Davis\\nMixing  Engineer: Andre \\'Dre Day\\' Ennis\\nMastering  Engineer: Kevin Tuffy\\n\\nAuto-generated by YouTube.',\n",
       "   'playlistId': 'OLAK5uy_ld0Hq_aefGxdye9nQ0sPpsy_sI0Cpfzkk',\n",
       "   'position': 0,\n",
       "   'publishedAt': '2019-01-23T11:30:54.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'vMGDXkMivRc'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/vMGDXkMivRc/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/vMGDXkMivRc/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/vMGDXkMivRc/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/vMGDXkMivRc/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/vMGDXkMivRc/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Throne'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/5wAqQiQuR2ks_1hCJlEh1wtN2ec\"',\n",
       "  'id': 'T0xBSzV1eV9tV3V3RlluQTYzSjV6S3ExQXJvNXNyZTh3aDdTT2RLdGMuNUFGRkE2OTkxOEE0REFFOA==',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCBR8-60-B28hp2BmDPdntcQ',\n",
       "   'channelTitle': 'YouTube Spotlight',\n",
       "   'description': 'Provided to YouTube by Sony Music Entertainment\\n\\nRaggamuffin · Koffee\\n\\nRaggamuffin\\n\\n℗ 2018 Promised Land Recordings Limited\\n\\nReleased on: 2018-11-13\\n\\nLyricist: Mikayla Simpson\\nGuitar, Percussion, Composer, Lyricist: Comar Campbell\\nKeyboards, Composer: Shawn Allwood\\nBass, Drums, Composer, Engineer, Mixing  Engineer: Marlon Easy\\nProducer: Frankie Production Limited\\nMastering  Engineer: Kevin Metcalfe\\n\\nAuto-generated by YouTube.',\n",
       "   'playlistId': 'OLAK5uy_mWuwFYnA63J5zKq1Aro5sre8wh7SOdKtc',\n",
       "   'position': 0,\n",
       "   'publishedAt': '2019-01-17T17:05:45.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'sHEJEMvMi_Y'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/sHEJEMvMi_Y/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/sHEJEMvMi_Y/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/sHEJEMvMi_Y/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/sHEJEMvMi_Y/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/sHEJEMvMi_Y/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Raggamuffin'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/tA25GVS0B0CBU1LEOECtHKW3LI0\"',\n",
       "  'id': 'UExVb0psRDFOdGRuOXBvQ25KZ09YS2o5cVp2eWxWc2FucC4zQzFBN0RGNzNFREFCMjBE',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "   'channelTitle': 'Koffee - Topic',\n",
       "   'description': \"Koffee - Throne\\nListen to/download 'Throne' here: http://smarturl.it/KoffeeThrone?IQid=yt\\n\\n----------\\n\\nFollow Koffee\\nOfficial Site: http://originalkoffee.com\\nFacebook: https://www.facebook.com/originalkoffee\\nTwitter: https://twitter.com/originalkoffee\\nInstagram: https://www.instagram.com/originalkoffee/\\n\\n----------\\n\\nLyrics:\\n\\nWoah now\\nMe deh pon di go now\\nTell dem watch it ina traffic, Koffee nu slow down\\nIna mi zone\\nAlto to Baritone\\nSoon dem a go see seh is a Queen deh pon di Throne\\n\\nMe nu waste time with the music\\nIn yuh face like any cutip\\nUsed to Facetime with the Blues\\nTil Reggae bassline mek me lose it\\nA nu monopoly\\nWalshy build the riddim, put da song ya pon it\\nNow dem all up on me\\nSay dem badder dan me\\nSo me kill dem and study dem anatomy\\nDem nu understand me\\nBut dem\\nSeh dem loving the flow now\\nWhen them see me all over the media\\nAnd them hear me deh pon Wikipedia\\nUsed to fast, now me all a get speedier\\nI a born storm\\nFyah cyah calm\\nShotter than a copper, what a Bam Bam\\nTell Jenella, Cinderella, John, Tom\\n“Say a prayer, get a choir; ensemble”\\n\\nWoah now\\nMe deh pon di go now\\nTell dem watch it ina traffic, Koffee nu slow down\\nIna mi zone\\nAlto to Baritone\\nSoon dem a go see seh is a Queen deh pon di Throne\\n\\nWarning dem!\\n5 Star seh we warning dem!\\nIna night, ina morning\\nJah cover we like a awning den\\nMarch out and we storm in\\nAnd one people we forming\\n‘Cause the disparity alarming\\nRegarding the place wa we born in, woie!\\nFolks nu waa fi hear a next shot\\nRather Koffee tear a next track\\nGive it to them like a crusade\\nTell them we deh pon a new wave\\nUnu nuh see nutn yet tho\\nMi come wid di fyah, get low!\\nLyrics put your very welfare pon the death row \\nPon the wet floor!\\n\\nWoah now\\nMe deh pon di go now\\nTell dem watch it ina traffic, Koffee nu slow down\\nIna mi zone\\nAlto to Baritone\\nSoon dem a go see seh is a Queen deh pon di Throne\\n\\nCheck check check, new Day\\nBetter put the Koffee pon yuh checklist\\nNobody never did expect this\\nNow dem watching me, watching me like Netflix\\nNa leave them ina silence\\nDem a wait pon me fi bring the vibes\\nJamaican people, leave the violence!\\nCya read, well read between the lines!\\nWell mi hear seh the gun dem pile a Bay\\nAnd dem have dem ina wide array\\nHow them reach Spanish Town and all Mobay\\nHave them all a spray\\nWhile a child a play\\nTell some police da effort deh na go work\\nProtect the peace and Lowe the dawta skirt!\\nNeedlessly display them armor \\nThen a drape mi brother\\nBwoy drape yuh father shirt!\\n\\nWoah now\\nMe deh pon di go now\\nTell dem watch it ina traffic, Koffee nu slow down\\nIna mi zone\\nAlto to Baritone\\nSoon dem a go see seh is a Queen deh pon di Throne\",\n",
       "   'playlistId': 'PLUoJlD1Ntdn9poCnJgOXKj9qZvylVsanp',\n",
       "   'position': 0,\n",
       "   'publishedAt': '2019-01-23T15:20:07.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': '5V4ZDNV4si0'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Koffee - Throne (Official Video)'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/6ad-B5dJvDcm3ZKO3VRSZPxl_8E\"',\n",
       "  'id': 'UExVb0psRDFOdGRuOXBvQ25KZ09YS2o5cVp2eWxWc2FucC45NkVENTkxRDdCQUFBMDY4',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "   'channelTitle': 'Koffee - Topic',\n",
       "   'description': \"Koffee - Burning\\nListen to/download 'Burning' here: http://smarturl.it/K_Burning?IQid=yt\\n\\n----------\\n\\nFollow Koffee\\nOfficial Site: http://originalkoffee.com\\nFacebook: https://www.facebook.com/originalkoffee\\nTwitter: https://twitter.com/originalkoffee\\nInstagram: https://www.instagram.com/originalkoffee/\\n\\n----------\\n\\nLyrics:\\n\\n[chorus]\\nCome wid di fiyah, di city burning down\\nMe just a tun it up higher and keep it burning\\nIt a bun like a tire, me have a burning sound\\nAnd if me try fi retire, me leave dem yearning\\nNutn cyah out my flame\\nNo it cyah quench, cyah cool, cyah tame\\nAnd since the devil nuh like it, him seh fi turn it down \\nSo me just give him the fyah and mek it burn him\\n\\nv1\\nKoffee pon di street\\nTank top ina the heat\\nJeans pants and Crocs, no socks deh pon mi feet\\nKnapsack wa me a beat well pack up and it neat\\nStay woke, no sleep\\nMe no likkle Bo Peep\\nMoney pon mi mind, but me never have a coin\\nNah cuss, me just a hustle\\nFi di pretty dollar sign\\nA never nuff fun time\\nLife rough sometimes \\nBut me know me and mi mommy haffi see di sunshine!\\n\\n[chorus]\\nCome wid di fiyah, di city burning down\\nMe just a tun it up higher and keep it burning\\nIt a bun like a tire, me have a burning sound\\nAnd if me try fi retire, me leave dem yearning\\nNutn cyah out my flame\\nNo it cyah quench, cyah cool, cyah tame\\nAnd since the devil nuh like it, him seh fi turn it down \\nSo me just give him the fyah and mek it burn him\\n\\nv2\\nSee it yah\\nWa become of Peter?\\nMommy seh be Doctor\\nGranny say be Preacher\\nWant fi be a Rasta\\nDaddy say be neater\\nPeter neva like that\\nSo him take the streets sah!\\nBut everybody born with a talent we fi feature\\nBlessings in abundance\\nWa we fi cherish each of\\nNever be ungrateful\\nLife is such a teacher\\nKoffee pon Upsetta track\\nSee me bring the heat ya!\\n\\n[chorus]\\nCome wid di fiyah, di city burning down\\nMe just a tun it up higher and keep it burning\\nIt a bun like a tire, me have a burning sound\\nAnd if me try fi retire, me leave dem yearning\\nNutn cyah out my flame\\nNo it cyah quench, cyah cool, cyah tame\\nAnd since the devil nuh like it, him seh fi turn it down \\nSo me just give him the fyah and mek it burn him\\n\\nv3\\nRun up and down\\nHave them a run up and down\\nYeah a Koffee with the don sound\\nAnytime me come round\\nA madness pon the compound\\nMan a turn fool, a turn clown\\nBut Jah Jah cover mi journey, I beg yuh guide it\\nAnd any trouble me see, help me avoid it\\nMi know seh anything me need, God will provide it\\nAnywhere still water deh, Him lead me beside it\\n\\n[chorus]\\nCome wid di fiyah, di city burning down\\nMe just a tun it up higher and keep it burning\\nIt a bun like a tire, me have a burning sound\\nAnd if me try fi retire, me leave dem yearning\\nNutn cyah out my flame\\nNo it cyah quench, cyah cool, cyah tame\\nAnd since the devil nuh like it, him seh fi turn it down \\nSo me just give him the fyah and mek it burn him\",\n",
       "   'playlistId': 'PLUoJlD1Ntdn9poCnJgOXKj9qZvylVsanp',\n",
       "   'position': 1,\n",
       "   'publishedAt': '2019-01-23T15:20:07.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'f5_xCnwz-fA'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/f5_xCnwz-fA/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/f5_xCnwz-fA/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/f5_xCnwz-fA/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/f5_xCnwz-fA/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/f5_xCnwz-fA/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Koffee - Burning (Audio)'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/0CZVLgxDJ2srQZFx4-IVv97gOmI\"',\n",
       "  'id': 'UExVb0psRDFOdGRuOXBvQ25KZ09YS2o5cVp2eWxWc2FucC5DNkMwRUI2MkI4QkI4NDFG',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "   'channelTitle': 'Koffee - Topic',\n",
       "   'description': 'Music video by Koffee performing Raggamuffin (Audio). (C) 2018 Sony Music Entertainment UK Limited\\n\\nhttp://vevo.ly/1hDzjV',\n",
       "   'playlistId': 'PLUoJlD1Ntdn9poCnJgOXKj9qZvylVsanp',\n",
       "   'position': 2,\n",
       "   'publishedAt': '2019-01-23T15:20:07.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': '4HSO9YtEAyA'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/4HSO9YtEAyA/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/4HSO9YtEAyA/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/4HSO9YtEAyA/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/4HSO9YtEAyA/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/4HSO9YtEAyA/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Koffee - Raggamuffin (Audio)'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/EaaGyKhjlkjlipO78q1GdgDCWP8\"',\n",
       "  'id': 'UExVb0psRDFOdGRuOXBvQ25KZ09YS2o5cVp2eWxWc2FucC5DRUQwODMxQzUyRTlGRkY3',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "   'channelTitle': 'Koffee - Topic',\n",
       "   'description': \"Koffee - Toast \\nListen to/download 'Toast' here: http://smarturl.it/KoffeeToast?IQid=yt\\n\\n----------\\n\\nFollow Koffee\\nOfficial Site: http://originalkoffee.com\\nFacebook: https://www.facebook.com/originalkoffee\\nTwitter: https://twitter.com/originalkoffee\\nInstagram: https://www.instagram.com/originalkoffee/\\n\\n----------\\n\\nLyrics:\\n\\nToast\\nSeh we a come in wid a force\\nBlessings we a reap pon wi course\\nIna handful\\nWe nuh rise and boast\\nYeah we give thanks like we need it the most\\nHafi give thanks like we really supposed \\nTo be thankful \\n\\n[chorus]\\nBlessings all pon mi life and, \\nMe Thank God fi di journey, di earnings a just fi di plus\\nGratitude is a must\\nMe see Blessings fall by mi right hand\\nToast to di friends weh tek off heavy load\\nOne time did sit down ina class and we bored\\nDen Oli seh do road and mi gwaan wid di road\\n\\nThird form mi seh mek mi try a ting\\nAnd yuh know it formed out to be a fiyah ting\\nNow a pon stage wid Chronixx I a sing\\nYeah Yuh Zimme all Diggy soon gi di I a ring\\nLike Hello Proto\\nHim seh “Had to shout yuh\\nSaw you post a spectacular photo\\nKeep it burning, yes that’s the motto\\nIf me deh bout I pass through your show too”\\n\\n[chorus]\\nCya bawl ina life man!\\nHaffi thank God fi di journey, di earnings a just fi di plus\\nGratitude is a must\\nMe see Blessings fall by mi right hand\\nToast to di friends weh tek off heavy load\\nFrom we did sit down ina class and we bored\\nTil Oli seh do road and mi gwaan wid di, mi gwaan wid di\\n\\n\\nJah shower blessings upon me\\nAnd seh mi fi tell yuh mi story\\nJah shower blessings upon me\\nThat’s why mi deh give Him the glory\\nMi delighted\\nJah know seh me passion ignited\\nCause the music get me excited\\nCome in like a potion\\n\\n[chorus]\\nBlessings all pon mi life and, \\nMe Thank God fi di journey, di earnings a just fi di plus\\nGratitude is a must\\nMe see Blessings fall by mi right hand\\nToast to di friends weh tek off heavy load\\nOne time did sit down ina class and we bored\\nDen Oli seh do road and mi gwaan wid di road\",\n",
       "   'playlistId': 'PLUoJlD1Ntdn9poCnJgOXKj9qZvylVsanp',\n",
       "   'position': 3,\n",
       "   'publishedAt': '2019-01-23T15:20:07.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'p8HoEvDh70Y'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Koffee - Toast (Official Video)'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/JLB-nXik2aT09Jiz6PIx6sV_EZY\"',\n",
       "  'id': 'T0xBSzV1eV9uU0x4cVBzTHlyRS1EbC1fQ0pqeUJsR2s3QzRnQ1VQY3cuNDc2QjBEQzI1RDdERUU4QQ==',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCBR8-60-B28hp2BmDPdntcQ',\n",
       "   'channelTitle': 'YouTube Spotlight',\n",
       "   'description': 'Provided to YouTube by TuneCore Japan\\n\\nTHRONE · KOFFEE\\n\\nTHRONE\\n\\n℗ 2019 KOFFEE MUSIC\\n\\nReleased on: 2019-01-22\\n\\nLyricist: Mikayla Victoria Simpson\\nComposer: Mikayla Victoria Simpson\\n\\nAuto-generated by YouTube.',\n",
       "   'playlistId': 'OLAK5uy_nSLxqPsLyrE-Dl-_CJjyBlGk7C4gCUPcw',\n",
       "   'position': 0,\n",
       "   'publishedAt': '2019-01-31T18:53:41.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'yX92xwsjMcU'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'THRONE'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/24WgQmgNn90fOkQWcmRwVUwoQac\"',\n",
       "  'id': 'UExDVlV1UUR4RkNTYzA3SkhVN0JRMlRLMlBnZGw0T2h0SC41NkI0NEY2RDEwNTU3Q0M2',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCUUNMri9GAoH2PiXCQJ6aWw',\n",
       "   'channelTitle': 'Original Koffee',\n",
       "   'description': \"Koffee - Throne\\nListen to/download 'Throne' here: http://smarturl.it/KoffeeThrone?IQid=yt\\n\\n----------\\n\\nFollow Koffee\\nOfficial Site: http://originalkoffee.com\\nFacebook: https://www.facebook.com/originalkoffee\\nTwitter: https://twitter.com/originalkoffee\\nInstagram: https://www.instagram.com/originalkoffee/\\n\\n----------\\n\\nLyrics:\\n\\nWoah now\\nMe deh pon di go now\\nTell dem watch it ina traffic, Koffee nu slow down\\nIna mi zone\\nAlto to Baritone\\nSoon dem a go see seh is a Queen deh pon di Throne\\n\\nMe nu waste time with the music\\nIn yuh face like any cutip\\nUsed to Facetime with the Blues\\nTil Reggae bassline mek me lose it\\nA nu monopoly\\nWalshy build the riddim, put da song ya pon it\\nNow dem all up on me\\nSay dem badder dan me\\nSo me kill dem and study dem anatomy\\nDem nu understand me\\nBut dem\\nSeh dem loving the flow now\\nWhen them see me all over the media\\nAnd them hear me deh pon Wikipedia\\nUsed to fast, now me all a get speedier\\nI a born storm\\nFyah cyah calm\\nShotter than a copper, what a Bam Bam\\nTell Jenella, Cinderella, John, Tom\\n“Say a prayer, get a choir; ensemble”\\n\\nWoah now\\nMe deh pon di go now\\nTell dem watch it ina traffic, Koffee nu slow down\\nIna mi zone\\nAlto to Baritone\\nSoon dem a go see seh is a Queen deh pon di Throne\\n\\nWarning dem!\\n5 Star seh we warning dem!\\nIna night, ina morning\\nJah cover we like a awning den\\nMarch out and we storm in\\nAnd one people we forming\\n‘Cause the disparity alarming\\nRegarding the place wa we born in, woie!\\nFolks nu waa fi hear a next shot\\nRather Koffee tear a next track\\nGive it to them like a crusade\\nTell them we deh pon a new wave\\nUnu nuh see nutn yet tho\\nMi come wid di fyah, get low!\\nLyrics put your very welfare pon the death row \\nPon the wet floor!\\n\\nWoah now\\nMe deh pon di go now\\nTell dem watch it ina traffic, Koffee nu slow down\\nIna mi zone\\nAlto to Baritone\\nSoon dem a go see seh is a Queen deh pon di Throne\\n\\nCheck check check, new Day\\nBetter put the Koffee pon yuh checklist\\nNobody never did expect this\\nNow dem watching me, watching me like Netflix\\nNa leave them ina silence\\nDem a wait pon me fi bring the vibes\\nJamaican people, leave the violence!\\nCya read, well read between the lines!\\nWell mi hear seh the gun dem pile a Bay\\nAnd dem have dem ina wide array\\nHow them reach Spanish Town and all Mobay\\nHave them all a spray\\nWhile a child a play\\nTell some police da effort deh na go work\\nProtect the peace and Lowe the dawta skirt!\\nNeedlessly display them armor \\nThen a drape mi brother\\nBwoy drape yuh father shirt!\\n\\nWoah now\\nMe deh pon di go now\\nTell dem watch it ina traffic, Koffee nu slow down\\nIna mi zone\\nAlto to Baritone\\nSoon dem a go see seh is a Queen deh pon di Throne\",\n",
       "   'playlistId': 'PLCVUuQDxFCSc07JHU7BQ2TK2Pgdl4OhtH',\n",
       "   'position': 0,\n",
       "   'publishedAt': '2019-01-30T18:15:41.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': '5V4ZDNV4si0'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/5V4ZDNV4si0/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Koffee - Throne (Official Video)'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/kRG-xbgcBe8AxXqpunfKUj8lfRM\"',\n",
       "  'id': 'UExDVlV1UUR4RkNTYzA3SkhVN0JRMlRLMlBnZGw0T2h0SC4yODlGNEE0NkRGMEEzMEQy',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCUUNMri9GAoH2PiXCQJ6aWw',\n",
       "   'channelTitle': 'Original Koffee',\n",
       "   'description': \"Koffee - Toast \\nListen to/download 'Toast' here: http://smarturl.it/KoffeeToast?IQid=yt\\n\\n----------\\n\\nFollow Koffee\\nOfficial Site: http://originalkoffee.com\\nFacebook: https://www.facebook.com/originalkoffee\\nTwitter: https://twitter.com/originalkoffee\\nInstagram: https://www.instagram.com/originalkoffee/\\n\\n----------\\n\\nLyrics:\\n\\nToast\\nSeh we a come in wid a force\\nBlessings we a reap pon wi course\\nIna handful\\nWe nuh rise and boast\\nYeah we give thanks like we need it the most\\nHafi give thanks like we really supposed \\nTo be thankful \\n\\n[chorus]\\nBlessings all pon mi life and, \\nMe Thank God fi di journey, di earnings a just fi di plus\\nGratitude is a must\\nMe see Blessings fall by mi right hand\\nToast to di friends weh tek off heavy load\\nOne time did sit down ina class and we bored\\nDen Oli seh do road and mi gwaan wid di road\\n\\nThird form mi seh mek mi try a ting\\nAnd yuh know it formed out to be a fiyah ting\\nNow a pon stage wid Chronixx I a sing\\nYeah Yuh Zimme all Diggy soon gi di I a ring\\nLike Hello Proto\\nHim seh “Had to shout yuh\\nSaw you post a spectacular photo\\nKeep it burning, yes that’s the motto\\nIf me deh bout I pass through your show too”\\n\\n[chorus]\\nCya bawl ina life man!\\nHaffi thank God fi di journey, di earnings a just fi di plus\\nGratitude is a must\\nMe see Blessings fall by mi right hand\\nToast to di friends weh tek off heavy load\\nFrom we did sit down ina class and we bored\\nTil Oli seh do road and mi gwaan wid di, mi gwaan wid di\\n\\n\\nJah shower blessings upon me\\nAnd seh mi fi tell yuh mi story\\nJah shower blessings upon me\\nThat’s why mi deh give Him the glory\\nMi delighted\\nJah know seh me passion ignited\\nCause the music get me excited\\nCome in like a potion\\n\\n[chorus]\\nBlessings all pon mi life and, \\nMe Thank God fi di journey, di earnings a just fi di plus\\nGratitude is a must\\nMe see Blessings fall by mi right hand\\nToast to di friends weh tek off heavy load\\nOne time did sit down ina class and we bored\\nDen Oli seh do road and mi gwaan wid di road\",\n",
       "   'playlistId': 'PLCVUuQDxFCSc07JHU7BQ2TK2Pgdl4OhtH',\n",
       "   'position': 1,\n",
       "   'publishedAt': '2019-01-30T18:16:10.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'p8HoEvDh70Y'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/p8HoEvDh70Y/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Koffee - Toast (Official Video)'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/g9OmICF_LqnT8VFjXqww-lHCvlE\"',\n",
       "  'id': 'T0xBSzV1eV9uNEZfazdTY2NPWXRUa2dwRlFiN2hMOG9mMFFHMTVMaTguOTQ5NURGRDc4RDM1OTA0Mw==',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCBR8-60-B28hp2BmDPdntcQ',\n",
       "   'channelTitle': 'YouTube Spotlight',\n",
       "   'description': \"Provided to YouTube by Sony Music Entertainment\\n\\nToast · Koffee\\n\\nToast\\n\\n℗ 2018 Promised Land Recordings Limited\\n\\nComposer, Lyricist: Mikayla Simpson\\nArranger, Engineer, Producer: IzyBeats\\nProducer: Walshy Fire\\nMixing  Engineer: Andre 'Dre Day' Ennis\\nMastering  Engineer: Kevin Metcalfe\\n\\nAuto-generated by YouTube.\",\n",
       "   'playlistId': 'OLAK5uy_n4F_k7SccOYtTkgpFQb7hL8of0QG15Li8',\n",
       "   'position': 0,\n",
       "   'publishedAt': '2018-12-12T22:38:36.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'eGHAX3c4n8s'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/eGHAX3c4n8s/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/eGHAX3c4n8s/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/eGHAX3c4n8s/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/eGHAX3c4n8s/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/eGHAX3c4n8s/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Toast'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/F5yZqH3vLFrHcKALVoSes_yAY94\"',\n",
       "  'id': 'UExVb0psRDFOdGRuX1ZFN2NNZmZwT0JYN0xKR0dUWW5EWS5CMTk0M0ExREZBODAzNDUw',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "   'channelTitle': 'Koffee - Topic',\n",
       "   'description': 'Provided to YouTube by TuneCore Japan\\n\\nToast · KOFFEE\\n\\nToast\\n\\n℗ 2018 KOFFEE MUSIC\\n\\nReleased on: 2018-11-30\\n\\nLyricist: Mikayla Victoria Simpson\\nComposer: Mikayla Victoria Simpson\\n\\nAuto-generated by YouTube.',\n",
       "   'playlistId': 'PLUoJlD1Ntdn_VE7cMffpOBX7LJGGTYnDY',\n",
       "   'position': 0,\n",
       "   'publishedAt': '2019-02-08T21:36:41.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'ij0ydYU_3P4'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/ij0ydYU_3P4/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/ij0ydYU_3P4/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/ij0ydYU_3P4/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/ij0ydYU_3P4/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/ij0ydYU_3P4/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Toast'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/djhFa7pjqzgG60EHE3VrYQvdsFQ\"',\n",
       "  'id': 'UExVb0psRDFOdGRuX1ZFN2NNZmZwT0JYN0xKR0dUWW5EWS4wRjA0RDE2QTUwMTk2MkY2',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "   'channelTitle': 'Koffee - Topic',\n",
       "   'description': 'My name is Mikayla \"Koffee\" Simpson and this is my debut single Burning, produced by Upsetta Records, directed by Ifidel Williams and filmed by Roe Summerz.\\n\\nPurchase the Ouji Riddim here: https://itunes.apple.com/us/album/ouji-riddim/id1290013610',\n",
       "   'playlistId': 'PLUoJlD1Ntdn_VE7cMffpOBX7LJGGTYnDY',\n",
       "   'position': 1,\n",
       "   'publishedAt': '2019-02-08T21:36:41.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'ySXe2p0daQk'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/ySXe2p0daQk/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/ySXe2p0daQk/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/ySXe2p0daQk/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/ySXe2p0daQk/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/ySXe2p0daQk/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'Koffee - BURNING Official Video [Ouji Riddim]'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/wX7h3sn_mJinGrsvxQji7bvI9WU\"',\n",
       "  'id': 'UExVb0psRDFOdGRuX1ZFN2NNZmZwT0JYN0xKR0dUWW5EWS4wOEE0NEE4QTk1RTc0MUJB',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "   'channelTitle': 'Koffee - Topic',\n",
       "   'description': 'Artist: ORIGINAL KOFFEE\\nProducer: FRANKIE MUSIC\\nDistributor: VPAL \\nSmart URL: http://smarturl.it/KoffeeRaggamuffin',\n",
       "   'playlistId': 'PLUoJlD1Ntdn_VE7cMffpOBX7LJGGTYnDY',\n",
       "   'position': 2,\n",
       "   'publishedAt': '2019-02-08T21:36:41.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': '6WoIsraFfQQ'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/6WoIsraFfQQ/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/6WoIsraFfQQ/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/6WoIsraFfQQ/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/6WoIsraFfQQ/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/6WoIsraFfQQ/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'RAGGAMUFFIN - ORIGINAL KOFFEE - OFFICIAL AUDIO'}},\n",
       " {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/1Tuc13WpvHJXnkavwsSoUr6ISRg\"',\n",
       "  'id': 'UExVb0psRDFOdGRuX1ZFN2NNZmZwT0JYN0xKR0dUWW5EWS4yNjFFMzVEMkVDRTRDOEMz',\n",
       "  'kind': 'youtube#playlistItem',\n",
       "  'snippet': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "   'channelTitle': 'Koffee - Topic',\n",
       "   'description': 'Provided to YouTube by TuneCore Japan\\n\\nTHRONE · KOFFEE\\n\\nTHRONE\\n\\n℗ 2019 KOFFEE MUSIC\\n\\nReleased on: 2019-01-22\\n\\nLyricist: Mikayla Victoria Simpson\\nComposer: Mikayla Victoria Simpson\\n\\nAuto-generated by YouTube.',\n",
       "   'playlistId': 'PLUoJlD1Ntdn_VE7cMffpOBX7LJGGTYnDY',\n",
       "   'position': 3,\n",
       "   'publishedAt': '2019-02-08T21:36:41.000Z',\n",
       "   'resourceId': {'kind': 'youtube#video', 'videoId': 'yX92xwsjMcU'},\n",
       "   'thumbnails': {'default': {'height': 90,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/default.jpg',\n",
       "     'width': 120},\n",
       "    'high': {'height': 360,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/hqdefault.jpg',\n",
       "     'width': 480},\n",
       "    'maxres': {'height': 720,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/maxresdefault.jpg',\n",
       "     'width': 1280},\n",
       "    'medium': {'height': 180,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/mqdefault.jpg',\n",
       "     'width': 320},\n",
       "    'standard': {'height': 480,\n",
       "     'url': 'https://i.ytimg.com/vi/yX92xwsjMcU/sddefault.jpg',\n",
       "     'width': 640}},\n",
       "   'title': 'THRONE'}}]"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_videos"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [],
   "source": [
    "mapped = {v['id']: v for v in all_videos}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Throne',\n",
       " 'Raggamuffin',\n",
       " 'Koffee - Throne (Official Video)',\n",
       " 'Koffee - Burning (Audio)',\n",
       " 'Koffee - Raggamuffin (Audio)',\n",
       " 'Koffee - Toast (Official Video)',\n",
       " 'THRONE',\n",
       " 'Koffee - Throne (Official Video)',\n",
       " 'Koffee - Toast (Official Video)',\n",
       " 'Toast',\n",
       " 'Toast',\n",
       " 'Koffee - BURNING Official Video [Ouji Riddim]',\n",
       " 'RAGGAMUFFIN - ORIGINAL KOFFEE - OFFICIAL AUDIO',\n",
       " 'THRONE']"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[v['snippet']['title'] for v in all_videos]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "r1 = yt.channelSections().list(channelId='UCbNNpH4gB4Nu-imqMDysWiw', part='snippet,contentDetails').execute()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/0UCiZ7zaat0z7LSFlugmXHXUGEM\"',\n",
       " 'items': [{'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/OrqLHjPdTrRjI1uTMd_odww6LCY\"',\n",
       "   'id': 'UExjT1U3eElFTkhoU1M3ZlpCbVRwdDFuQjdyRENFcjB3VC43RjgyNkZCNjkwMkZDMzcz',\n",
       "   'kind': 'youtube#playlistItem',\n",
       "   'snippet': {'channelId': 'UChGKzv70GtmPC8AKRzODJkw',\n",
       "    'channelTitle': 'Elley Duhé - Topic',\n",
       "    'description': 'Elley Duhé\\'s \"Immortal\" - Available Now!\\nApple Music: http://smarturl.it/iImmortal?IQid=yt\\nSpotify: http://smarturl.it/spImmortal?IQid=yt\\nAmazon Music: http://smarturl.it/azImmortal?IQid=yt\\nGoogle Play: http://smarturl.it/gpImmortal?IQid=yt\\n\\nFollowElley Duhé:\\nhttps://www.facebook.com/elleyduhemusic/\\nhttps://twitter.com/elleyduhe\\nhttps://www.instagram.com/elleyduhe/\\nhttps://soundcloud.com/elleyduhe',\n",
       "    'playlistId': 'PLcOU7xIENHhSS7fZBmTpt1nB7rDCEr0wT',\n",
       "    'position': 0,\n",
       "    'publishedAt': '2019-02-10T02:12:50.000Z',\n",
       "    'resourceId': {'kind': 'youtube#video', 'videoId': 'Jfk6-lZUUvQ'},\n",
       "    'thumbnails': {'default': {'height': 90,\n",
       "      'url': 'https://i.ytimg.com/vi/Jfk6-lZUUvQ/default.jpg',\n",
       "      'width': 120},\n",
       "     'high': {'height': 360,\n",
       "      'url': 'https://i.ytimg.com/vi/Jfk6-lZUUvQ/hqdefault.jpg',\n",
       "      'width': 480},\n",
       "     'maxres': {'height': 720,\n",
       "      'url': 'https://i.ytimg.com/vi/Jfk6-lZUUvQ/maxresdefault.jpg',\n",
       "      'width': 1280},\n",
       "     'medium': {'height': 180,\n",
       "      'url': 'https://i.ytimg.com/vi/Jfk6-lZUUvQ/mqdefault.jpg',\n",
       "      'width': 320},\n",
       "     'standard': {'height': 480,\n",
       "      'url': 'https://i.ytimg.com/vi/Jfk6-lZUUvQ/sddefault.jpg',\n",
       "      'width': 640}},\n",
       "    'title': 'Elley Duhé - immortal (Audio)'}},\n",
       "  {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/xQa-ChyjgtPIZF9ZpC-iICRNDZQ\"',\n",
       "   'id': 'UExjT1U3eElFTkhoU1M3ZlpCbVRwdDFuQjdyRENFcjB3VC5FRUEzOUYxQTE4OEIyMTI3',\n",
       "   'kind': 'youtube#playlistItem',\n",
       "   'snippet': {'channelId': 'UChGKzv70GtmPC8AKRzODJkw',\n",
       "    'channelTitle': 'Elley Duhé - Topic',\n",
       "    'description': 'Music video by Elley Duhé performing COUNTERFEIT (Audio). (C) 2018 A Creative Music Group, Inc./RCA Records\\n\\nhttp://vevo.ly/VEdgY1',\n",
       "    'playlistId': 'PLcOU7xIENHhSS7fZBmTpt1nB7rDCEr0wT',\n",
       "    'position': 1,\n",
       "    'publishedAt': '2019-02-10T02:12:50.000Z',\n",
       "    'resourceId': {'kind': 'youtube#video', 'videoId': 'BdYMU64HwbA'},\n",
       "    'thumbnails': {'default': {'height': 90,\n",
       "      'url': 'https://i.ytimg.com/vi/BdYMU64HwbA/default.jpg',\n",
       "      'width': 120},\n",
       "     'high': {'height': 360,\n",
       "      'url': 'https://i.ytimg.com/vi/BdYMU64HwbA/hqdefault.jpg',\n",
       "      'width': 480},\n",
       "     'maxres': {'height': 720,\n",
       "      'url': 'https://i.ytimg.com/vi/BdYMU64HwbA/maxresdefault.jpg',\n",
       "      'width': 1280},\n",
       "     'medium': {'height': 180,\n",
       "      'url': 'https://i.ytimg.com/vi/BdYMU64HwbA/mqdefault.jpg',\n",
       "      'width': 320},\n",
       "     'standard': {'height': 480,\n",
       "      'url': 'https://i.ytimg.com/vi/BdYMU64HwbA/sddefault.jpg',\n",
       "      'width': 640}},\n",
       "    'title': 'Elley Duhé - COUNTERFEIT (Audio)'}},\n",
       "  {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/-ww98ypBf2I7koYlD_p6TAxreCY\"',\n",
       "   'id': 'UExjT1U3eElFTkhoU1M3ZlpCbVRwdDFuQjdyRENFcjB3VC5GMzY4RDIwMjU1MkMwOTRB',\n",
       "   'kind': 'youtube#playlistItem',\n",
       "   'snippet': {'channelId': 'UChGKzv70GtmPC8AKRzODJkw',\n",
       "    'channelTitle': 'Elley Duhé - Topic',\n",
       "    'description': \"'DRAGON MENTALITY' out now!: http://smarturl.it/DRGNMNTLY\\n\\nItunes: http://smarturl.it/DRGNMNTLY/itunes\\nApple Music: http://smarturl.it/DRGNMNTLY/applemusic\\nSpotify: http://smarturl.it/DRGNMNTLY/spotify\\nGoogle Play: http://smarturl.it/DRGNMNTLY/googleplay\\nAmazon: http://smarturl.it/DRGNMNTLY/az\\nDeezer: http://smarturl.it/DRGNMNTLY/deezer\\nSoundCloud: http://smarturl.it/DRGNMNTLY/soundcloud\\n\\nFollow Elley Duhé:\\nhttps://www.facebook.com/elleyduhemusic/\\nhttps://twitter.com/elleyduhe\\nhttps://www.instagram.com/elleyduhe/ \\nhttps://soundcloud.com/elleyduhe\\nhttp://www.elleyduhe.com/\",\n",
       "    'playlistId': 'PLcOU7xIENHhSS7fZBmTpt1nB7rDCEr0wT',\n",
       "    'position': 2,\n",
       "    'publishedAt': '2019-02-10T02:12:50.000Z',\n",
       "    'resourceId': {'kind': 'youtube#video', 'videoId': 'hNitk3e3rDc'},\n",
       "    'thumbnails': {'default': {'height': 90,\n",
       "      'url': 'https://i.ytimg.com/vi/hNitk3e3rDc/default.jpg',\n",
       "      'width': 120},\n",
       "     'high': {'height': 360,\n",
       "      'url': 'https://i.ytimg.com/vi/hNitk3e3rDc/hqdefault.jpg',\n",
       "      'width': 480},\n",
       "     'maxres': {'height': 720,\n",
       "      'url': 'https://i.ytimg.com/vi/hNitk3e3rDc/maxresdefault.jpg',\n",
       "      'width': 1280},\n",
       "     'medium': {'height': 180,\n",
       "      'url': 'https://i.ytimg.com/vi/hNitk3e3rDc/mqdefault.jpg',\n",
       "      'width': 320},\n",
       "     'standard': {'height': 480,\n",
       "      'url': 'https://i.ytimg.com/vi/hNitk3e3rDc/sddefault.jpg',\n",
       "      'width': 640}},\n",
       "    'title': 'Elley Duhé - FEVER (Official Video)'}},\n",
       "  {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/fLjB1cXG3KVE48vIkppGeF-Gt8E\"',\n",
       "   'id': 'UExjT1U3eElFTkhoU1M3ZlpCbVRwdDFuQjdyRENFcjB3VC5FN0MwOEIwNDJFMDI5RDhB',\n",
       "   'kind': 'youtube#playlistItem',\n",
       "   'snippet': {'channelId': 'UChGKzv70GtmPC8AKRzODJkw',\n",
       "    'channelTitle': 'Elley Duhé - Topic',\n",
       "    'description': 'Multi:  http://smarturl.it/elostmm/\\n \\nApple Music: http://smarturl.it/elostmm/applemusic\\nYoutube: http://smarturl.it/elostmm/youtube\\nItunes: http://smarturl.it/elostmm/itunes\\nSpotify: http://smarturl.it/elostmm/spotify\\nAmazon Music: http://smarturl.it/elostmm/az\\nGoogle Play:  http://smarturl.it/elostmm/googleplay\\nSound Cloud: http://smarturl.it/elostmm/soundcloud\\n \\nFollow Elley Duhé:\\nhttps://www.facebook.com/elleyduhemusic/\\nhttps://twitter.com/elleyduhe\\nhttps://www.instagram.com/elleyduhe/ \\nhttps://soundcloud.com/elleyduhe\\nhttp://www.elleyduhe.com/',\n",
       "    'playlistId': 'PLcOU7xIENHhSS7fZBmTpt1nB7rDCEr0wT',\n",
       "    'position': 3,\n",
       "    'publishedAt': '2019-02-10T02:12:50.000Z',\n",
       "    'resourceId': {'kind': 'youtube#video', 'videoId': 'MCFxNuXNZok'},\n",
       "    'thumbnails': {'default': {'height': 90,\n",
       "      'url': 'https://i.ytimg.com/vi/MCFxNuXNZok/default.jpg',\n",
       "      'width': 120},\n",
       "     'high': {'height': 360,\n",
       "      'url': 'https://i.ytimg.com/vi/MCFxNuXNZok/hqdefault.jpg',\n",
       "      'width': 480},\n",
       "     'maxres': {'height': 720,\n",
       "      'url': 'https://i.ytimg.com/vi/MCFxNuXNZok/maxresdefault.jpg',\n",
       "      'width': 1280},\n",
       "     'medium': {'height': 180,\n",
       "      'url': 'https://i.ytimg.com/vi/MCFxNuXNZok/mqdefault.jpg',\n",
       "      'width': 320},\n",
       "     'standard': {'height': 480,\n",
       "      'url': 'https://i.ytimg.com/vi/MCFxNuXNZok/sddefault.jpg',\n",
       "      'width': 640}},\n",
       "    'title': 'Elley Duhé - LOST MY MIND (Audio)'}},\n",
       "  {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/BKfcz20nXzWk5LbCQjgLoxUcIfo\"',\n",
       "   'id': 'UExjT1U3eElFTkhoU1M3ZlpCbVRwdDFuQjdyRENFcjB3VC4yQUYyOTAwNjkwNDE5QjlE',\n",
       "   'kind': 'youtube#playlistItem',\n",
       "   'snippet': {'channelId': 'UChGKzv70GtmPC8AKRzODJkw',\n",
       "    'channelTitle': 'Elley Duhé - Topic',\n",
       "    'description': 'Music video by Tarro, Elley Duhé performing Millennium. (C) 2017 A Creative Music Group, Inc./RCA Records\\n\\nhttp://vevo.ly/oDF609',\n",
       "    'playlistId': 'PLcOU7xIENHhSS7fZBmTpt1nB7rDCEr0wT',\n",
       "    'position': 4,\n",
       "    'publishedAt': '2019-02-10T02:12:50.000Z',\n",
       "    'resourceId': {'kind': 'youtube#video', 'videoId': 'vvZoK0qrISs'},\n",
       "    'thumbnails': {'default': {'height': 90,\n",
       "      'url': 'https://i.ytimg.com/vi/vvZoK0qrISs/default.jpg',\n",
       "      'width': 120},\n",
       "     'high': {'height': 360,\n",
       "      'url': 'https://i.ytimg.com/vi/vvZoK0qrISs/hqdefault.jpg',\n",
       "      'width': 480},\n",
       "     'maxres': {'height': 720,\n",
       "      'url': 'https://i.ytimg.com/vi/vvZoK0qrISs/maxresdefault.jpg',\n",
       "      'width': 1280},\n",
       "     'medium': {'height': 180,\n",
       "      'url': 'https://i.ytimg.com/vi/vvZoK0qrISs/mqdefault.jpg',\n",
       "      'width': 320},\n",
       "     'standard': {'height': 480,\n",
       "      'url': 'https://i.ytimg.com/vi/vvZoK0qrISs/sddefault.jpg',\n",
       "      'width': 640}},\n",
       "    'title': 'Tarro & Elley Duhé - Millennium (Audio)'}}],\n",
       " 'kind': 'youtube#playlistItemListResponse',\n",
       " 'nextPageToken': 'CAUQAA',\n",
       " 'pageInfo': {'resultsPerPage': 5, 'totalResults': 12}}"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "yt.playlistItems().list(playlistId='PLcOU7xIENHhSS7fZBmTpt1nB7rDCEr0wT', part='snippet').execute()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [],
   "source": [
    "chansearch = yt.search().list(q='koffee music', type='channel', part='snippet', topicId='/m/04rlf').execute()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/qcm_mV8CfUu4tzMwjjJVG_mSeIU\"',\n",
       " 'items': [{'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/A7BGcBFGWVbI6RqOBhblcOko1GM\"',\n",
       "   'id': {'channelId': 'UCUUNMri9GAoH2PiXCQJ6aWw', 'kind': 'youtube#channel'},\n",
       "   'kind': 'youtube#searchResult',\n",
       "   'snippet': {'channelId': 'UCUUNMri9GAoH2PiXCQJ6aWw',\n",
       "    'channelTitle': 'Original Koffee',\n",
       "    'description': \"I'm a lover of music and I use it to express myself.\",\n",
       "    'liveBroadcastContent': 'none',\n",
       "    'publishedAt': '2017-08-01T00:49:43.000Z',\n",
       "    'thumbnails': {'default': {'url': 'https://yt3.ggpht.com/-7gniZXwVOTc/AAAAAAAAAAI/AAAAAAAAAAA/8R85-y8lg2g/s88-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'high': {'url': 'https://yt3.ggpht.com/-7gniZXwVOTc/AAAAAAAAAAI/AAAAAAAAAAA/8R85-y8lg2g/s800-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'medium': {'url': 'https://yt3.ggpht.com/-7gniZXwVOTc/AAAAAAAAAAI/AAAAAAAAAAA/8R85-y8lg2g/s240-c-k-no-mo-rj-c0xffffff/photo.jpg'}},\n",
       "    'title': 'Original Koffee'}},\n",
       "  {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/YMhv-29Q76tGeWG8cOeMue5P-z4\"',\n",
       "   'id': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw', 'kind': 'youtube#channel'},\n",
       "   'kind': 'youtube#searchResult',\n",
       "   'snippet': {'channelId': 'UCSTyhCNj3MK4gRaxszgxLAw',\n",
       "    'channelTitle': 'Koffee - Topic',\n",
       "    'description': 'Mikayla Simpson, popularly known as Koffee, is a Jamaican singer, rapper/DJ, and guitarist from Spanish Town, Jamaica. She has released five singles.',\n",
       "    'liveBroadcastContent': 'none',\n",
       "    'publishedAt': '2015-09-18T15:16:26.000Z',\n",
       "    'thumbnails': {'default': {'url': 'https://yt3.ggpht.com/-Sq9WgKHL1sk/AAAAAAAAAAI/AAAAAAAAAAA/XJwdvYo-o90/s88-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'high': {'url': 'https://yt3.ggpht.com/-Sq9WgKHL1sk/AAAAAAAAAAI/AAAAAAAAAAA/XJwdvYo-o90/s800-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'medium': {'url': 'https://yt3.ggpht.com/-Sq9WgKHL1sk/AAAAAAAAAAI/AAAAAAAAAAA/XJwdvYo-o90/s240-c-k-no-mo-rj-c0xffffff/photo.jpg'}},\n",
       "    'title': 'Koffee - Topic'}},\n",
       "  {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/B2EiBt_sioRxYIYwYmrWeplLYGY\"',\n",
       "   'id': {'channelId': 'UCpbo3B3i6g5cCAtw4Equ6fg', 'kind': 'youtube#channel'},\n",
       "   'kind': 'youtube#searchResult',\n",
       "   'snippet': {'channelId': 'UCpbo3B3i6g5cCAtw4Equ6fg',\n",
       "    'channelTitle': 'Koffee - Topic',\n",
       "    'description': '',\n",
       "    'liveBroadcastContent': 'none',\n",
       "    'publishedAt': '2015-09-18T15:05:03.000Z',\n",
       "    'thumbnails': {'default': {'url': 'https://yt3.ggpht.com/-hil99U0hDao/AAAAAAAAAAI/AAAAAAAAAAA/OkISRG22W0c/s88-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'high': {'url': 'https://yt3.ggpht.com/-hil99U0hDao/AAAAAAAAAAI/AAAAAAAAAAA/OkISRG22W0c/s800-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'medium': {'url': 'https://yt3.ggpht.com/-hil99U0hDao/AAAAAAAAAAI/AAAAAAAAAAA/OkISRG22W0c/s240-c-k-no-mo-rj-c0xffffff/photo.jpg'}},\n",
       "    'title': 'Koffee - Topic'}},\n",
       "  {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/6qaChVe-px0gy-cXl4h4Ddl87NI\"',\n",
       "   'id': {'channelId': 'UCIOoP9FirTzjvgeAYTJWLcg', 'kind': 'youtube#channel'},\n",
       "   'kind': 'youtube#searchResult',\n",
       "   'snippet': {'channelId': 'UCIOoP9FirTzjvgeAYTJWLcg',\n",
       "    'channelTitle': 'KoffeeVEVO',\n",
       "    'description': '',\n",
       "    'liveBroadcastContent': 'none',\n",
       "    'publishedAt': '2018-09-17T18:47:09.000Z',\n",
       "    'thumbnails': {'default': {'url': 'https://yt3.ggpht.com/-h45VqmKKmBY/AAAAAAAAAAI/AAAAAAAAAAA/1GMkrhxJUpk/s88-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'high': {'url': 'https://yt3.ggpht.com/-h45VqmKKmBY/AAAAAAAAAAI/AAAAAAAAAAA/1GMkrhxJUpk/s800-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'medium': {'url': 'https://yt3.ggpht.com/-h45VqmKKmBY/AAAAAAAAAAI/AAAAAAAAAAA/1GMkrhxJUpk/s240-c-k-no-mo-rj-c0xffffff/photo.jpg'}},\n",
       "    'title': 'KoffeeVEVO'}},\n",
       "  {'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/pTDpIRvm_xhK_fAKIEob1t5c7o8\"',\n",
       "   'id': {'channelId': 'UCOGRZ8d1eMNiub-slPzBwww', 'kind': 'youtube#channel'},\n",
       "   'kind': 'youtube#searchResult',\n",
       "   'snippet': {'channelId': 'UCOGRZ8d1eMNiub-slPzBwww',\n",
       "    'channelTitle': 'Koffee VEVO',\n",
       "    'description': 'Koffee_official.',\n",
       "    'liveBroadcastContent': 'none',\n",
       "    'publishedAt': '2019-01-22T20:35:02.000Z',\n",
       "    'thumbnails': {'default': {'url': 'https://yt3.ggpht.com/-1gxa5Nz50ts/AAAAAAAAAAI/AAAAAAAAAAA/01R9lDFFjjI/s88-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'high': {'url': 'https://yt3.ggpht.com/-1gxa5Nz50ts/AAAAAAAAAAI/AAAAAAAAAAA/01R9lDFFjjI/s800-c-k-no-mo-rj-c0xffffff/photo.jpg'},\n",
       "     'medium': {'url': 'https://yt3.ggpht.com/-1gxa5Nz50ts/AAAAAAAAAAI/AAAAAAAAAAA/01R9lDFFjjI/s240-c-k-no-mo-rj-c0xffffff/photo.jpg'}},\n",
       "    'title': 'Koffee VEVO'}}],\n",
       " 'kind': 'youtube#searchListResponse',\n",
       " 'nextPageToken': 'CAUQAA',\n",
       " 'pageInfo': {'resultsPerPage': 5, 'totalResults': 2555},\n",
       " 'regionCode': 'CA'}"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chansearch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'etag': '\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/ewwRz0VbTYpp2EGbOkvZ5M_1mbo\"',\n",
       " 'items': [],\n",
       " 'kind': 'youtube#playlistListResponse',\n",
       " 'pageInfo': {'resultsPerPage': 5, 'totalResults': 0}}"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "yt.playlists().list(channelId='UCbNNpH4gB4Nu-imqMDysWiw', part='snippet').execute()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from importlib import reload"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from tracker import runner"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<module 'tracker.runner' from '/Users/joel/src/thundr/tracker/tracker/runner.py'>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reload(runner)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "No item found for channel id: yt1\n",
      "No item found for channel id: yt2\n",
      "No item found for channel id: yt3\n"
     ]
    }
   ],
   "source": [
    "runner.update_yt_artist_channel_stats()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "db.Session.commit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<module 'tracker.youtube.youtube' from '/Users/joel/src/thundr/tracker/tracker/youtube/youtube.py'>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reload(youtube)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "youtube.insert_new_videos_for_artist_channel('UCjAimkVp-G_o6HK5MXujk9A')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "db.Session.query(db.YtArtistChannel.ytid, db.YtArtistChannel.last_updated).all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "youtube._update_artist_channel_last_updated('yt2')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "db.Session.query(db.YtArtistChannel.ytid, db.YtArtistChannel.last_updated).all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def found(item):\n",
    "    print(\"Found item!\", item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def notfound(id):\n",
    "    print(\"Not found: {}\".format(id))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "youtube.visit_channel_stats(['UCVnbV347jNFMAy__hdJGZFw', 'foo', 'UCiLwf13a39oUh3RASGkcjVw'], found, notfound)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "res = r.execute()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "res['items'][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# r1 = yt.search().list(type='video', q=\"Let's Go Home Foliage\", part='snippet')\n",
    "# r1 = yt.search().list(type='video', q=\"Gotta Go Kim Chung Ha\", part='snippet')\n",
    "# r1 = yt.search().list(type='video', q=\"Summer Lover Cub Sport\", part='snippet')\n",
    "r1 = yt.search().list(type='video', q=\"hope is a dangerous thing for a woman like me to have - but I have it\", part='snippet')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "r1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "r2 = r1.execute()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "r2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "parts = [\n",
    "'contentDetails',\n",
    "#'fileDetails',  only for owners\n",
    "'id',\n",
    "# 'liveStreamingDetails',\n",
    "# 'localizations',\n",
    "# 'player',\n",
    "#'processingDetails',\n",
    "# 'recordingDetails',\n",
    "'snippet',\n",
    "'statistics',\n",
    "'status',\n",
    "#'suggestions',\n",
    "'topicDetails',\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ids = [ v['id']['videoId'] for v in r2['items'] ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "parts, ids"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "r3 = yt.videos().list(\n",
    "    id=\",\".join(ids), \n",
    "    part=\",\".join(parts)).execute()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "r3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "[(l['id'], l['snippet']['channelTitle'],  l['snippet']['channelId'], l['snippet']['description'], l['snippet']['title'], \" | \".join(l['topicDetails']['topicCategories'])) for l in r3['items']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "descriptions = [ v['snippet']['description'] for v in r3['items']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "URL_REGEX = r\"\"\"(?i)\\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)/)(?:[^\\s()<>{}\\[\\]]+|\\([^\\s()]*?\\([^\\s()]+\\)[^\\s()]*?\\)|\\([^\\s]+?\\))+(?:\\([^\\s()]*?\\([^\\s()]+\\)[^\\s()]*?\\)|\\([^\\s]+?\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’])|(?:(?<!@)[a-z0-9]+(?:[.\\-][a-z0-9]+)*[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)\\b/?(?!@)))\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import re\n",
    "res = [ re.findall(URL_REGEX, d) for d in descriptions ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import requests\n",
    "g = requests.get('https://foliagemusic.bandcamp.com/')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from bs4 import BeautifulSoup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "soup = BeautifulSoup(g.content, 'html5lib')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "[a.attrs.get('href') for a in soup.findAll('a') if a.attrs.get('href', '').startswith('htt')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from tracker.spidering import url_spider"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "reload(url_spider)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "url_spider.spider_urls_to_list(['https://foliagemusic.bandcamp.com/album/iii',\n",
    "  'https://foliagemusic.bandcamp.com/album/iii-2',\n",
    "  'https://open.spotify.com/artist/6GO4Noo5C7TXVHxGNClp2w'], recurse_depth=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Handler = url_spider._get_handler('https://open.spotify.com/artist/6GO4Noo5C7TXVHxGNClp2w')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Handler('https://open.spotify.com/artist/6GO4Noo5C7TXVHxGNClp2w').convert_to_canonical_form()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "spoturl = 'https://spoti.fi/2PRj0jr'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "r = requests.get(spoturl, allow_redirects=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "r.is_redirect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "r.is_permanent_redirect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "r.headers['Location']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "reload(url_spider)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "url_spider._get_handler(spoturl)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "H = _"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "handler = H(spoturl)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "handler.convert_to_canonical_form()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "handler.spider_for_urls()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "Getting the related links data is a challenge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from bs4 import BeautifulSoup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "chreq = requests.get('https://www.youtube.com/channel/UC14ap4T608Zz_Mz4eezhIqw')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "channel_soup = BeautifulSoup(chreq.content, 'html5lib')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "channel_soup"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "gg = requests.get('https://www.youtube.com/user/timnelsonmusic/about')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "gg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "channel_soup = BeautifulSoup(gg.content, 'html5lib')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "channel_soup.select('.about-channel-link-icon')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from urllib import parse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "parse.unquote(channel_soup.select_one('.about-channel-link-icon').attrs['alt'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from urllib.parse import urlsplit, parse_qs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "qry = urlsplit(channel_soup.select_one('.about-channel-link-icon').attrs['alt']).query"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "parse_qs(qry).get('q')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_page_links(url):\n",
    "    page = requests.get(url)\n",
    "    if page.status_code != 200:\n",
    "        return None\n",
    "    soup = BeautifulSoup(page.content, 'html5lib')\n",
    "    ret = []\n",
    "    for tag in soup.select('.about-channel-link-icon'):\n",
    "        print(tag)\n",
    "        qry = parse.urlsplit(tag.attrs['alt']).query\n",
    "        link_url = parse_qs(qry).get('q')\n",
    "        ret.append(link_url)\n",
    "    \n",
    "    return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "f = get_page_links('https://www.youtube.com/user/GeorgiaFlipoDrums/about?disable_polymer=1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "r = requests.get('https://www.youtube.com/user/GeorgiaFlipoDrums/about?disable_polymer=1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "soup = BeautifulSoup(r.content, 'html5lib')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "parse.unquote(soup.select('.about-channel-link-icon')[0]).attrs['alt']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "f"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from pynamodb.models import Model\n",
    "from pynamodb import attributes as dya"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class TestTable(Model):\n",
    "    class Meta:\n",
    "        table_name = 'test_table'\n",
    "        # Specifies the region\n",
    "        region = 'eu-west-1'\n",
    "        # Optional: Specify the hostname only if it needs to be changed from the default AWS setting\n",
    "        host = 'http://localhost:8000'\n",
    "        # Specifies the write capacity\n",
    "        write_capacity_units = 10\n",
    "        # Specifies the read capacity\n",
    "        read_capacity_units = 10\n",
    "    ytid = dya.UnicodeAttribute(hash_key=True)\n",
    "    data = dya.JSONAttribute()\n",
    "    track_spyid = dya.UnicodeAttribute(null=True)\n",
    "    artist_spyid = dya.UnicodeAttribute(null=True)\n",
    "    arid = dya.NumberAttribute(null=True)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "TestTable.create_table(wait=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "list(TestTable.scan())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "TestTable('yt1', track_spyid='spy1', data={'test': True, 'foo': 1, 'bar': 'baz'}).save()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "a = _[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "TestTable.delete_table?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "a.data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "a.ytid"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "TestTable.get('yt1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class TestTable(Model):\n",
    "    class Meta:\n",
    "        table_name = 'test_table'\n",
    "        # Specifies the region\n",
    "        region = 'eu-west-1'\n",
    "        # Optional: Specify the hostname only if it needs to be changed from the default AWS setting\n",
    "        host = 'http://localhost:8000'\n",
    "        # Specifies the write capacity\n",
    "        write_capacity_units = 10\n",
    "        # Specifies the read capacity\n",
    "        read_capacity_units = 10\n",
    "    ytid = dya.UnicodeAttribute(hash_key=True)\n",
    "    data = dya.JSONAttribute()\n",
    "    track_spyid = dya.UnicodeAttribute(null=True)\n",
    "    artist_spyid = dya.UnicodeAttribute(null=True)\n",
    "    arid = dya.NumberAttribute(null=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
