新传媒下载

toggle video

  1. // ==UserScript==
  2. // @name 新传媒下载
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description toggle video
  6. // @author cw2012
  7. // @match https://www.mewatch.sg/season/*
  8. // @match https://www.mewatch.sg/show/*
  9. // @icon https://static.mewatch.sg/favicon.png
  10. // @grant GM_xmlhttpRequest
  11. // @grant GM_addStyle
  12. // @grant GM_download
  13. // @grant GM_setClipboard
  14. // @connect kaltura.com
  15. // @connect mewatch.sg
  16. // @license MIT
  17. // ==/UserScript==
  18.  
  19. (function() {
  20. 'use strict';
  21.  
  22. init();
  23. let seasonId = location.href.split('/')[4].split('-')
  24. seasonId = seasonId[seasonId.length - 1];
  25.  
  26. GM_xmlhttpRequest({
  27. url:`https://cdn.mewatch.sg/api/page?ff=idp,ldp,rpt,cd&item_detail_expand=all&item_detail_select_season=first&lang=en&list_page_size=24&max_list_prefetch=3&path=/${location.href.split('/')[3]}/${location.href.split('/')[4]}&segments=all&sub=Anonymous&text_entry_format=html`,
  28. method:'get',
  29. onload:res=>{
  30. res = JSON.parse(res.responseText);
  31. res = res.item.episodes.items;
  32. getEposidesAndDownload(res)
  33. },
  34. onerror: err=>{
  35. console.log(err)
  36. }
  37. })
  38. let episodeList = []
  39. function getEposidesAndDownload(res){
  40. if(res.length){
  41. res.forEach((item,index)=>{
  42. episodeList[index] = {
  43. id:item.customId ,
  44. num:item.episodeNumber ,
  45. subtitle:item.hasClosedCaptions ,
  46. free:item.badge ?(item.badge === 'premium'):true
  47. }
  48. });
  49. let box = document.createElement('div');
  50. box.className = 'epList';
  51. episodeList.forEach((item,index)=>{
  52. let a = document.createElement('a');
  53. a.text = index+1;
  54. if(!item.free){
  55. a.className = 'premium';
  56. }
  57. a.addEventListener('click',aClicked);
  58. box.append(a);
  59. })
  60. document.body.append(box);
  61. }else{
  62. Toast('没有获取到集数数据')
  63. }
  64. }
  65.  
  66. function aClicked(e){
  67. let index = e.target.innerText - 1;
  68. getEposideInfoAndDownload(index+1,episodeList[index].id)
  69. }
  70.  
  71. function getEposideInfoAndDownload(index,id){
  72. let data = {
  73. "1":{
  74. "service":"ottuser",
  75. "action":"anonymousLogin",
  76. "partnerId":"147"
  77. },
  78. "2":{
  79. "service":"asset",
  80. "action":"get",
  81. "id":id,
  82. "assetReferenceType":"media",
  83. "ks":"{1:result:ks}"
  84. },
  85. "3":{
  86. "service":"asset",
  87. "action":"getPlaybackContext",
  88. "assetId":id,
  89. "assetType":"media",
  90. "contextDataParams":{
  91. "objectType":"KalturaPlaybackContextOptions",
  92. "context":"PLAYBACK"
  93. },
  94. "ks":"{1:result:ks}"
  95. },
  96. "apiVersion":"5.2.6",
  97. "partnerId":"147"
  98. };
  99. GM_xmlhttpRequest({
  100. url:'https://rest-as.ott.kaltura.com/api_v3/service/multirequest',
  101. method:'post',
  102. headers: {"Content-Type": "application/json"},
  103. data:JSON.stringify (data),
  104. onload:res=>{
  105. res = JSON.parse(res.responseText);
  106. if(res.result && !res.result.error && res.result.length){
  107. res = res.result;
  108. let videoUrl;
  109. res.forEach((item)=>{
  110. if(item.sources){
  111. const sources = item.sources;
  112. if(!sources.length){
  113. Toast('无法获取第'+(index)+'集视频资源,可能是付费视频');
  114. return;
  115. }
  116. sources.forEach(source=>{
  117. if(source.type.endsWith('Clear') &&(source.drm.length === 0) && source.type.startsWith('DASH')){
  118. videoUrl = source.url
  119. }
  120. })
  121. }
  122. });
  123. if(videoUrl){
  124. GM_setClipboard(videoUrl);
  125. Toast(`第${index}集地址已复制到剪切板`)
  126. }else{
  127. Toast(`第${index}集是加密内容`)
  128. }
  129. }else{
  130. Toast('获取分集信息失败');
  131. }
  132. }
  133. });
  134. }
  135.  
  136. function init(){
  137. GM_addStyle(`
  138. .epList{
  139. background-color:#ffbf00;
  140. border-radius:10px;
  141. padding:15px;
  142. position:fixed;
  143. top:50%;
  144. right:15px;
  145. display:flex;
  146. flex-flow:row wrap;
  147. justify-content: flex-start;
  148. max-width:230px;
  149. max-height: 300px;
  150. overflow-y: auto;
  151. }
  152. .epList::-webkit-scrollbar{
  153. width:4px;
  154. }
  155. .epList::-webkit-scrollbar-thumb {
  156. background-color: #0cb317;
  157. outline: 1px solid slategrey;
  158. }
  159. .epList>a{
  160. display:inline-flex;
  161. align-items:center;
  162. justify-content: center;
  163. min-width:20px;
  164. line-height:20px;
  165. margin:4px;
  166. padding:1px 4px;
  167. color: white;
  168. border-bottom: solid 3px #0cb317;
  169. cursor: pointer;
  170. background-color: #000;
  171. }
  172. .epList>a.premium{
  173. background-color:#a5238c;
  174. }
  175. .epList>a:hover{
  176. color:red;}
  177. .toastify{padding:12px 20px;color:#fff;display:inline-block;box-shadow:0 3px 6px -1px rgba(0,0,0,.12),0 10px 36px -4px rgba(77,96,232,.3);background:-webkit-linear-gradient(315deg,#73a5ff,#5477f5);background:linear-gradient(135deg,#73a5ff,#5477f5);position:fixed;opacity:0;transition:all .4s cubic-bezier(.215,.61,.355,1);border-radius:2px;cursor:pointer;text-decoration:none;max-width:calc(50% - 20px);z-index:2147483647}.toastify.on{opacity:1}.toast-close{opacity:.4;padding:0 5px}.toastify-right{right:15px}.toastify-left{left:15px}.toastify-top{top:-150px}.toastify-bottom{bottom:-150px}.toastify-rounded{border-radius:25px}.toastify-avatar{width:1.5em;height:1.5em;margin:-7px 5px;border-radius:2px}.toastify-center{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content;max-width:-moz-fit-content}@media only screen and (max-width:360px){.toastify-left,.toastify-right{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content}}
  178. `);
  179. }
  180. function Toast(msg,duration){
  181. duration=isNaN(duration)?3000:duration;
  182. if(typeof Toastify!='undefined'){
  183. Toastify({
  184. text: msg,
  185. duration: duration,
  186. close: true,
  187. gravity: "top", // `top` or `bottom`
  188. position: "right", // `left`, `center` or `right`
  189. backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
  190. stopOnFocus: true, // Prevents dismissing of toast on hover
  191. onClick: function(){} // Callback after click
  192. }).showToast();
  193. return;
  194. }
  195. var m = document.createElement('div');
  196. m.innerHTML = msg;
  197. m.style.cssText="max-width:60%;min-width: 150px;padding:0 14px;height: 40px;color: rgb(255, 255, 255);line-height: 40px;text-align: center;border-radius: 4px;position: fixed;top: 5%;left: 50%;transform: translate(-50%, -50%);z-index: 999999;background: rgba(255, 191, 0,.7);font-size: 16px;";
  198. document.body.appendChild(m);
  199. setTimeout(function() {
  200. var d = 0.5;
  201. m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
  202. m.style.opacity = '0';
  203. setTimeout(function() { document.body.removeChild(m) }, d * 1000);
  204. }, duration);
  205. }
  206. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址