{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import json\n", "import os\n", "from datetime import datetime\n", "import random\n", "from pprint import pprint" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Total: 445582\n", "Total Populated: 442034 (99.20%)\n", "Total New: 130411 (29.27%)\n", "{'conn_country': 'GB',\n", " 'episode_name': None,\n", " 'episode_show_name': None,\n", " 'incognito_mode': False,\n", " 'ip_addr_decrypted': '82.132.244.90',\n", " 'master_metadata_album_album_name': 'Tales Told By Dead Friends',\n", " 'master_metadata_album_artist_name': 'Mayday Parade',\n", " 'master_metadata_track_name': 'Three Cheers For Five Years',\n", " 'ms_played': 33274,\n", " 'offline': False,\n", " 'offline_timestamp': 0,\n", " 'platform': 'iOS 9.2.1 (iPhone7,1)',\n", " 'reason_end': 'fwdbtn',\n", " 'reason_start': 'fwdbtn',\n", " 'shuffle': True,\n", " 'skipped': True,\n", " 'spotify_episode_uri': None,\n", " 'spotify_track_uri': 'spotify:track:1aw8gphDUzqalHEi9Z8M38',\n", " 'ts': '2016-02-11T08:13:55Z',\n", " 'user_agent_decrypted': 'unknown',\n", " 'username': 'sarsoo'}\n" ] } ], "source": [ "data = []\n", "data_with_names = []\n", "new_data = []\n", "\n", "folder = '/Users/andy/lab/backups/spotify-2022-03-07'\n", "\n", "for i in os.listdir(folder):\n", " if i.startswith('endsong_'):\n", " with open(f'{folder}/{i}') as f:\n", " data += json.loads(f.read())\n", "\n", "data.sort(key = lambda a: a['ts'])\n", "data_with_names = [i for i in data if i['master_metadata_track_name'] is not None]\n", "new_data = [i for i in data_with_names if datetime.fromisoformat(i['ts'].split('T')[0]) < datetime(2017, 11, 3)]\n", "\n", "print(f'Total: {len(data)}')\n", "print(f'Total Populated: {len(data_with_names)} ({len(data_with_names)/len(data)*100:.2f}%)')\n", "print(f'Total New: {len(new_data)} ({len(new_data)/len(data)*100:.2f}%)')\n", "\n", "pprint(random.choice(new_data))\n", "# print(min(i[0] for i in data))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "interpreter": { "hash": "a0a5145e6c304e2a9afaf5b930a2955b950bd4b81fe94f7c42930f43f42762eb" }, "kernelspec": { "display_name": "Python 3.10.7 64-bit", "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.10.4" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }