uploaded using Google CoLaboratory

This commit is contained in:
Hansly Saw 2022-04-29 16:45:47 +08:00
parent f28fca56cc
commit 2a571e2287
1 changed files with 42 additions and 21 deletions

View File

@ -7,6 +7,7 @@
"provenance": [],
"collapsed_sections": [],
"private_outputs": true,
"authorship_tag": "ABX9TyOKzpUDluOXYqmRr/JITg5H",
"include_colab_link": true
},
"kernelspec": {
@ -45,7 +46,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "NKYqnAEwCPYG"
"id": "NKYqnAEwCPYG",
"cellView": "form"
},
"outputs": [],
"source": [
@ -56,11 +58,13 @@
"import subprocess\n",
"from google.colab import files\n",
"from google.colab import output\n",
"from IPython.display import Audio\n",
"\n",
"# selections\n",
"class selection: \n",
" artist = \"Twice\" #@param [\"Blackpink\", \"Twice\"]\n",
" video = \"\" #@param {type:\"string\"}\n",
" artist = \"Twice\" #@param [\"Twice\"]\n",
" video = \"MORE & MORE\" #@param {type:\"string\"}\n",
" video = (video.strip()).lower()\n",
" videoURL = ''\n",
"\n",
"class configs: \n",
@ -102,33 +106,51 @@
" def install_dependencies_pip():\n",
" return os.system('pip install \"video-to-ascii==1.2.8\" && pip install pyaudio')\n",
"\n",
" def install_dependencies_other(): \n",
" return os.system('cd /tmp && git clone https://people.csail.mit.edu/hubert/git/pyaudio.git && cd pyaudio && ipython setup.py install') # install pyaudio\n",
"\n",
" info.status('Setting up the environment…')\n",
"\n",
" install_dependencies_apt()\n",
" install_dependencies_pip()\n",
" install_dependencies_other()\n",
"\n",
" info.success('The environment has been set up. ')\n",
" output.clear()\n",
"\n",
"def download_video(): \n",
" musicvideos = {\n",
" # Download links for the music videos. Good thing it's available in archive.org. \n",
" # should all be in lower case\n",
" \"Twice\": {\n",
" # Download links available here: https://archive.org/details/twuniverse\n",
" \"Like Ooh-Ahh\": \"https://ia804501.us.archive.org/7/items/twuniverse/Like%20Oohahhoohahh.ia.mp4\",\n",
" \"Cheer Up\": \"https://ia904501.us.archive.org/7/items/twuniverse/Cheer%20Up%20.ia.mp4\",\n",
" \"TT\": \"https://ia804501.us.archive.org/7/items/twuniverse/Tt%20.ia.mp4\",\n",
" \"Knock Knock\": \"https://ia904501.us.archive.org/7/items/twuniverse/Knock%20Knock%20.ia.mp4\",\n",
" \"Signal\": \"https://ia804501.us.archive.org/7/items/twuniverse/Signal%20.ia.mp4\",\n",
" \"One More Time\": \"https://ia804501.us.archive.org/7/items/twuniverse/One%20More%20Time.ia.mp4\",\n",
" \"Likey\": \"https://ia904501.us.archive.org/7/items/twuniverse/Likey%20.ia.mp4\",\n",
" \"Merry & Happy\": \"https://ia904501.us.archive.org/7/items/twuniverse/Merry%20%20Happy%20.ia.mp4\",\n",
" \"Candy Pop\": \"https://ia804501.us.archive.org/7/items/twuniverse/Candy%20Pop.ia.mp4\",\n",
" \"What Is Love?\": \"https://ia804501.us.archive.org/7/items/twuniverse/What%20Is%20Love%20.ia.mp4\",\n",
" \"Wake Me Up\": \"https://ia804501.us.archive.org/7/items/twuniverse/Wake%20Me%20Up.ia.mp4\",\n",
" \"I Want You Back\": \"https://ia804501.us.archive.org/7/items/twuniverse/I%20Want%20You%20Back.ia.mp4\",\n",
" \"Dance The Night Away\": \"https://ia904501.us.archive.org/7/items/twuniverse/Dance%20The%20Night%20Away%20.ia.mp4\",\n",
" \"BDZ\": \"https://ia904501.us.archive.org/7/items/twuniverse/Bdz.ia.mp4\",\n",
" \"Alcohol-Free\": \"https://ia804501.us.archive.org/7/items/twuniverse/Alcoholfree%20.ia.mp4\"\n",
" \"like ooh-ahh\": \"https://ia804501.us.archive.org/7/items/twuniverse/Like%20Oohahhoohahh.ia.mp4\",\n",
" \"cheer up\": \"https://ia904501.us.archive.org/7/items/twuniverse/Cheer%20Up%20.ia.mp4\",\n",
" \"tt\": \"https://ia804501.us.archive.org/7/items/twuniverse/Tt%20.ia.mp4\",\n",
" \"knock knock\": \"https://ia904501.us.archive.org/7/items/twuniverse/Knock%20Knock%20.ia.mp4\",\n",
" \"signal\": \"https://ia804501.us.archive.org/7/items/twuniverse/Signal%20.ia.mp4\",\n",
" \"one more time\": \"https://ia804501.us.archive.org/7/items/twuniverse/One%20More%20Time.ia.mp4\",\n",
" \"likey\": \"https://ia904501.us.archive.org/7/items/twuniverse/Likey%20.ia.mp4\",\n",
" \"merry & happy\": \"https://ia904501.us.archive.org/7/items/twuniverse/Merry%20%20Happy%20.ia.mp4\",\n",
" \"candy pop\": \"https://ia804501.us.archive.org/7/items/twuniverse/Candy%20Pop.ia.mp4\",\n",
" \"what is love?\": \"https://ia804501.us.archive.org/7/items/twuniverse/What%20Is%20Love%20.ia.mp4\",\n",
" \"wake me up\": \"https://ia804501.us.archive.org/7/items/twuniverse/Wake%20Me%20Up.ia.mp4\",\n",
" \"i want you back\": \"https://ia804501.us.archive.org/7/items/twuniverse/I%20Want%20You%20Back.ia.mp4\",\n",
" \"dance the night away\": \"https://ia904501.us.archive.org/7/items/twuniverse/Dance%20The%20Night%20Away%20.ia.mp4\",\n",
" \"bdz\": \"https://ia904501.us.archive.org/7/items/twuniverse/Bdz.ia.mp4\",\n",
" \"yes or yes\": \"https://ia804501.us.archive.org/7/items/twuniverse/Yes%20Or%20Yes%20.ia.mp4\",\n",
" \"the best thing i ever did\": \"https://ia804501.us.archive.org/7/items/twuniverse/The%20Best%20Thing%20I%20Ever%20Did.ia.mp4\",\n",
" \"fancy\": \"https://ia904501.us.archive.org/7/items/twuniverse/Fancy%20.ia.mp4\",\n",
" \"breakthrough\": \"https://ia804501.us.archive.org/7/items/twuniverse/Breakthrough.ia.mp4\",\n",
" \"happy happy\": \"https://ia904501.us.archive.org/7/items/twuniverse/Happy%20Happy.ia.mp4\",\n",
" \"feel special\": \"https://ia904501.us.archive.org/7/items/twuniverse/Feel%20Special%20.ia.mp4\",\n",
" \"fake & true\": \"https://ia804501.us.archive.org/7/items/twuniverse/Fake%20%20True%20.ia.mp4\",\n",
" \"more & more\": \"https://ia804501.us.archive.org/7/items/twuniverse/More%20%20More%20.ia.mp4\",\n",
" \"fanfare\": \"https://ia904501.us.archive.org/7/items/twuniverse/Fanfare.ia.mp4\",\n",
" \"i can't stop me\": \"https://ia804501.us.archive.org/7/items/twuniverse/I%20Cant%20Stop%20Me%20.ia.mp4\",\n",
" \"better\": \"https://ia804501.us.archive.org/7/items/twuniverse/Better%20.ia.mp4\",\n",
" \"kura kura\": \"https://ia804501.us.archive.org/7/items/twuniverse/Kura%20Kura%20.ia.mp4\",\n",
" \"alcohol-free\": \"https://ia804501.us.archive.org/7/items/twuniverse/Alcoholfree%20.ia.mp4\"\n",
" }\n",
" }\n",
"\n",
@ -140,7 +162,7 @@
" \n",
" except:\n",
" info.err('The video that you are looking for does not exist. Make sure you have typed it properly. If you did, you can safely assume that this script is not updated. ')\n",
" os.kill(os.getpid(), 9)\n",
" os.kill(os.getpid(), 1)\n",
" \n",
" def start_download():\n",
" def check_exists(which=\"new\"):\n",
@ -155,8 +177,7 @@
" info.status('Downloading the music video…')\n",
"\n",
" if os.system('curl ' + selection.videoURL + ' -o video.mp4') > 0:\n",
" info.err('The download has failed, please re-run this script again. ')\n",
" os.system('rm -rf video.mp4 -v')\n",
" info.err('The download has failed, please re-run this script again. '); os.system('rm -rf video.mp4 -v')\n",
" if check_exists(\"old\"): os.system('mv video.old.mp4 video.mp4 -v')\n",
" os.kill(os.getpid(), 1)\n",
" else:\n",