Skip to content

Commit

Permalink
v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Itz-fork authored Aug 4, 2021
0 parents commit 14a0acd
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2021 Itz-fork

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 4 additions & 0 deletions PyYtX/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) 2021 Itz-fork
# Part of PyYtX Project

from .ythumb import PyYtX
34 changes: 34 additions & 0 deletions PyYtX/ythumb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2021 Itz-fork
# Part of PyYt Project

import logging
from urllib.parse import urlparse, parse_qs

logger = logging.getLogger(__name__)

class PyYtX:
def get_thumb(url=None):
url = url
if url is None:
logging.error("Url Isn't Provided")
# Getting Video Id from given Url
logging.info("Getting Video ID From Url")
Yt_Vid_Id = PyYtX.extract_video_id(url)
if Yt_Vid_Id is None:
logging.error("Given Url is not a Youtube Url")
else:
max_thumb = f"https://img.youtube.com/vi/{Yt_Vid_Id}/maxresdefault.jpg"
standered_thumb = f"https://img.youtube.com/vi/{Yt_Vid_Id}/sddefault.jpg"
return max_thumb, standered_thumb

def extract_video_id(url):
query = urlparse(url)
try:
if query.hostname == 'youtu.be': return query.path[1:]
if query.hostname in {'www.youtube.com', 'youtube.com'}:
if query.path == '/watch': return parse_qs(query.query)['v'][0]
if query.path[:7] == '/watch/': return query.path.split('/')[1]
if query.path[:7] == '/embed/': return query.path.split('/')[2]
if query.path[:3] == '/v/': return query.path.split('/')[2]
except:
return None
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wget
37 changes: 37 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) 2021 Itz-fork
# Part of PyYtX Project

import os
from setuptools import setup, find_packages

# Allow Exec. from any path (Credits: mega.py)
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

# Getting the requirements
with open('requirements.txt') as req:
reques = req.read().splitlines()


setup(name='PyYtX',
version='0.1',
description='A Simple Python Program to Get Best Possible Thumbnail Urls From a Youtube Video Link',
url='https://github.com/Itz-fork/PyYtX',
author='Itz-fork',
author_email='itz-fork@users.noreply.github.com',
license='MIT',
packages=find_packages('PyYtX'),
download_url="https://github.com/Itz-fork/PyYtX/archive/refs/tags/v0.1.tar.gz",
keywords=['python', 'youtube', 'PyYt'],
install_requires=reques,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.9',
],
)

0 comments on commit 14a0acd

Please sign in to comment.