Skip to content

Commit 9a23eaf

Browse files
committed
Yts Discord Bot
1 parent 5419a32 commit 9a23eaf

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

Yts Discord Bot/Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
worker: python yts.py

Yts Discord Bot/commands.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Command Description Example
2+
3+
search searches for the movie $search Avengers
4+
ping responds with pong followed by latency $ping
5+
watching sets bot status to the given movie $watching Avengers
6+
clear delete messages on channel $clear

Yts Discord Bot/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
discord.py==1.7.1
2+
requests==2.25.0

Yts Discord Bot/yts.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import requests, discord
2+
from discord.ext import commands
3+
4+
client = commands.Bot(command_prefix='$')
5+
6+
async def machine(search_mov):
7+
raw_query = requests.get(f'https://yts.mx/api/v2/list_movies.json?query_term={search_mov}').json()
8+
finalResult = ""
9+
setStatus = ""
10+
# print(f"{raw_query['data']['movie_count']} Results Found!!!")
11+
finalResult += f"**{raw_query['data']['movie_count']} Result(s) Found!!!**\n\n"
12+
13+
if raw_query['data']['movie_count']!=0:
14+
setStatus += raw_query['data']['movies'][0]['title_english']
15+
for movie in raw_query['data']['movies']:
16+
# print(f"Name: {movie['title_long']}")
17+
finalResult += f"**Name:** {movie['title_long']}\n"
18+
# print('Genres: ', end='')
19+
finalResult += '**Genres:** '
20+
for genre in movie['genres']:
21+
# print(f'{genre}\t')
22+
finalResult += f'{genre}\t'
23+
# print(f"\n\nSummary: {movie['summary']}")
24+
finalResult += f"\n**Summary:** {movie['summary']}\n"
25+
for torrent in movie['torrents']:
26+
# print(f"{torrent['quality']} {torrent['type']} {torrent['size']}")
27+
finalResult += f"**Quality | Size:** {torrent['quality']} {torrent['type']} | {torrent['size']}\n"
28+
# print(f"Magnet URL: magnet:?xt=urn:btih:{torrent['hash']}&dn={movie['title_long']} {torrent['quality']} {torrent['type']}&tr=udp://open.demonii.com:1337/announce&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.coppersurfer.tk:6969&tr=udp://glotorrents.pw:6969/announce&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://torrent.gresille.org:80/announce&tr=udp://p4p.arenabg.com:1337&tr=udp://tracker.leechers-paradise.org:6969")
29+
finalResult += f"**Magnet URL:** magnet:?xt=urn:btih:{torrent['hash']}&dn={movie['title_long']} {torrent['quality']} {torrent['type']}&tr=udp://open.demonii.com:1337/announce&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.coppersurfer.tk:6969&tr=udp://glotorrents.pw:6969/announce&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://torrent.gresille.org:80/announce&tr=udp://p4p.arenabg.com:1337&tr=udp://tracker.leechers-paradise.org:6969\n\n"
30+
finalResult += '-'*100 + '\n\n'
31+
return (finalResult, setStatus)
32+
33+
@client.event
34+
async def on_ready():
35+
print("Bot Ready!")
36+
37+
@client.command()
38+
async def search(ctx, mov1="", mov2="", mov3="", mov4="", mov5="", mov6="", mov7="", mov8="", mov9="", mov10=""):
39+
search_mov = mov1 + " " + mov2 + " " + mov3 + " " + mov4 + " " + mov5 + " " + mov6 + " " + mov7 + " " + mov8 + " " + mov9 + " " + mov10
40+
if mov1 == "":
41+
await ctx.send(f"Please Enter **Movie** Name, like: `/search The Vault`")
42+
else:
43+
(finalResult, setStatus) = await machine(search_mov)
44+
await watching(ctx, setStatus)
45+
if len(finalResult)>2000:
46+
chunk=0
47+
while True:
48+
try:
49+
await ctx.send(f"{finalResult[chunk:2000+chunk]}")
50+
chunk += 2000
51+
except discord.errors.HTTPException:
52+
pass
53+
except:
54+
await ctx.send(f'{finalResult[chunk:]}')
55+
break
56+
else:
57+
await ctx.send(f"{finalResult}")
58+
59+
@client.command()
60+
async def ping(ctx):
61+
latency = str(int(client.latency * 1000))
62+
await ctx.send(f'Pong :)\t{latency}ms')
63+
64+
@client.command()
65+
async def watching(ctx, setStatus):
66+
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=setStatus.upper()))
67+
68+
@client.command()
69+
async def clear(ctx, amount=5):
70+
await ctx.channel.purge(limit=amount+1)
71+
72+
client.run("Your Token Here")

0 commit comments

Comments
 (0)