@minermaniac447/

Get Youtube Link from Search Query (sync)

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.57848169944684","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHJlcXVlc3RzCmltcG9ydCByZQoKZGVmIHl0c2VhcmNoKG51bSwgcXVlcnkpOgogICAgaHRtbCA9IHJlcXVlc3RzLmdldCgiaHR0cHM6Ly95b3V0dWJlLmNvbS9yZXN1bHRzP3NlYXJjaF9xdWVyeT17fSIuZm9ybWF0KHF1ZXJ5KSkKICAgIGh0bWwgPSBzdHIoaHRtbC5jb250ZW50KQogICAgZHJlc3VsdHMgPSAocmUuZmluZGFsbCgnaHJlZj1cIi93YXRjaFw/dj0oLnsxMX0pJywgaHRtbCkpCiAgICByZXN1bHRzID0gW10KICAgIGZvciByZXN1bHQgaW4gZHJlc3VsdHM6CiAgICAgICAgaWYgcmVzdWx0IGluIHJlc3VsdHM6CiAgICAgICAgICAgIGNvbnRpbnVlCiAgICAgICAgZWxzZToKICAgICAgICAgICAgcmVzdWx0cy5hcHBlbmQocmVzdWx0KQogICAgaWYgbnVtID4gbGVuKHJlc3VsdHMpOgogICAgICAgIG51bSA9IGxlbihyZXN1bHRzKQogICAgZm9yIHggaW4gcmFuZ2UobnVtKToKICAgICAgICBsaW5rID0gImh0dHBzOi8veW91dHUuYmUvIiArIHJlc3VsdHNbeF0KICAgICAgICBwcmludChsaW5rKQoKcXVlcnkgPSBpbnB1dCgicGxzXG4iKQpudW0gPSBpbnB1dCgiaG93IG1uYXkgdmlkZXlveiBkbyB5ZXcgd2FudFxuIikKCnRyeToKICAgIG51bSA9IGludChudW0pCmV4Y2VwdCBFeGNlcHRpb246CiAgICBudW0gPSAxCgp5dHNlYXJjaChudW0sIHF1ZXJ5KQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests
import re

def ytsearch(num, query):
    html = requests.get("https://youtube.com/results?search_query={}".format(query))
    html = str(html.content)
    dresults = (re.findall('href=\"/watch\?v=(.{11})', html))
    results = []
    for result in dresults:
        if result in results:
            continue
        else:
            results.append(result)
    if num > len(results):
        num = len(results)
    for x in range(num):
        link = "https://youtu.be/" + results[x]
        print(link)

query = input("pls\n")
num = input("how mnay videyoz do yew want\n")

try:
    num = int(num)
except Exception:
    num = 1

ytsearch(num, query)