release: minor improvements #1
					 1 changed files with 20 additions and 11 deletions
				
			
		|  | @ -16,7 +16,6 @@ | |||
|       "cell_type": "code", | ||||
|       "execution_count": null, | ||||
|       "metadata": { | ||||
|         "cellView": "form", | ||||
|         "id": "NKYqnAEwCPYG" | ||||
|       }, | ||||
|       "outputs": [], | ||||
|  | @ -25,7 +24,6 @@ | |||
|         "# Watch k-pop music videos in an ASCII format. \n", | ||||
|         "\n", | ||||
|         "import os; import subprocess\n", | ||||
|         "from google.colab import files; from google.colab import output\n", | ||||
|         "from IPython.display import Audio\n", | ||||
|         "\n", | ||||
|         "# selections\n", | ||||
|  | @ -38,6 +36,7 @@ | |||
|         "class configs: \n", | ||||
|         "    #@markdown ## Configuration\n", | ||||
|         "    method = \"ascii-color\" #@param [\"filled-ascii\", \"ascii-color\", \"just-ascii\"]\n", | ||||
|         "    action = \"download\" #@param [\"run\", \"download\"]\n", | ||||
|         "\n", | ||||
|         "# Set screen formatting. \n", | ||||
|         "class formatting:\n", | ||||
|  | @ -64,6 +63,12 @@ | |||
|         "    def success(message):\n", | ||||
|         "        print(formatting.font.bold + formatting.color.green + 'Success: \\t' + formatting.clear + formatting.clear + message)\n", | ||||
|         "\n", | ||||
|         "try: \n", | ||||
|         "    from google.colab import files; from google.colab import output\n", | ||||
|         "except: \n", | ||||
|         "    info.err(formatting.font.bold + 'You are not using this in Google CoLab. ' + formatting.clear + 'For this to work, please do so. ')\n", | ||||
|         "    os.kill(os.getpid(), 1)\n", | ||||
|         "\n", | ||||
|         "# Install apt programs and python modules. \n", | ||||
|         "def get_dependencies(): \n", | ||||
|         "    import subprocess\n", | ||||
|  | @ -129,7 +134,7 @@ | |||
|         "                selection.videoURL = musicvideos[selection.artist][selection.video]\n", | ||||
|         "            \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", | ||||
|         "    \n", | ||||
|         "    def start_download():\n", | ||||
|  | @ -164,9 +169,13 @@ | |||
|         "        if check_file_exists(): os.system('rm -rf output.old.sh && mv output.sh output.old.sh -v')\n", | ||||
|         "\n", | ||||
|         "    def process():\n", | ||||
|         "        if configs.action == \"download\":\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", | ||||
|         "    \n", | ||||
|         "        else:\n", | ||||
|         "            info.status('Processing the video. After some while, the video will play.')\n", | ||||
|         "            !video-to-ascii -f video.mp4 --strategy {configs.method}\n", | ||||
|         "\n", | ||||
|         "    def check_success():\n", | ||||
|         "        if check_file_exists():\n", | ||||
|         "            output.clear()\n", | ||||
|  | @ -178,6 +187,7 @@ | |||
|         "\n", | ||||
|         "    attemptReplace()\n", | ||||
|         "    process()\n", | ||||
|         "    if configs.action == \"download\":\n", | ||||
|         "        check_success()\n", | ||||
|         "\n", | ||||
|         "def download_results():\n", | ||||
|  | @ -193,6 +203,7 @@ | |||
|         "    get_dependencies()\n", | ||||
|         "    download_video()\n", | ||||
|         "    render()\n", | ||||
|         "    if configs.action == \"download\":\n", | ||||
|         "        download_results()\n", | ||||
|         "\n", | ||||
|         "main()" | ||||
|  | @ -202,9 +213,7 @@ | |||
|   "metadata": { | ||||
|     "accelerator": "GPU", | ||||
|     "colab": { | ||||
|       "authorship_tag": "ABX9TyOKzpUDluOXYqmRr/JITg5H", | ||||
|       "collapsed_sections": [], | ||||
|       "include_colab_link": true, | ||||
|       "name": "Kpop'minal.ipynb", | ||||
|       "private_outputs": true, | ||||
|       "provenance": [] | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue