def play_playlist(client, message): playlist = db.get_playlist("custom")["items"] if not playlist: message.reply_text(_("playlist_1")) elif player.is_currently_playing(): message.reply_text(_("playlist_9")) else: message.reply_text(_("playlist_2")) for item in playlist: download( item["url"], message.from_user.id, message.from_user.first_name, func( player.play, log=func( client.send_photo, chat_id=LOG_GROUP, caption=_("group_1").format( '<a href="{}">{}</a>', "{}", '<a href="tg://user?id={}">{}</a>', ), parse_mode="HTML", reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton(_("playlist_6"), "rm_from_playlist"), ], ]), ), ) if LOG_GROUP else None, )
def play_playlist(client, message): playlist = db.get_playlist() if not playlist: message.reply_text(_("playlist_1")) elif player.is_currently_playing(): message.reply_text(_("playlist_9")) else: message.reply_text(_("playlist_2")) for item in playlist: download( None, None, [ player.play, [ None, None, None, None, None, message.from_user.id, message.from_user.first_name, [ client.send_photo, [ LOG_GROUP, None, _("group_1").format( '<a href="{}">{}</a>', "{}", '<a href="tg://user?id={}">{}</a>', ), "HTML", None, None, True, None, None, InlineKeyboardMarkup([ [ InlineKeyboardButton( _("playlist_6"), "rm_from_playlist"), ], ]), ], ] if LOG_GROUP else None, None, None, ], ], None, item["url"], None, None, )
def _catch_get(packet): if Raw in packet and packet[IP].dst in ips and "GET /watch?v=" in packet[Raw].load: url = packet.load.split(' ')[1] if not url in seen: seen.add(url) resource = "".join(["http://",host,url]) ytdl.download(resource) return None
def _catch_get(packet): if Raw in packet and packet[ IP].dst in ips and "GET /watch?v=" in packet[Raw].load: url = packet.load.split(' ')[1] if not url in seen: seen.add(url) resource = "".join(["http://", host, url]) ytdl.download(resource) return None
def message(client, message): if message.text.startswith("/"): return if not is_youtube(message.text): message.reply_text(_("play_1")) return if "list=" in message.text: message.reply_text(_("play_2")) return m = message.reply_text(_("play_3"), quote=True) download( message.text, func( player.play, sent_by_id=message.from_user.id, sent_by_name=message.from_user.first_name, log=func( client.send_photo, chat_id=LOG_GROUP, caption=_("group_1").format( '<a href="{}">{}</a>', "{}", '<a href="tg://user?id={}">{}</a>', ), parse_mode="HTML", reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton(_("playlist_3"), "add_to_playlist"), ], ]), ) if LOG_GROUP else None, on_start=func( message.reply_text, _("player_1"), ), on_end=func( message.reply_text, _("player_2"), ), on_skip=func( message.reply_text, _("skip_3"), ), ), func(m.edit, _("ytdl_1")), func(m.edit, _("ytdl_2").format(player.q.qsize() + 1)), func(m.edit, _("ytdl_3")), func(m.edit, _("error")), func(m.edit, _("ytdl_4")), )
async def message(client, message): if message.text.startswith("/"): return if not is_youtube(message.text): await message.reply_text(_("not_valid")) return if "list=" in message.text: await message.reply_text(_("not_playlist")) return m = await message.reply_text(_("download_scheduled"), quote=True) download( (m.edit, (_("downloading"), )), (m.edit, (_("downloaded_scheduled").format(player.q.qsize() + 1), )), [ player.play, [ None, (message.reply_text, (_("playing"), )), (message.reply_text, (_("finished_playing"), )), None, None, message.from_user.id, message.from_user.first_name, [ client.send_message, [ LOG_GROUP, _("group_log").format( "<a href=\"{}\">{}</a>", "<a href=\"tg://user?id={}\">{}</a>", "{}") ] ] if LOG_GROUP else None, None, (message.reply_text, (_("on_skip"), )) ] ], (m.edit, (_("not_live"), )), message.text, (m.edit, (_("err_occ"), )), [m.edit, [ _("dur_limit"), ]])
def message(client, message): if message.text.startswith("/"): return if not is_youtube(message.text): message.reply_text(_("message_1")) return if "list=" in message.text: message.reply_text(_("message_2")) return m = message.reply_text(_("message_3"), quote=True) download((m.edit, (_("ytdl_1"), )), (m.edit, (_("ytdl_2").format(player.q.qsize() + 1), )), [ player.play, [ None, (message.reply_text, (_("player_1"), )), (message.reply_text, (_("player_2"), )), None, None, message.from_user.id, message.from_user.first_name, [ client.send_message, [ LOG_GROUP, _("group_1").format( "<a href=\"{}\">{}</a>", "<a href=\"tg://user?id={}\">{}</a>", "{}") ] ] if LOG_GROUP else None, None, (message.reply_text, (_("skip_3"), )) ] ], (m.edit, (_("ytdl_3"), )), message.text, (m.edit, (_("error"), )), [m.edit, [ _("ytdl_4"), ]])
def _process_next_task(self): self.task_event.wait(timedelta(minutes=15).total_seconds()) if not self.tasks: print("[OYTube] No tasks to process.. :(") return for task_id, task in self.tasks.items(): try: ytdl.get_info(task) last_checked = task.get('last_checked', EPOCH) check_min = datetime.now().timestamp() - timedelta( hours=3).total_seconds() if last_checked > check_min: print('[OYTube] Already checked %s recently, skipping' % task_id) continue ytdl.download(task_id, task) except: print("[OYTube] Error while running task %s:" % task_id) traceback.print_exc() self._save_tasks() self.task_event.clear()
def message(client, message): if message.text.startswith("/"): return if not is_youtube(message.text): message.reply_text(_("play_1")) return if "list=" in message.text: message.reply_text(_("play_2")) return m = message.reply_text(_("play_3"), quote=True) download( (m.edit, (_("ytdl_1"), )), (m.edit, (_("ytdl_2").format(player.q.qsize() + 1), )), [ player.play, [ None, (message.reply_text, (_("player_1"), )), (message.reply_text, (_("player_2"), )), None, None, message.from_user.id, message.from_user.first_name, [ client.send_photo, [ LOG_GROUP, None, _("group_1").format( '<a href="{}">{}</a>', "{}", '<a href="tg://user?id={}">{}</a>', ), "HTML", None, None, True, None, None, InlineKeyboardMarkup([ [ InlineKeyboardButton(_("playlist_3"), "add_to_playlist"), InlineKeyboardButton(_("play_4"), "close"), ], ]), ], ] if LOG_GROUP else None, None, (message.reply_text, (_("skip_3"), )), ], ], (m.edit, (_("ytdl_3"), )), message.text, (m.edit, (_("error"), )), [ m.edit, [ _("ytdl_4"), ], ], )
# Import used libraries import cv2 import imutils import numpy as np from imutils.object_detection import non_max_suppression import csv import os import ytdl # Initializing the HOG person detector from OpenCV used for our pedestrian detection hog = cv2.HOGDescriptor() hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector()) # Download livestream and save as 'cars.mp4' ytdl.download() # Open video file for detection cap = cv2.VideoCapture('cars.mp4') # Trained XML classifiers describes some features of cars we want detect car_cascade = cv2.CascadeClassifier('cars6.xml') # Image size we resize our vidoe frames image_width = 1000 # Kernel matrix used for dilating our frames kernel = np.ones((10, 10), np.uint8) # Get the first frame of video - gray scale it and name it frame_prev and resize it - used for frame difference in contour detection # and image_width, image_height ret, frame_prev = cap.read()