mirror of
				https://github.com/buzz-lightsnack-2007/DownYouNow.git
				synced 2024-08-14 23:55:22 +00:00 
			
		
		
		
	fixed significant bugs and added new features:
- resolved error on startup - Youtube-dl is now the fallback downloader in case yt-dlp fails. Files are cleared when switching. - A failed download no longer raises an exception, but an error message is still shown and the execution will still fail.
This commit is contained in:
		
							parent
							
								
									010409d8f4
								
							
						
					
					
						commit
						7ead6d173a
					
				
					 1 changed files with 40 additions and 12 deletions
				
			
		|  | @ -1,5 +1,15 @@ | |||
| { | ||||
|   "cells": [ | ||||
|     { | ||||
|       "cell_type": "markdown", | ||||
|       "metadata": { | ||||
|         "id": "view-in-github", | ||||
|         "colab_type": "text" | ||||
|       }, | ||||
|       "source": [ | ||||
|         "<a href=\"https://colab.research.google.com/github/buzz-lightsnack-2007/DownYouNow/blob/development/DownYouNow.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|       "cell_type": "markdown", | ||||
|       "metadata": { | ||||
|  | @ -10,7 +20,7 @@ | |||
|         "\n", | ||||
|         "**A 100% free YouTube video downloader.** \n", | ||||
|         "\n", | ||||
|         "_Powered by `yt_dlp` and `youtube_dl`._" | ||||
|         "_Powered by [`YouTube-DL`](https://urlzs.com/AqDFN) and [`yt_dlp`](https://urlzs.com/rkBHD). ._" | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|  | @ -70,6 +80,10 @@ | |||
|         "    try: from google.colab import files\n", | ||||
|         "    except: raise TypeError(\"No! Please run this in \" + formatting.font.bold + 'Google CoLab' + formatting.clear + '. ')\n", | ||||
|         "\n", | ||||
|         "def fail(message = ''): \n", | ||||
|         "    # When the program fails, run this. \n", | ||||
|         "    clear(); info.title(); info.err(message); os.kill(os.getpid, 1);\n", | ||||
|         "\n", | ||||
|         "def getExtension(fileName): \n", | ||||
|         "    import os\n", | ||||
|         "    fileName_split = os.path.splitext(fileName)\n", | ||||
|  | @ -81,7 +95,6 @@ | |||
|         "def install(what, where = 'apt', isCritical = False):\n", | ||||
|         "    os.system('add-apt-repository ppa:apt-fast/stable -y && apt-get update')\n", | ||||
|         "\n", | ||||
|         "    info.status('Installing ' + what + '…')\n", | ||||
|         "    try:\n", | ||||
|         "        if (where == 'apt' or where == 'apt-get' or where == 'apt-fast' or where == 'aptitude'):\n", | ||||
|         "            if os.system('DEBIAN_FRONTEND=noninteractive apt-fast install ' + what + ' -y'): \n", | ||||
|  | @ -93,11 +106,10 @@ | |||
|         "            if os.system('DEBIAN_FRONTEND=noninteractive ' + where + ' install ' + what): raise\n", | ||||
|         "    except:\n", | ||||
|         "        errorMsg = (what + ' could not get installed. ')\n", | ||||
|         "        if isCritical: clear(); info.title(); raise SystemError('Critical component ' + errorMsg)\n", | ||||
|         "        if isCritical: fail('Critical component ' + errorMsg)\n", | ||||
|         "        else: info.err(errorMsg); return True\n", | ||||
|         "    else: \n", | ||||
|         "        if os.system('apt-fast clean && apt-fast autoremove -y') > 0: os.system('apt clean && apt autoremove -y') > 0\n", | ||||
|         "        info.success('Installed '+ what + '.'); return False\n", | ||||
|         "\n", | ||||
|         "def install_required(): \n", | ||||
|         "    def check_installDone(method='check'): \n", | ||||
|  | @ -105,23 +117,36 @@ | |||
|         "        else: return not(os.system('cat .config/installDone'))\n", | ||||
|         "\n", | ||||
|         "    if not(check_installDone()): \n", | ||||
|         "        for program in ['apt-fast', 'yt-dlp', 'youtube-dl', 'libboost-all-dev']: \n", | ||||
|         "        # Install programs here using apt.\n", | ||||
|         "        for program in ['apt-fast', 'youtube-dl', 'libboost-all-dev']: \n", | ||||
|         "            clear()\n", | ||||
|         "            info.title(); info.status('Please wait.')\n", | ||||
|         "            install(program)\n", | ||||
|         "            clear()\n", | ||||
|         "        # install programs here using pip\n", | ||||
|         "        for program in ['yt-dlp']: \n", | ||||
|         "            info.title(); info.status('Please wait.')\n", | ||||
|         "            install(program, 'pip')\n", | ||||
|         "            clear()\n", | ||||
|         "        \n", | ||||
|         "        check_installDone('write')\n", | ||||
|         "\n", | ||||
|         "def save_video(): \n", | ||||
|         "\n", | ||||
|         "    import google;\n", | ||||
|         "\n", | ||||
|         "    try:\n", | ||||
|         "        info.title() \n", | ||||
|         "        if not(user.audio_only):\n", | ||||
|         "            if os.system('yt-dlp \"' + user.video_link + '\" --compat-options no-youtube-unavailable-videos --merge-output-format ' + user.video_format + ' --audio-format ' + user.audio_format): raise\n", | ||||
|         "            if os.system('yt-dlp \"' + user.video_link + '\" --compat-options no-youtube-unavailable-videos --merge-output-format ' + user.video_format + ' --audio-format ' + user.audio_format): \n", | ||||
|         "                cleanup()\n", | ||||
|         "                if os.system('youtube-dl \"' + user.video_link + '\" --compat-options no-youtube-unavailable-videos --merge-output-format ' + user.video_format + ' --audio-format ' + user.audio_format): raise\n", | ||||
|         "        else: \n", | ||||
|         "            if os.system('yt-dlp -x \"' + user.video_link + '\" --compat-options no-youtube-unavailable-videos --audio-format ' + user.audio_format): raise\n", | ||||
|         "            if os.system('yt-dlp -x \"' + user.video_link + '\" --compat-options no-youtube-unavailable-videos --audio-format ' + user.audio_format): \n", | ||||
|         "                cleanup()\n", | ||||
|         "                if os.system('youtube-dl -x \"' + user.video_link + '\" --compat-options no-youtube-unavailable-videos --audio-format ' + user.audio_format): raise\n", | ||||
|         "    except: \n", | ||||
|         "        clear(); info.title(); raise UnboundLocalError(formatting.font.bold + 'The YouTube video could not be downloaded. ' + formatting.clear + 'Please try again. ')\n", | ||||
|         "        clear(); fail(formatting.font.bold + 'The YouTube video could not be downloaded. ' + formatting.clear + 'Please try again. ')\n", | ||||
|         "    else: \n", | ||||
|         "        info.success('Video cached. ')\n", | ||||
|         "\n", | ||||
|  | @ -157,11 +182,14 @@ | |||
|         "    audio_only = 0 #@param {type:\"slider\", min:0, max:1, step:1}\n", | ||||
|         "\n", | ||||
|         "    if not(audio_only): \n", | ||||
|         "        video_format = \"mp4\" #@param [\"mp4\", \"mkv\", \"webm\"]\n", | ||||
|         "        video_format = \"mkv\" #@param [\"mkv\", \"webm\"]\n", | ||||
|         "    else: \n", | ||||
|         "        video_format = False\n", | ||||
|         "    \n", | ||||
|         "    audio_format = 'm4a' #@param ['mp3', 'm4a', 'wav']\n", | ||||
|         "    audio_format = 'm4a' #@param ['m4a']\n", | ||||
|         "\n", | ||||
|         "\n", | ||||
|         "install_required()\n", | ||||
|         "\n", | ||||
|         "try: \n", | ||||
|         "    import yt_dlp;\n", | ||||
|  | @ -182,7 +210,6 @@ | |||
|         "            video_title = info_dict.get('title', None)\n", | ||||
|         "            output_format = '';\n", | ||||
|         "\n", | ||||
|         "install_required()\n", | ||||
|         "save_video()\n", | ||||
|         "download_video()" | ||||
|       ] | ||||
|  | @ -193,7 +220,8 @@ | |||
|       "collapsed_sections": [], | ||||
|       "name": "Untitled0.ipynb", | ||||
|       "private_outputs": true, | ||||
|       "provenance": [] | ||||
|       "provenance": [], | ||||
|       "include_colab_link": true | ||||
|     }, | ||||
|     "kernelspec": { | ||||
|       "display_name": "Python 3", | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue