Uploaded using Google CoLaboratory.

This commit is contained in:
Hansly Saw 2022-05-03 17:57:39 +08:00
parent 2f23e4340c
commit 9e88053c37
1 changed files with 13 additions and 12 deletions

View File

@ -16,8 +16,8 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"cellView": "form", "id": "NKYqnAEwCPYG",
"id": "NKYqnAEwCPYG" "cellView": "form"
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
@ -25,13 +25,12 @@
"# Watch k-pop music videos in an ASCII format. \n", "# Watch k-pop music videos in an ASCII format. \n",
"\n", "\n",
"import os; import subprocess\n", "import os; import subprocess\n",
"from google.colab import files; from google.colab import output\n",
"from IPython.display import Audio\n", "from IPython.display import Audio\n",
"\n", "\n",
"# selections\n", "# selections\n",
"class selection: \n", "class selection: \n",
" artist = \"Twice\" #@param [\"Twice\"]\n", " artist = \"Twice\" #@param [\"Twice\"]\n",
" video = \"MORE & MORE\" #@param {type:\"string\"}\n", " video = \"\" #@param {type:\"string\"}\n",
" video = (video.strip()).lower()\n", " video = (video.strip()).lower()\n",
" videoURL = ''\n", " videoURL = ''\n",
"\n", "\n",
@ -64,6 +63,12 @@
" def success(message):\n", " def success(message):\n",
" print(formatting.font.bold + formatting.color.green + 'Success: \\t' + formatting.clear + formatting.clear + message)\n", " print(formatting.font.bold + formatting.color.green + 'Success: \\t' + formatting.clear + formatting.clear + message)\n",
"\n", "\n",
"try: \n",
" from google.colab import files; from google.colab import output\n",
"except: \n",
" info.err(formatting.font.bold + 'Google CoLab is required to run this.' + formatting.clear + ' This requires components only available in Google CoLab servers.')\n",
" os.kill(os.getpid(), 1)\n",
"\n",
"# Install apt programs and python modules. \n", "# Install apt programs and python modules. \n",
"def get_dependencies(): \n", "def get_dependencies(): \n",
" import subprocess\n", " import subprocess\n",
@ -129,7 +134,7 @@
" selection.videoURL = musicvideos[selection.artist][selection.video]\n", " selection.videoURL = musicvideos[selection.artist][selection.video]\n",
" \n", " \n",
" except:\n", " except:\n",
" info.err(formatting.font.bold + 'The video that you are looking for does not exist. ' + formatting.clear + 'Make sure you have typed it properly. If you did, you can safely assume that this script is not updated. ')\n", " info.err(formatting.font.bold + 'The video that you are looking for does not exist. ' + formatting.clear + 'Make sure you have typed it properly. If you did, it was not possibly included. Check out the GitHub discussions for that.')\n",
" os.kill(os.getpid(), 1)\n", " os.kill(os.getpid(), 1)\n",
" \n", " \n",
" def start_download():\n", " def start_download():\n",
@ -166,7 +171,7 @@
" def process():\n", " def process():\n",
" info.status('Processing the video. This will take some while.')\n", " info.status('Processing the video. This will take some while.')\n",
" !video-to-ascii -f video.mp4 -o output.sh --strategy {configs.method}\n", " !video-to-ascii -f video.mp4 -o output.sh --strategy {configs.method}\n",
" \n", "\n",
" def check_success():\n", " def check_success():\n",
" if check_file_exists():\n", " if check_file_exists():\n",
" output.clear()\n", " output.clear()\n",
@ -185,9 +190,7 @@
" try:\n", " try:\n",
" files.download('output.sh')\n", " files.download('output.sh')\n",
" except:\n", " except:\n",
" info.err('The file could not be downloaded, but it is available for manual downloading at the files view in the sidebar.')\n", " info.err('The file could not be downloaded automatically, but it is available for at the files view in the sidebar.')\n",
" else:\n",
" info.success('The file was succesfully downloaded.')\n",
"\n", "\n",
"def main():\n", "def main():\n",
" get_dependencies()\n", " get_dependencies()\n",
@ -202,9 +205,7 @@
"metadata": { "metadata": {
"accelerator": "GPU", "accelerator": "GPU",
"colab": { "colab": {
"authorship_tag": "ABX9TyOKzpUDluOXYqmRr/JITg5H",
"collapsed_sections": [], "collapsed_sections": [],
"include_colab_link": true,
"name": "Kpop'minal.ipynb", "name": "Kpop'minal.ipynb",
"private_outputs": true, "private_outputs": true,
"provenance": [] "provenance": []
@ -219,4 +220,4 @@
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 0
} }