Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. exports.getStreams = function(series_id, callback) {
  2. var self = this;
  3. this.doRequest("series/"+series_id+"/1", function(err,data){
  4. var jsData = JSON.parse(data);
  5. var max_seasons = jsData.series.seasons;
  6. var season_urls = [];
  7. var seasonList = {};
  8.  
  9. for(var i=1; i <= max_seasons; i++) {
  10. seasonList[i] = {};
  11. season_urls.push("series/"+series_id+"/"+i);
  12. }
  13. var i= 0;
  14. async.forEachOf(season_urls, function(val, key, cb){
  15.  
  16. self.doRequest(val, function(err,data){
  17. var seasonData = JSON.parse(data);
  18. seasonData.epi.forEach(function(item){
  19. seasonList[key+1][item.epi] = (item.german);
  20. });
  21. cb();
  22. });
  23. }, function(err){
  24.  
  25. async.forEachOf(seasonList, function(val,seasonKey,cb){
  26. async.forEachOf(seasonList[seasonKey], function(val, episodesKey, epicb){
  27. var data_url = "series/"+series_id+"/"+seasonKey+"/"+episodesKey;
  28. self.doRequest(data_url, function(err,data){
  29. var streamJS = JSON.parse(data);
  30. var streamChoose = streamJS.links;
  31. var stream_id = "";
  32. streamChoose.forEach(function(simpleObj){
  33. if(simpleObj.hoster.toLowerCase() == "streamcloud")
  34. stream_id = (simpleObj.id);
  35. });
  36. if(stream_id.length <= 0) {
  37. seasonList[seasonKey][episodesKey] = false;
  38. return epicb();
  39. }
  40. self.doRequest("watch/"+stream_id, function(err,data){
  41. var stream_data = JSON.parse(data);
  42. seasonList[seasonKey][episodesKey] = (stream_data.fullurl);
  43. return epicb();
  44. });
  45. });
  46. }, function(err){
  47. cb();
  48. });
  49. }, function(err){
  50. console.log(seasonList);
  51. });
  52. });
  53. })
  54. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement