Hab von PHP nicht so Ahnung, aber falls es wem hilft hier in python (Python 2.7.13). NFO von xrel holen, imdb url auslesen und omdbapi. Ohne User-Agent und Referer kommt man wohl nicht an die NFO als Text...
Syntax: xrel.py Releasename
PHP-Code:## -*- coding: utf-8 -*-
import urllib2
import sys
from bs4 import BeautifulSoup
import json
#xrel oeffnen und nfo laden
xrel_url = "https://www.xrel.to/search.html?mode=full&xrel_search_query=" + sys.argv[1]
req = urllib2.Request(xrel_url)
req.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8')
req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36')
req.add_header('Referer', 'https://www.xrel.to/releases.html')
req.add_header('Cookie', 'notice_understood=1')
resp = urllib2.urlopen(req)
content = resp.read()
soup = BeautifulSoup(content)
nfotext = soup.find("div", {"id": "nfo_text"})
nfotext = nfotext.text
print nfotext
print '\n'
#imdb url auslesen
if 'imdb' in nfotext:
imdb_id = nfotext.split("/title/")[-1].split("/")[0].split(" ")[0]
print imdb_id
print '\n'
#omdbapi
url = "http://www.omdbapi.com/?i=" + imdb_id
data = json.load(urllib2.urlopen(url))
try:
title = data["Title"]
except KeyError:
title = ""
try:
year = data["Year"]
except KeyError:
year = ""
try:
genre = data["Genre"]
except KeyError:
genre = ""
try:
runtime = data["Runtime"]
except KeyError:
runtime = ""
try:
rating = data["imdbRating"]
except KeyError:
rating = ""
try:
votes = data["imdbVotes"]
except KeyError:
votes = ""
try:
director = data["Director"]
except KeyError:
director = ""
try:
writer = data["Writer"]
except KeyError:
writer = ""
try:
actors = data["Actors"]
except KeyError:
actors = ""
try:
poster = data["Poster"]
except KeyError:
poster = ""
try:
country = data["Country"]
except KeyError:
country = ""
#Ausgabe
print "Title: " + title
print "Cover: " + poster
print "Genre: " + genre
print "Land/Jahr: " + country + "/" + year
print "Laufzeit: " + runtime
print "Rating: " + rating + "/" + "10" + " (" + votes + " Votes" +")"
print "Regie: " + director
print "Drehbuch: " + writer
print "Darsteller: " + actors




Zitieren