Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Get all magazines
- $data = \Httpful\Request::get("https://d3og6tlt23zks5.cloudfront.net/magazines?ppage=1&per_page=1000000&languages=&sort=publish_date&safe=false")
- ->addHeader("Content-Type", "application/json")
- ->expectsJson()
- ->send();
- foreach(json_decode($data)->content as $mag){
- //Process each $mag (Magazine)
- $data = \Httpful\Request::get("https://d3og6tlt23zks5.cloudfront.net/magazines/$mag->uuid?ppage=1&per_page=1000000")
- ->addHeader("Content-Type", "application/json")
- ->expectsJson()
- ->send();
- foreach (json_decode($data)->content as $issue) {
- //Process each magazine issue as you wish. Make sure to save the id and publication
- $opts = [
- "http" => [
- "method" => "GET",
- "header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/66.0 \r\n" .
- "X-AUTH-TOKEN: GET YOUR OWN AUTH TOKEN AND PUT IT HERE\r\n" .
- "Referer: https://go.readly.com/magazines/51c1819803c6b7589300009f\r\n"
- ]
- ];
- $headers = stream_context_create($opts);
- $token = file_get_contents("https://api-eu.readly.com/issue/$issue->uuid/content/token?format=webp&r=2400", false, $headers);
- $data = \Httpful\Request::get("https://api-eu.readly.com/content/$token")
- ->addHeader("Content-Type", "application/json")
- ->addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/66.0")
- ->addHeader("X-AUTH-TOKEN", "GET YOUR OWN AUTH TOKEN AND PUT IT HERE")
- ->addHeader("Referer", "https://go.readly.com/")
- ->expectsJson()
- ->send();
- $i=1;
- foreach(json_decode($data)->content as $page){
- file_put_contents($i . ".webp",file_get_contents($page));
- shell_exec("node readly.js $issue->uuid $i .webp");
- $i = $i+1;
- }
- }
- }
- And readly.js is:
- var fs = require('fs');
- function decodeImg(buffer, issueId) {
- var data = new Uint8Array(buffer);
- for (var i = 0; i <= data.length - 1; i++)
- data[i] = data[i] ^ issueId.charCodeAt(i % issueId.length);
- return data;
- }
- var issueId = process.argv[2];
- var source = process.argv[3];
- if( issueId && source ) {
- var fileBuffer = fs.readFileSync(source);
- fs.writeFileSync( 'decoded-' + source, decodeImg(fileBuffer, issueId) );
- } else {
- console.log('Use: node decode.js [issueId] [fileName]');
- }
Advertisement
Add Comment
Please, Sign In to add comment