Skip to content

Commit

Permalink
stable v-
Browse files Browse the repository at this point in the history
  • Loading branch information
kalanakt committed Feb 18, 2023
1 parent e41414d commit 9414820
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 78 deletions.
30 changes: 30 additions & 0 deletions helpers/database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from pymongo import MongoClient

# Replace <username>, <password>, and <cluster-name> with your own values
client = MongoClient(
"mongodb+srv://ktu:[email protected]/?retryWrites=true&w=majority")
db = client.database
collection = db.utube_collection


def u_video(video_data, video):
post = {"video_data": video_data, "video": video}
result = collection.insert_one(post)
# This will print the ID of the inserted document
return result.inserted_id


def get_u_video(video_data):
query = {"video_data": video_data}

# Find documents with the given title
results = collection.find(query)

# Print the results
for result in results:
return result


def delete_u_video(video_data):
query = {"video_data": video_data}
collection.delete_one(query)
14 changes: 14 additions & 0 deletions helpers/youtube.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup

def get_youtube_video_id(url):
"""Extracts the video ID from a YouTube URL"""
video_id = None
if 'youtube.com' in url:
video_id = url.split('v=')[-1]
if '&' in video_id:
video_id = video_id.split('&')[0]
elif 'youtu.be' in url:
video_id = url.split('/')[-1]
return video_id

def get_resolution_keyboard(video):
resolutions = {}
for stream in video.streams.filter(progressive=True):
Expand Down Expand Up @@ -28,3 +39,6 @@ def get_filetype_keyboard(video, resolution):
keyboard = InlineKeyboardMarkup([buttons])

return keyboard

async def progress(current, total):
print(f"{current * 100 / total:.1f}%")
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pyrogram.raw import functions, types
from pyrogram import Client, idle
from pyromod import listen
from config import Config

bot = Client(
Expand Down
Loading

0 comments on commit 9414820

Please sign in to comment.