YoutubeTags
YouTube SEO tool for extracting video tags without the need for the official YouTube API
New in Version 1.5 — fully backward compatible, existing code keeps working unchanged.
- Full video metadata (
get_video_info), channel metadata (get_channel_info)- Tags as Python lists, hashtags, YouTube autocomplete tag suggestions, tag SEO analysis (500-char limit check)
- Bulk/concurrent tag extraction,
youtubetagscommand line tool- Accepts
youtu.be, Shorts, embed, live links, bare video ids and@handles- Timeouts, retries and EU cookie-consent handling so requests no longer hang or come back empty
Version 1.4 Added Functions for videotitle,videodescription,channeldescription
Installation
pip install YoutubeTags
Video Tags
How to Use It
import YoutubeTags
from YoutubeTags import videotags
link = "Add Your Youtube Link Here" # Use https / http Links
variable_name = videotags(link)
print(variable_name)
NOTE: ONLY SUPPORTS HTTP(S) , use HTTP(S) links to get the results
Example 1
import YoutubeTags
from YoutubeTags import videotags
findtags = videotags("https://www.youtube.com/watch?v=RTbrXiIzUt4") # Mkbhd's Video
print(findtags)
Output of Example 1
Right To Repair, right to repair, MKBHD, right to repair movement, Apple, Apple vs,
repairing iPhone, iPhone 12, Tesla right to repair, Apple right to repair
Example 2
import YoutubeTags
from YoutubeTags import videotags
tags = videotags("https://www.youtube.com/watch?v=Kbe3FKeCd1A") # Karikku star Episode
print(tags)
Output of Example 2
karikku, malayalam, funny, comedy, webseries, lolan,
george, karikk, karikke, film, trending, sketch, vine, flowerstv
Example 3
import YoutubeTags
from YoutubeTags import videotags
gettag = videotags("https://www.youtube.com/watch?v=nvjILgpf6tc") # Video From Technical Guruji
print(gettag)
Output of Example 3
iPhone 14, iPhone 14 Unboxing, iPhone 14 exclusive 1st look, iPhone 14 first look,
iPhone 14 no notch, iPhone 14 punch hole camera, iPhone 14 titanium sides, iPhone 14 look,
iPhone 14 leaks, iPhone 14 design, iPhone 14 india, iPhone 14 launch date, iPhone 14 no camera bump,
iPhone 14 features, iPhone 14 price, iPhone 14 vs iPhone 13, iPhone 14 launch event, iPhone 14 india 1st look,
iPhone 14 first look in hindi, Technical Guruji, Technicalguruji, Gaurav Chaudhary, 13
Example 4 (If Video Has no tags)
import YoutubeTags
from YoutubeTags import videotags
tag = videotags("https://www.youtube.com/watch?v=Mlk888FiI8A") # Google Keynote video 2021
if tag:
print (tag)
else:
print("No Tags Found")
Output of Example 4
No Tags Found
Channel Tags
How to Use It
import YoutubeTags
from YoutubeTags import channeltags
link = "Add Your Channel Link Here" # Use https / http Links
variable_name = channeltags(link)
print(variable_name)
NOTE: ONLY SUPPORTS HTTP(S) , use HTTP(S) links to get the results
Example 1
import YoutubeTags
from YoutubeTags import channeltags
findtags = channeltags("https://youtube.com/c/mkbhd") # Mkbhd's channel Link
print(findtags)
Output of Example 1
MKBHD, MarquesBrownlee, Marques, Brownlee
Example 2
import YoutubeTags
from YoutubeTags import channeltags
tags = channeltags("https://youtube.com/c/Karikku_Fresh") # Karikku channel Link
print(tags)
Output of Example 2
karikku, media, digital, malayalam
Example 3
import YoutubeTags
from YoutubeTags import channeltags
gettag = channeltags("https://youtube.com/c/TechnicalGuruji") # Technical Guruji channel Link
print(gettag)
Output of Example 3
Hindi Technology, Technology in Hindi, Hindi Tech Guru, Technical Guruji, Hindi Tech Tips, Tech Reviews, Mobile Tips and Tricks, Technology Explained,
Hindi Tech, Hindi Tech Reviews, Tech Hindi, hindi, Technology, Mobile, tech, Reviews, TechnicalGuruji, Gaurav Chaudhary, Smartphones, Mobile Phones,
Tech, latest Tech,Cool Technology, Tech News, Latest Tech News
Example 4
import YoutubeTags
from YoutubeTags import channeltags
tag = channeltags("https://youtube.com/user/PewDiePie") # PewDiePie channel Link
print(tag)
Output of Example 4
pewdiepie, pewds, gaming, felix arvid ulf, felix, kjellberg
What's New in 1.5
Everything above still works exactly as before. The functions below are new; they return
Python lists / dicts and raise YoutubeTags.YoutubeTagsError (or a subclass) on failure
instead of returning False.
Flexible links
Every function now also accepts youtu.be/..., /shorts/..., /embed/..., /live/... links,
bare 11-character video ids, links without https://, and channel @handles.
from YoutubeTags import videotags, channeltags
print(videotags("RTbrXiIzUt4"))
print(videotags("https://youtu.be/RTbrXiIzUt4"))
print(channeltags("@mkbhd"))
Full video info
from YoutubeTags import get_video_info
info = get_video_info("https://www.youtube.com/watch?v=RTbrXiIzUt4")
print(info["title"], info["views"], info["tags"])
{
"video_id": "RTbrXiIzUt4",
"url": "https://www.youtube.com/watch?v=RTbrXiIzUt4",
"title": "What Is Right To Repair?",
"description": "Do you really own what you buy? ...", # full description, not truncated
"tags": ["Right To Repair", "right to repair", "MKBHD", ...],
"hashtags": [],
"channel_name": "Marques Brownlee",
"channel_id": "UCBJycsmduvYEL83R_U4JriQ",
"channel_url": "http://www.youtube.com/@mkbhd",
"views": 4679645,
"likes": 250306,
"length_seconds": 1215,
"category": "Science & Technology",
"publish_date": "2021-05-07T18:03:28-07:00",
"upload_date": "2021-05-07T18:03:28-07:00",
"thumbnail": "https://i.ytimg.com/vi/RTbrXiIzUt4/maxresdefault.jpg",
"is_live": false,
"is_family_safe": true,
"is_unlisted": false,
"is_private": false
}
Channel info
from YoutubeTags import get_channel_info
print(get_channel_info("https://www.youtube.com/@mkbhd"))
{'channel_id': 'UCBJycsmduvYEL83R_U4JriQ', 'name': 'Marques Brownlee',
'url': 'https://www.youtube.com/channel/UCBJycsmduvYEL83R_U4JriQ',
'description': 'MKBHD: Quality Tech Videos | ...', 'tags': ['MKBHD', 'MarquesBrownlee', 'Marques', 'Brownlee'],
'avatar': 'https://yt3.googleusercontent.com/...', 'subscribers': '1.17M subscribers', 'is_family_safe': 'true'}
Tags as lists, hashtags
from YoutubeTags import videotags_list, channeltags_list, hashtags
videotags_list("RTbrXiIzUt4") # ['Right To Repair', 'right to repair', 'MKBHD', ...]
channeltags_list("@mkbhd") # ['MKBHD', 'MarquesBrownlee', 'Marques', 'Brownlee']
hashtags("https://youtu.be/...") # ['#shorts', '#tech']
Tag ideas from YouTube search autocomplete
from YoutubeTags import tag_suggestions
tag_suggestions("right to repair") # ['right to repair', 'right to repair india', ...]
tag_suggestions("cricket", language="hi", region="IN")
Tag SEO analysis
Checks your tags against YouTube Studio's 500-character limit and finds duplicates.
Accepts a list or the string returned by videotags().
from YoutubeTags import videotags, analyze_tags
analyze_tags(videotags("RTbrXiIzUt4"))
{'count': 10, 'unique_count': 9, 'total_characters': 164, 'character_limit': 500,
'within_limit': True, 'duplicates': ['right to repair'], 'longest': 'right to repair movement',
'average_length': 13.9}
Many videos at once
from YoutubeTags import bulk_videotags
bulk_videotags(["RTbrXiIzUt4", "Kbe3FKeCd1A"], max_workers=4)
# {'RTbrXiIzUt4': [...], 'Kbe3FKeCd1A': [...]} failed links map to None
Error handling
from YoutubeTags import get_video_info, VideoUnavailable, InvalidURL, RequestFailed
try:
get_video_info("https://www.youtube.com/watch?v=xxxxxxxxxxx")
except VideoUnavailable as e:
print(e) # Video xxxxxxxxxxx is unavailable: This video is unavailable
Settings (timeout, retries, language, proxies)
import YoutubeTags
YoutubeTags.configure(timeout=10, retries=3, language="en-US",
proxies={"https": "http://127.0.0.1:8080"})
Defaults: 15 second timeout, 2 retries on network errors / HTTP 429 / 5xx, YouTube picks the language.
Command line
youtubetags https://www.youtube.com/watch?v=RTbrXiIzUt4 # tags
youtubetags RTbrXiIzUt4 Kbe3FKeCd1A --json # several videos, JSON
youtubetags --info RTbrXiIzUt4 # full metadata
youtubetags --analyze RTbrXiIzUt4 # tag SEO analysis
youtubetags --channel @mkbhd # channel tags
youtubetags --suggest "right to repair" # tag ideas
python -m YoutubeTags RTbrXiIzUt4 # same, without the script
Running the tests
pip install -r requirements.txt
python -m unittest discover -s tests -v
The tests use saved HTML, so they never hit YouTube.
License
© 2021 Nuhman Pk , LICENSED under MIT License
Github
Follow me on Github and if you find this library useful don't forget to add Your star
Sponsor this project
Credits : thepythoncode
This Project is based on small Snippet from thepythoncode.com as part of their Web Scrapping Modules. Do check their web site here.
Metadata
Release files for YoutubeTags 1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| youtubetags-1.5.tar.gz | 19.1 kB | Without provenance | Details for youtubetags-1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| youtubetags-1.5-py3-none-any.whl | Python 3 | none | any | Details for youtubetags-1.5-py3-none-any.whl |
Total release size: 33.9 kB
Security for YoutubeTags 1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.