{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from rap_scrpr import *\n", "from rap_db import *\n", "from rap_clean import*\n", "from rap_viz import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 songs cleaned raw (not properly formatted)\n", "130 songs cleaned clean\n", "chief_keef_raw.json made!\n", "0 songs cleaned raw (not properly formatted)\n", "91 songs cleaned clean\n", "2_chainz_raw.json made!\n", "chief_keef_raw.json added!\n", "2_chainz_raw.json added!\n" ] } ], "source": [ "#connect to DB, change password and username\n", "estconn = pg2.connect(database='rap_songs', user='*', host='localhost', password='*')\n", "#set up list of rappers to scrape\n", "dwnld = ['Chief Keef', '2 Chainz']\n", "#pull link from DB and scrape the songs there\n", "new_artists = scrape_multi_artists(estconn, dwnld)\n", "#only run this when creating the music tables for the first time\n", "#create_music_tables(estconn, bypass = True)\n", "#loads newly created json files into DB\n", "bulk_load(estconn, new_artists)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Made Chief Keef object!\n", "Made 2 Chainz object!\n", "Saved Chief Keef!\n", "Saved 2 Chainz!\n" ] } ], "source": [ "#pulls all songs from database based on dwnld and creates an artist object for each\n", "works_pull = dict(zip(dwnld, construct_artists(estconn, art_list = dwnld)))\n", "#saves the artist objects for speedier access\n", "art_save(works_pull)\n", "estconn.close()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "artists = ['Del', 'Doom', 'Mos Def', 'Chief Keef']\n", "#loads art objects with these names\n", "works = art_load(artists)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Found: Bada Bing!\n", "Changed 49 sylbs!\n" ] }, { "data": { "text/html": [ "