Added check_link feature.

- check_link feature ensures that the video is in a YouTube domain.
This commit is contained in:
Hansly Saw 2022-05-12 12:21:13 +08:00
parent 7ead6d173a
commit 524206104c

View file

@ -27,8 +27,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "tgACi8lLVS6Y",
"cellView": "form"
"id": "tgACi8lLVS6Y"
},
"outputs": [],
"source": [
@ -131,8 +130,15 @@
" \n",
" check_installDone('write')\n",
"\n",
"def save_video(): \n",
"def check_link(): \n",
" # Check the link if it is in YouTube. \n",
" if ('.youtube.co' in user.video_link) or ('youtu.be' in user.video_link): \n",
" return True\n",
" else: \n",
" fail(formatting.font.bold + 'The link is not YouTube. ' + formatting.clear)\n",
" return False\n",
"\n",
"def save_video(): \n",
" import google;\n",
"\n",
" try:\n",
@ -171,10 +177,12 @@
" start_download((video.video_title + '.' + user.audio_format))\n",
"\n",
"# Main. \n",
"check_compatibility()\n",
"cleanup()\n",
"try: \n",
" check_compatibility()\n",
" cleanup()\n",
" check_link()\n",
"\n",
"class user: \n",
" class user: \n",
" video_link = \"\" #@param {type:\"string\"}\n",
" video_link = video_link.strip()\n",
"\n",
@ -189,9 +197,9 @@
" audio_format = 'm4a' #@param ['m4a']\n",
"\n",
"\n",
"install_required()\n",
" install_required()\n",
"\n",
"try: \n",
" try: \n",
" import yt_dlp;\n",
" with yt_dlp.YoutubeDL({}) as ydl:\n",
" class video: \n",
@ -200,7 +208,7 @@
" video_id = info_dict.get(\"id\", None)\n",
" video_title = info_dict.get('title', None)\n",
" output_format = '';\n",
"except: \n",
" except: \n",
" import youtube_dl;\n",
" with youtube_dl.YoutubeDL({}) as ydl:\n",
" class video: \n",
@ -210,8 +218,10 @@
" video_title = info_dict.get('title', None)\n",
" output_format = '';\n",
"\n",
"save_video()\n",
"download_video()"
" save_video()\n",
" download_video()\n",
"except: \n",
" info.fail(formatting.font.bold + 'An error has ocurred, ' formatting.clear + 'we apologize for the inconvenience. Please check the log for full details. ')"
]
}
],