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
1 changed files with 52 additions and 42 deletions

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,8 +177,10 @@
" start_download((video.video_title + '.' + user.audio_format))\n",
"\n",
"# Main. \n",
"try: \n",
" check_compatibility()\n",
" cleanup()\n",
" check_link()\n",
"\n",
" class user: \n",
" video_link = \"\" #@param {type:\"string\"}\n",
@ -211,7 +219,9 @@
" output_format = '';\n",
"\n",
" save_video()\n",
"download_video()"
" 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. ')"
]
}
],