martysmarty

Untitled

Apr 29th, 2019
1,578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. //Get all magazines
  2.  
  3. $data = \Httpful\Request::get("https://d3og6tlt23zks5.cloudfront.net/magazines?ppage=1&per_page=1000000&languages=&sort=publish_date&safe=false")
  4. ->addHeader("Content-Type", "application/json")
  5. ->expectsJson()
  6. ->send();
  7.  
  8. foreach(json_decode($data)->content as $mag){
  9.  
  10. //Process each $mag (Magazine)
  11.  
  12. $data = \Httpful\Request::get("https://d3og6tlt23zks5.cloudfront.net/magazines/$mag->uuid?ppage=1&per_page=1000000")
  13. ->addHeader("Content-Type", "application/json")
  14. ->expectsJson()
  15. ->send();
  16.  
  17. foreach (json_decode($data)->content as $issue) {
  18.  
  19. //Process each magazine issue as you wish. Make sure to save the id and publication
  20.  
  21. $opts = [
  22. "http" => [
  23. "method" => "GET",
  24. "header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/66.0 \r\n" .
  25. "X-AUTH-TOKEN: GET YOUR OWN AUTH TOKEN AND PUT IT HERE\r\n" .
  26. "Referer: https://go.readly.com/magazines/51c1819803c6b7589300009f\r\n"
  27. ]
  28. ];
  29.  
  30. $headers = stream_context_create($opts);
  31. $token = file_get_contents("https://api-eu.readly.com/issue/$issue->uuid/content/token?format=webp&r=2400", false, $headers);
  32.  
  33. $data = \Httpful\Request::get("https://api-eu.readly.com/content/$token")
  34. ->addHeader("Content-Type", "application/json")
  35. ->addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/66.0")
  36. ->addHeader("X-AUTH-TOKEN", "GET YOUR OWN AUTH TOKEN AND PUT IT HERE")
  37. ->addHeader("Referer", "https://go.readly.com/")
  38. ->expectsJson()
  39. ->send();
  40.  
  41.  
  42. $i=1;
  43. foreach(json_decode($data)->content as $page){
  44.  
  45. file_put_contents($i . ".webp",file_get_contents($page));
  46.  
  47. shell_exec("node readly.js $issue->uuid $i .webp");
  48. $i = $i+1;
  49.  
  50. }
  51.  
  52.  
  53. }
  54.  
  55.  
  56. }
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. And readly.js is:
  64.  
  65. var fs = require('fs');
  66.  
  67. function decodeImg(buffer, issueId) {
  68. var data = new Uint8Array(buffer);
  69. for (var i = 0; i <= data.length - 1; i++)
  70. data[i] = data[i] ^ issueId.charCodeAt(i % issueId.length);
  71. return data;
  72. }
  73.  
  74. var issueId = process.argv[2];
  75. var source = process.argv[3];
  76.  
  77. if( issueId && source ) {
  78. var fileBuffer = fs.readFileSync(source);
  79. fs.writeFileSync( 'decoded-' + source, decodeImg(fileBuffer, issueId) );
  80. } else {
  81. console.log('Use: node decode.js [issueId] [fileName]');
  82. }
Advertisement
Add Comment
Please, Sign In to add comment