Created
April 1, 2017 12:28
-
-
Save rubyon/83b7da599330e74258402a38da7250b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$JSONOutput = array(); | |
$TotalResults = 0; | |
$loginUrl = 'https://bezze.me/login.php'; | |
// init curl | |
$ch = curl_init(); | |
// Set the URL to work with | |
curl_setopt($ch, CURLOPT_URL, $loginUrl); | |
// ENABLE HTTP POST | |
curl_setopt($ch, CURLOPT_POST, 1); | |
// Set the post parameters | |
curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=' . $_GET["user"] . '&password=' . $_GET["passkey"]); | |
// Handle cookies for the login | |
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); | |
// Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL | |
// not to print out the results of its query. | |
// Instead, it will return the results as a string return value | |
// from curl_exec() instead of the usual true/false. | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
// execute the request (the login) | |
$store = curl_exec($ch); | |
// the login is now done and you can continue to get the | |
// protected content. | |
// set the URL to the protected file | |
curl_setopt($ch, CURLOPT_URL, 'https://bezze.me/torrents.php?filter_cat%5B2%5D=1&filter_cat%5B3%5D=1&filter_cat%5B4%5D=1&searchstr=' . $_GET["search"]); | |
// execute the request | |
$response = curl_exec($ch); | |
$response = str_replace(" class=\"r00\"", "", $response); | |
$wurl = 'https://bezze.me/'; | |
$regexp_get_auth_pass = "user=(.*)&auth=(.*)&passkey=(.*)&authkey=(.*)\""; | |
preg_match("/$regexp_get_auth_pass/siU", $response, $match_auth_pass); | |
$t_user = $match_auth_pass[1]; | |
$t_auth = $match_auth_pass[2]; | |
$t_passkey = $match_auth_pass[3]; | |
$t_authkey = $match_auth_pass[4]; | |
/* | |
echo("User: " . $t_user); | |
echo("Auth: " . $t_auth); | |
echo("Passkey: " . $t_passkey); | |
echo("Authkey: " . $t_authkey); | |
*/ | |
$cut_start = stripos($response, '<table class="torrent_table grouping" id="torrent_table">'); | |
$response = substr($response, $cut_start); | |
$response = preg_replace('/(\s+)/is', ' ', $response); | |
$response = $response . "<tr class=\"group\">"; | |
// echo("Response: " . $response); | |
$regexp2 = "<td class=\"center\">(.*)<tr class=\"group\">"; | |
$regexp_category = "<td class=\"center cats_col\"> <div title=\"(.*)\" class=\"cats_"; | |
$regexp_title = "<td colspan=\"2\" class=\"list_title\">(.*)<\/font>"; | |
$regexp_reso = "\/ (SD|720p|1080i|1080p|2160i|2160p|NTSC|PAL|Other) \/"; | |
$regexp_media = "\/ (SDTV|HDTV|CATV|IPTV|DVD|Blu-Ray|BRRip|BDRip|HD-DVD|CAM.TS|TC|R5|Screener|WebRip|WebDL|Portable|Unknown|Mixed|Other) \/"; | |
if (preg_match_all("/$regexp2/siU", $response, $regexp2_matches, PREG_SET_ORDER)) { | |
foreach($regexp2_matches as $regexp2_match) { | |
$title = "Unknown title"; | |
$category = "Unknown category"; | |
// echo("Sub Response: " . $regexp2_match[0]); | |
if (preg_match_all("/$regexp_category/siU", $regexp2_match[0], $regexp_category_matches, PREG_SET_ORDER)) { | |
foreach($regexp_category_matches as $regexp_category_match) { | |
$category = $regexp_category_match[1]; | |
// echo("########## Category: " . $category . "<br />"); | |
} | |
} | |
if (preg_match_all("/$regexp_title/siU", $regexp2_match[0], $regexp_title_matches, PREG_SET_ORDER)) { | |
foreach($regexp_title_matches as $regexp_title_match) { | |
$title = str_replace(" ", " ", strip_tags($regexp_title_match[1])); | |
// echo("Title: " . $title); | |
} | |
} | |
if ($title != "Unknown title") { | |
$regexp3 = "<tr class=\"group_torrent groupid_(.*)\"> <td colspan=\"4\">(.*)<\/tr>"; | |
$regexp_title2 = "torrentid=(.*)\">(.*)<\/a>"; | |
$regexp_download = "<a href=\"(.*)\" title=\"Download\">"; | |
$regexp_size = "<\/span><\/td> <td class=\"nobr\">([0-9\,\.]+) (GB|MB|KB|TB)<\/td> <td>(.*)<\/td> <td>(.*)<\/td> <td>(.*)<\/td>"; | |
$regexp_time = "<span class=\"time\" title=\"(.*), (.*):(.*):(.*)\">"; | |
if (preg_match_all("/$regexp3/siU", $regexp2_match[0], $regexp3_matches, PREG_SET_ORDER)) { | |
foreach($regexp3_matches as $regexp3_match) { | |
$title2 = "Unknown title"; | |
$download = "Unknown download"; | |
$torrent_id = "0"; | |
$size = 0; | |
$datetime = "2016-10-29"; | |
$page = "Default page"; | |
$hash = "Hash unknown"; | |
$seeds = 0; | |
$leechs = 0; | |
// echo("Sub Match: " . $regexp3_match[0]); | |
if (preg_match_all("/$regexp_reso/siU", $regexp3_match[0], $regexp_reso_matches, PREG_SET_ORDER)) { | |
foreach($regexp_reso_matches as $regexp_reso_match) { | |
$reso = $regexp_reso_match[1]; | |
// echo("########## Reso: " . $reso . "<br />"); | |
} | |
} | |
if (preg_match_all("/$regexp_media/siU", $regexp3_match[0], $regexp_media_matches, PREG_SET_ORDER)) { | |
foreach($regexp_media_matches as $regexp_media_match) { | |
$media = $regexp_media_match[1]; | |
// echo("########## Media: " . $media . "<br />"); | |
} | |
} | |
if (preg_match_all("/$regexp_download/siU", $regexp3_match[0], $regexp_download_matches, PREG_SET_ORDER)) { | |
foreach($regexp_download_matches as $regexp_download_match) { | |
$download = $wurl . $regexp_download_match[1]; | |
$download = str_replace("&", "&", $download); | |
$regexp_download_id = "torrentid=(.*)\">"; | |
if (preg_match_all("/$regexp_download_id/siU", $regexp3_match[0], $regexp_download_id_matches, PREG_SET_ORDER)) { | |
foreach($regexp_download_id_matches as $regexp_download_id_match) { | |
$page = "https://bezze.me/torrents.php?torrentid=$regexp_download_id_match[1]"; | |
$torrent_id = $regexp_download_id_match[1]; | |
} | |
} | |
/* | |
echo("Page: " . $page); | |
echo("Download: " . $download . "&force=1"); | |
*/ | |
} | |
} | |
if (preg_match_all("/$regexp_title2/siU", $regexp3_match[0], $regexp_title2_matches, PREG_SET_ORDER)) { | |
foreach($regexp_title2_matches as $regexp_title2_match) { | |
$title2 = $title . " : " . $regexp_title2_match[2]; | |
$regexp_icon = "<img src=\"(.*)\" class=\"(.*)\" title=\"(.*)\" \/>"; | |
$icon = ""; | |
if (preg_match_all("/$regexp_icon/siU", $title2, $regexp_icon_matches, PREG_SET_ORDER)) { | |
foreach($regexp_icon_matches as $regexp_icon_match) { | |
$icon = $icon . " " . trim($regexp_icon_match[3]); | |
// echo("Change Title: " . $icon); | |
} | |
} | |
$title2 = $title2 . " " . $icon; | |
$title2 = strip_tags($title2); | |
$title2 = str_replace(" ", "", $title2); | |
// echo("Title: " . $title2); | |
if ($download == "Unknown download") { | |
$regexp_download_id = "torrentid=(.*)\">"; | |
if (preg_match_all("/$regexp_download_id/siU", $regexp3_match[0], $regexp_download_id_matches, PREG_SET_ORDER)) { | |
foreach($regexp_download_id_matches as $regexp_download_id_match) { | |
$download = "https://bezze.me/torrents.php?action=download&id=$regexp_download_id_match[1]&authkey=$t_authkey&torrent_pass=$t_passkey"; | |
$page = "https://bezze.me/torrents.php?torrentid=$regexp_download_id_match[1]"; | |
} | |
} | |
/* | |
echo("Page: " . $page); | |
echo("Download: " . $download); | |
*/ | |
} | |
} | |
} | |
if (preg_match_all("/$regexp_time/siU", $regexp3_match[0], $regexp_time_matches, PREG_SET_ORDER)) { | |
foreach($regexp_time_matches as $regexp_time_match) { | |
$datetime = $regexp_time_match[1]; | |
// echo("Datetime: " . $datetime); | |
} | |
} | |
if (preg_match_all("/$regexp_size/siU", $regexp3_match[0], $regexp_size_matches, PREG_SET_ORDER)) { | |
foreach($regexp_size_matches as $regexp_size_match) { | |
$size = str_replace(",", "", $regexp_size_match[1]); | |
/* | |
echo("########## Size: " . $size . "<br />"); | |
echo("########## Unit: " . trim($regexp_size_match[2]) . "<br />"); | |
*/ | |
switch (trim($regexp_size_match[2])) { | |
case 'KB': | |
$size = $size * 1024; | |
break; | |
case 'MB': | |
$size = $size * 1024 * 1024; | |
break; | |
case 'GB': | |
$size = $size * 1024 * 1024 * 1024; | |
break; | |
case 'TB': | |
$size = $size * 1024 * 1024 * 1024 * 1024; | |
break; | |
} | |
$size = round(intval($size) / 1024 / 1024, 0); | |
/* | |
echo("Seeds: " . $regexp_size_match[4]); | |
echo("Peers: " . $regexp_size_match[5]); | |
*/ | |
$seeds = $regexp_size_match[4]; | |
$leechs = $regexp_size_match[5]; | |
} | |
} | |
if ($title2 != "Unknown title") { | |
$Details = array( | |
"movie_name" => trim($title) , | |
"movie_year" => substr($datetime, 0, 4) , | |
"release_name" => trim($title2) , | |
"media" => $media, | |
"resolution" => $reso, | |
"torrent_id" => $torrent_id, | |
"details_url" => $page, | |
"download_url" => $download . "&force=1", | |
"imdb_id" => $_GET["imdbid"], | |
"type" => $category, | |
"resolution" => $reso, | |
"size" => $size, | |
"leechers" => $leechs, | |
"seeders" => $seeds, | |
"publish_date" => $datetime . 'T00:00:00Z' | |
); | |
array_push($JSONOutput, $Details); | |
$TotalResults++; | |
} | |
} | |
} | |
} | |
} | |
} | |
if ($TotalResults == 0) { | |
echo json_encode(array( | |
"total_results" => $TotalResults | |
)); | |
} | |
else { | |
echo json_encode(array( | |
"results" => $JSONOutput, | |
"total_results" => $TotalResults | |
) , JSON_UNESCAPED_SLASHES); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment