upload_btn

辅助脚本支持发布btn

目前为 2021-06-03 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/427286/937272/upload_btn.js

  1. if (GM_getValue('btn_info') !== undefined) {
  2. raw_info = JSON.parse(GM_getValue('btn_info'));
  3. raw_info = fill_raw_info(raw_info);
  4. if ($('#post').parent().parent().parent().parent().css('display') != 'none') {
  5. $('#content').find('table').first().hide();
  6. $('td.label:contains(Actors)').parent().after($(`<tr><td class="label">IMDB</td>
  7. <td><input type="text" id="imdbid" name="imdbid" size="60" />
  8. <input id="fill" type="button" value="辅助填写">
  9. </td></tr>`));
  10. $('#imdbid').val(raw_info.url);
  11. $('#scenename').val(raw_info.name);
  12. $('#release_desc').val(raw_info.descr.replace(/\[.{3,15}\]/g, '').trim());
  13. setTimeout(function() {
  14. $('#fill').click(function(){
  15. var name = $('#scenename').val().trim();
  16. var title = $('#title').val().trim();
  17. if (title == name.replace(/ /g, '.')) {
  18. if (name.match(/E\d+/i) && !name.match(/S\d+E\d+/i)) {
  19. name = name.replace(/(E\d+)/, 'S01$1');
  20. $('#title').val('S01' + title.match(/E\d+/)[0])
  21. }
  22. }
  23. var tv_series = $('#artist').val();
  24. if (!tv_series.match(/(19|20)\d{2}/) && name.match(/(19|20)\d{2}[^pP]/)) {
  25. name = name.replace(/(19|20)\d{2}/, '').replace(/ +/, ' ');
  26. }
  27. try{
  28. var channels = raw_info.descr.match(/Channel.*?(\d).*?channels/)[1];
  29. var label = null;
  30. var label_str = '';
  31. if (channels == '1') {
  32. label = /1\.0/;
  33. label_str = '1.0';
  34. } else if (channels == '2') {
  35. label = /2\.0/;
  36. label_str = '2.0';
  37. } else if (channels == '6') {
  38. label = /5\.1/;
  39. label_str = '5.1';
  40. } else if (channels == '8') {
  41. label = /7\.1/;
  42. label_str = '7.1';
  43. }
  44. if (!name.match(label)) {
  45. name = name.replace(/(DDPA|AAC|DDP|FLAC|DTS|LPCM|TrueHD)/, `$1${label_str}`);
  46. }
  47.  
  48. if (name.match(/(H.265|H.264).(DDPA|AAC|DDP|FLAC|DTS|LPCM|TrueHD)(2\.0|1\.0|5\.1|7\.1)/)) {
  49. name = name.replace(/(H.265|H.264).(DDPA|AAC|DDP|FLAC|DTS|LPCM|TrueHD)(2\.0|1\.0|5\.1|7\.1)/, '$2 $3 $1')
  50. }
  51.  
  52. } catch(err) {alert(err)}
  53. $('#scenename').val(name.replace(/ /g, '.'));
  54. $('#origin').val('P2P');
  55.  
  56. var info = $('#album_desc').val();
  57. if (!info.match(/Season/)) {
  58. info = `[b]Episode Name: [/b]\n[b]Season: {s} [/b]\n[b]Episode: {e} [/b]\n[b]Aired: [/b]\n\n[b]Episode Overview: [/b]`;
  59. console.log(name)
  60. try {
  61. info = info.format({'s': parseInt(name.match(/S(\d+)/)[1])});
  62. info = info.format({'e': parseInt(name.match(/E(\d+)/)[1])});
  63. $('#album_desc').val(info);
  64. } catch (err) {
  65. console.log(err)
  66. }
  67. }
  68.  
  69. var codec = name.codec_sel();
  70. if (codec == 'H264' || codec == 'X264') {
  71. $('#bitrate').val('H.264');
  72. } else if (codec == 'H265' || codec == 'X265') {
  73. $('#bitrate').val('H.265');
  74. }
  75. var medium = name.medium_sel();
  76. if (medium == 'HDTV') {
  77. $('#media').val('HDTV');
  78. } else if (medium == 'WEB-DL') {
  79. $('#media').val('WEB-DL');
  80. }
  81. var standard = name.standard_sel();
  82. if (standard == '720p') {
  83. $('#resolution').val('720p');
  84. } else if (standard == '1080p') {
  85. $('#resolution').val('1080p');
  86. } else if (standard == '1080i') {
  87. $('#resolution').val('1080i');
  88. } else if (standard == '4K') {
  89. $('#resolution').val('2160p');
  90. }
  91.  
  92. var mediainfo = $('#release_desc').val();
  93. if (mediainfo.match(/\.mp4/)) {
  94. $('#format').val('MP4');
  95. } else if (mediainfo.match(/\.mkv/)) {
  96. $('#format').val('MKV');
  97. }
  98. $('#international_box').attr('checked', true);
  99. var url = $('#imdbid').val();
  100. if (url.match(/tt\d+/)) {
  101. var imdb_url = 'https://www.imdb.com/title/' + url.match(/tt\d+/)[0];
  102. getDoc(imdb_url, null, function(doc) {
  103. var country = Array.from($('div.txt-block:contains("Country")', doc).find('a')).map(function(e){
  104. return $(e).text();
  105. });
  106. var country_selected = false;
  107. country.map(function(e){
  108. if ($('#country').find(`option:contains(${e.trim()})`).length) {
  109. if (!country_selected){
  110. country_selected = true;
  111. $('#country').find(`option:contains(${e.trim()})`).attr('selected', true);
  112. }
  113. }
  114. });
  115. var language = $('div.txt-block:contains("Language")', doc).find('a').text().trim();
  116. if (language == 'English') {
  117. $('#international_box').attr('checked', false);
  118. }
  119. })
  120.  
  121. }
  122. });
  123. }, 500);
  124.  
  125. $('#album_desc').css({'width': '600px', 'height': '200px'});
  126. $('#release_desc').css({'width': '600px', 'height': '500px'});
  127. } else {
  128. if (raw_info.name.match(/e\d+/i)) {
  129. $('#categories').val('Episode');
  130. } else {
  131. $('#categories').val('Season');
  132. }
  133. $('#scene_yesno').val('Yes');
  134.  
  135. $('#autofill_scene_yes').css({'display': 'block'});
  136. $('#autofill').val(raw_info.name);
  137. }
  138. }