Skip to content

Instantly share code, notes, and snippets.

@henrydatei
Created August 1, 2023 13:00
Show Gist options
  • Save henrydatei/3b24f82597d41f50b501202f56dd64e4 to your computer and use it in GitHub Desktop.
Save henrydatei/3b24f82597d41f50b501202f56dd64e4 to your computer and use it in GitHub Desktop.
Searches xrel.to to find a release for a movie which is between 7.5 GB and 12 GB big
import requests
from bs4 import BeautifulSoup
def getSceneReleases(link):
newLink = link.split(".html")[0] + "/releases.html"
cookies = {"notice_understood":"1"}
r2 = requests.get(newLink, cookies = cookies)
soup = BeautifulSoup(r2.text, features = "lxml")
sceneReleases = soup.find_all("div", {"class": "release_item"})
liste = []
for release in sceneReleases:
type = release.find_all("div", {"class": "release_cat"})[0].a.span.string
try:
title = release.find_all("div", {"class": "release_title"})[0].div.a["title"]
except:
continue
videoAudio = release.find_all("div", {"class": "release_type"})[0].get_text()
video = videoAudio.split(" ")[1]
audio = videoAudio.split(" ")[2]
size = release.find_all("div", {"class": "release_grp"})[0].span.string.split(" ")[0]
data = {"type": type, "release": title, "video": video, "audio": audio, "size": int(size)}
liste.append(data)
return liste
def getP2PReleases(link):
number = link.split("/")[4]
name = link.split("/")[5].split(".")[0]
newLink = "https://www.xrel.to/p2p/movie-{}-{}/releases.html".format(number, name)
cookies = {"notice_understood":"1"}
r2 = requests.get(newLink, cookies = cookies)
soup = BeautifulSoup(r2.text, features = "lxml")
sceneReleases = soup.find_all("div", {"class": "release_item"})
liste = []
for release in sceneReleases:
type = release.find_all("div", {"class": "release_cat"})[0].a.span.string
try:
title = release.find_all("div", {"class": "release_title_p2p"})[0].div.a["title"]
except:
continue
video = 0
audio = 0
size = release.find_all("div", {"class": "release_grp"})[0].span.string.split(" ")[0]
data = {"type": type, "release": title, "video": video, "audio": audio, "size": int(size)}
liste.append(data)
return liste
search = input("Keyword: ")
type = input("Type (movie|tv|game|console|software|xxx - or leave empty to search Ext Infos of all types): ")
params = {"q": search, "type": type, "limit": 1}
r = requests.get("https://xrel-api.nfos.to/v2/search/ext_info.json", params = params)
link = r.json()["results"][0]["link_href"]
allReleases = []
allReleases.extend(getSceneReleases(link))
allReleases.extend(getP2PReleases(link))
for release in allReleases:
if 7500 <= release["size"] and release["size"] <= 12000:
print(release["release"], release["size"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment