{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "\n",
    "from suno_utils.utils.text import read_jsonl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "53357407\n"
     ]
    }
   ],
   "source": [
    "metas_filepath = \"/home/christian/code/christian/metadata/discogs_metas.jsonl\"\n",
    "metas = read_jsonl(metas_filepath)\n",
    "print(len(metas))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of songs with lyrics: 6855322 (12.85%)\n"
     ]
    }
   ],
   "source": [
    "# count the number of songs with lyrics\n",
    "lyrics_count = sum(1 for meta in metas if meta.get(\"text\", None) is not None)\n",
    "print(f\"Number of songs with lyrics: {lyrics_count} ({lyrics_count / len(metas) * 100:.2f}%)\")\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# count the number of songs with tags\n",
    "tags_count = sum(1 for meta in metas if meta.get(\"tags\", None) is not None)\n",
    "print(f\"Number of songs with tags: {tags_count} ({tags_count / len(metas) * 100:.2f}%)\")\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Number of songs with invalid s3_filepath: 315327 (0.59%): 100%|██████████| 53357407/53357407 [00:36<00:00, 1466331.81it/s]\n"
     ]
    }
   ],
   "source": [
    "# check for valid s3_filepath\n",
    "count = 0\n",
    "from tqdm import tqdm\n",
    "pbar = tqdm(metas)\n",
    "for idx, meta in enumerate(pbar):\n",
    "    if meta.get(\"s3_filepath\", None) is not None:\n",
    "        s3_filepath = meta[\"s3_filepath\"]\n",
    "        if not s3_filepath.endswith((\".mp3\", \".mp4\", \".m4a\", \".wav\", \".webm\", \".ogg\")):\n",
    "            count += 1\n",
    "    if idx % 1000 == 0:\n",
    "        pbar.set_description(f\"Number of songs with invalid s3_filepath: {count} ({count / len(metas) * 100:.2f}%)\")\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "suno_env",
   "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
