upload_btn

辅助脚本支持发布btn

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

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