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", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"id": "tgACi8lLVS6Y", "id": "tgACi8lLVS6Y"
"cellView": "form"
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
@ -131,8 +130,15 @@
" \n", " \n",
" check_installDone('write')\n", " check_installDone('write')\n",
"\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", "\n",
"def save_video(): \n",
" import google;\n", " import google;\n",
"\n", "\n",
" try:\n", " try:\n",
@ -171,8 +177,10 @@
" start_download((video.video_title + '.' + user.audio_format))\n", " start_download((video.video_title + '.' + user.audio_format))\n",
"\n", "\n",
"# Main. \n", "# Main. \n",
"try: \n",
" check_compatibility()\n", " check_compatibility()\n",
" cleanup()\n", " cleanup()\n",
" check_link()\n",
"\n", "\n",
" class user: \n", " class user: \n",
" video_link = \"\" #@param {type:\"string\"}\n", " video_link = \"\" #@param {type:\"string\"}\n",
@ -211,7 +219,9 @@
" output_format = '';\n", " output_format = '';\n",
"\n", "\n",
" save_video()\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. ')"
] ]
} }
], ],