upload_btn

辅助脚本支持发布btn

目前为 2021-05-31 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/427286/936243/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(Tech Specs)').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. } catch(err) {alert(err)}
  48. $('#scenename').val(name.replace(/ /g, '.'));
  49. $('#origin').val('P2P');
  50.  
  51. var info = $('#album_desc').val();
  52. if (!info.match(/Season/)) {
  53. info = `[b]Episode Name: {name}[/b]\n[b]Season: {s}[/b]\n[b]Episode: {e}[/b]\n[b]Aired: [b/]\n\n[b]Episode Overview:[/b]`;
  54. if (!tv_series.match(/fail/)) {
  55. info.format({'name': tv_series});
  56. }
  57. try {
  58. info.format({'s': name.match(/S(\d+)/)[1]});
  59. info.format({'e': name.match(/E(\d+)/)[1]});
  60. } catch (err) {}
  61. $('#album_desc').val(info);
  62. }
  63.  
  64. var codec = name.codec_sel();
  65. if (codec == 'H264' || codec == 'X264') {
  66. $('#bitrate').val('H.264');
  67. } else if (codec == 'H265' || codec == 'X265') {
  68. $('#bitrate').val('H.265');
  69. }
  70. var medium = name.medium_sel();
  71. if (medium == 'HDTV') {
  72. $('#media').val('HDTV');
  73. } else if (medium == 'WEB-DL') {
  74. $('#media').val('WEB-DL');
  75. }
  76. var standard = name.standard_sel();
  77. if (standard == '720p') {
  78. $('#resolution').val('720p');
  79. } else if (standard == '1080p') {
  80. $('#resolution').val('1080p');
  81. } else if (standard == '1080i') {
  82. $('#resolution').val('1080i');
  83. } else if (standard == '4K') {
  84. $('#resolution').val('2160p');
  85. }
  86.  
  87. var mediainfo = $('#release_desc').val();
  88. if (mediainfo.match(/\.mp4/)) {
  89. $('#format').val('MP4');
  90. } else if (mediainfo.match(/\.mkv/)) {
  91. $('#format').val('MKV');
  92. }
  93. $('#international_box').attr('checked', true);
  94. var url = $('#imdbid').val();
  95. if (url.match(/tt\d+/)) {
  96. var imdb_url = 'https://www.imdb.com/title/' + url.match(/tt\d+/)[0];
  97. getDoc(imdb_url, null, function(doc) {
  98. var country = Array.from($('div.txt-block:contains("Country")', doc).find('a')).map(function(e){
  99. return $(e).text();
  100. });
  101. var country_selected = false;
  102. country.map(function(e){
  103. if ($('#country').find(`option:contains(${e.trim()})`).length) {
  104. if (!country_selected){
  105. country_selected = true;
  106. $('#country').find(`option:contains(${e.trim()})`).attr('selected', true);
  107. }
  108. }
  109. });
  110. var language = $('div.txt-block:contains("Language")', doc).find('a').text().trim();
  111. if (language == 'English') {
  112. $('#international_box').attr('checked', false);
  113. }
  114. })
  115.  
  116. }
  117. });
  118. }, 500);
  119.  
  120. $('#album_desc').css({'width': '600px', 'height': '200px'});
  121. $('#release_desc').css({'width': '600px', 'height': '500px'});
  122. } else {
  123. if (raw_info.name.match(/e\d+/i)) {
  124. $('#categories').val('Episode');
  125. } else {
  126. $('#categories').val('Season');
  127. }
  128. $('#scene_yesno').val('Yes');
  129.  
  130. $('#autofill_scene_yes').css({'display': 'block'});
  131. $('#autofill').val(raw_info.name);
  132. }
  133. }