BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

upload.js 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. function DisplayTrans() {
  2. /*
  3. if (['Softsubs','Hardsubs'].indexOf($('select[name="sub"]').raw().value) != -1) {
  4. $('#subber').raw().parentNode.parentNode.style.display = 'table-row'
  5. } else {
  6. $('#subber').raw().parentNode.parentNode.style.display = 'none'
  7. }
  8. */
  9. }
  10. function Categories() {
  11. let def = [
  12. 'javdb', // Accession Number
  13. 'audio', // Version
  14. 'title', // Torrent Title
  15. 'title_rj', // Organism
  16. 'title_jp', // Strain/Variety
  17. 'idols', // Authors(s)
  18. 'studio', // Department/Lab
  19. 'series', // Location
  20. 'year', // Year
  21. 'codec', // License
  22. // Platform changes below
  23. 'resolution', // Assembly Level
  24. // Format changes below
  25. 'archive', // Archive
  26. 'tags', // Tags
  27. 'cover', // Picture
  28. 'mirrors', // Mirrors
  29. 'screenshots', // Publications
  30. 'group_desc', // Torrent Group Description
  31. 'release_desc', // Torrent Description
  32. 'censored', // Aligned/Annotated
  33. 'anon', // Upload Anonymously
  34. ]
  35. let cats = [
  36. { // DNA
  37. 'media': {}, // Platform
  38. 'container': {}, // Format
  39. },
  40. { // RNA
  41. 'media': {}, // Platform
  42. 'container': {}, // Format
  43. },
  44. { // Proteins
  45. 'media': {}, // Platform
  46. 'container_prot': {}, // Format
  47. },
  48. { // Imaging
  49. 'media_manga': {}, // Platform
  50. 'container_games': {}, // Format
  51. },
  52. { // Extras
  53. 'media': {}, // Platform
  54. 'container_extra': {}, // Format
  55. }
  56. ]
  57. let active = {}
  58. for (let field of def) active[field] = {}
  59. let category = 0
  60. if ($('input[name="type"]').raw()) category = $('input[name="type"]').raw().value
  61. if ($('#categories').raw()) category = $('#categories').raw().value
  62. active = Object.assign(active, cats[category])
  63. let hide = el => {
  64. Array.from($(`#${el.id} input, #${el.id} select, #${el.id} textarea`)).forEach(inp => inp.disabled = true)
  65. $(el).ghide()
  66. }
  67. let show = el => {
  68. Array.from($(`#${el.id} input, #${el.id} select, #${el.id} textarea`)).forEach(inp => inp.disabled = false)
  69. $(el).gshow()
  70. }
  71. let trs = $('#dynamic_form tr')
  72. for (let tr of trs) {
  73. let field = tr.id.slice(0, -3)
  74. if (active[field]) {
  75. if (active[field].name) {
  76. tr.children[0].innerHTML = active[field].name
  77. }
  78. let notes = $(`#${tr.id} p.notes`).raw()
  79. if (notes) notes.innerHTML = active[field].notes || ''
  80. show(tr)
  81. } else {
  82. hide(tr)
  83. }
  84. }
  85. }
  86. function Bitrate() {
  87. /*
  88. $('#other_bitrate').raw().value = '';
  89. if ($('#bitrate').raw().options[$('#bitrate').raw().selectedIndex].value == 'Other') {
  90. $('#other_bitrate_span').gshow();
  91. } else {
  92. $('#other_bitrate_span').ghide();
  93. }
  94. */
  95. }
  96. function AltBitrate() {
  97. /*
  98. if ($('#other_bitrate').raw().value >= 320) {
  99. $('#vbr').raw().disabled = true;
  100. $('#vbr').raw().checked = false;
  101. } else {
  102. $('#vbr').raw().disabled = false;
  103. }
  104. */
  105. }
  106. function add_tag() {
  107. if ($('#tags').raw().value == "") {
  108. $('#tags').raw().value = $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
  109. } else if ($('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value == '---') {
  110. } else {
  111. $('#tags').raw().value = $('#tags').raw().value + ', ' + $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
  112. }
  113. }
  114. var LogCount = 1;
  115. function AddLogField() {
  116. if (LogCount >= 200) {
  117. return;
  118. }
  119. var LogField = document.createElement("input");
  120. LogField.type = "file";
  121. LogField.id = "file";
  122. LogField.name = "logfiles[]";
  123. LogField.size = 50;
  124. var x = $('#logfields').raw();
  125. x.appendChild(document.createElement("br"));
  126. x.appendChild(LogField);
  127. LogCount++;
  128. }
  129. function RemoveLogField() {
  130. if (LogCount == 1) {
  131. return;
  132. }
  133. var x = $('#logfields').raw();
  134. for (i = 0; i < 2; i++) {
  135. x.removeChild(x.lastChild);
  136. }
  137. LogCount--;
  138. }
  139. var ExtraLogCount = 1;
  140. function AddExtraLogField(id) {
  141. if (LogCount >= 200) {
  142. return;
  143. }
  144. var LogField = document.createElement("input");
  145. LogField.type = "file";
  146. LogField.id = "file_" + id;
  147. LogField.name = "logfiles_" + id + "[]";
  148. LogField.size = 50;
  149. var x = $('#logfields_' + id).raw();
  150. x.appendChild(document.createElement("br"));
  151. x.appendChild(LogField);
  152. LogCount++;
  153. }
  154. function RemoveLogField() {
  155. if (LogCount == 1) {
  156. return;
  157. }
  158. var x = $('#logfields').raw();
  159. for (i = 0; i < 2; i++) {
  160. x.removeChild(x.lastChild);
  161. }
  162. LogCount--;
  163. }
  164. var FormatCount = 0;
  165. function AddFormat() {
  166. if (FormatCount >= 10) {
  167. return;
  168. }
  169. FormatCount++;
  170. $('#extras').raw().value = FormatCount;
  171. var NewRow = document.createElement("tr");
  172. NewRow.id = "new_torrent_row" + FormatCount;
  173. NewRow.setAttribute("style", "border-top-width: 5px; border-left-width: 5px; border-right-width: 5px;");
  174. var NewCell1 = document.createElement("td");
  175. NewCell1.setAttribute("class", "label");
  176. NewCell1.innerHTML = "Extra Torrent File";
  177. var NewCell2 = document.createElement("td");
  178. var TorrentField = document.createElement("input");
  179. TorrentField.type = "file";
  180. TorrentField.id = "extra_torrent_file" + FormatCount;
  181. TorrentField.name = "extra_torrent_files[]";
  182. TorrentField.size = 50;
  183. NewCell2.appendChild(TorrentField);
  184. NewRow.appendChild(NewCell1);
  185. NewRow.appendChild(NewCell2);
  186. NewRow = document.createElement("tr");
  187. NewRow.id = "new_format_row" + FormatCount;
  188. NewRow.setAttribute("style", "border-left-width: 5px; border-right-width: 5px;");
  189. NewCell1 = document.createElement("td");
  190. NewCell1.setAttribute("class", "label");
  191. NewCell1.innerHTML = "Extra Format / Bitrate";
  192. NewCell2 = document.createElement("td");
  193. tmp = '<select id="releasetype" name="extra_formats[]"><option value="">---</option>';
  194. var formats = ["Saab", "Volvo", "BMW"];
  195. for (var i in formats) {
  196. tmp += '<option value="' + formats[i] + '">' + formats[i] + "</option>\n";
  197. }
  198. tmp += "</select>";
  199. var bitrates = ["1", "2", "3"];
  200. tmp += '<select id="releasetype" name="extra_bitrates[]"><option value="">---</option>';
  201. for (var i in bitrates) {
  202. tmp += '<option value="' + bitrates[i] + '">' + bitrates[i] + "</option>\n";
  203. }
  204. tmp += "</select>";
  205. NewCell2.innerHTML = tmp;
  206. NewRow.appendChild(NewCell1);
  207. NewRow.appendChild(NewCell2);
  208. NewRow = document.createElement("tr");
  209. NewRow.id = "new_description_row" + FormatCount;
  210. NewRow.setAttribute("style", "border-bottom-width: 5px; border-left-width: 5px; border-right-width: 5px;");
  211. NewCell1 = document.createElement("td");
  212. NewCell1.setAttribute("class", "label");
  213. NewCell1.innerHTML = "Extra Release Description";
  214. NewCell2 = document.createElement("td");
  215. NewCell2.innerHTML = '<textarea name="extra_release_desc[]" id="release_desc" cols="60" rows="4"></textarea>';
  216. NewRow.appendChild(NewCell1);
  217. NewRow.appendChild(NewCell2);
  218. }
  219. function RemoveFormat() {
  220. if (FormatCount == 0) {
  221. return;
  222. }
  223. $('#extras').raw().value = FormatCount;
  224. var x = $('#new_torrent_row' + FormatCount).raw();
  225. x.parentNode.removeChild(x);
  226. x = $('#new_format_row' + FormatCount).raw();
  227. x.parentNode.removeChild(x);
  228. x = $('#new_description_row' + FormatCount).raw();
  229. x.parentNode.removeChild(x);
  230. FormatCount--;
  231. }
  232. var ArtistCount = 1;
  233. function AddArtistField() {
  234. window.getSelection().removeAllRanges()
  235. ArtistCount = $('input[name="idols[]"]').length;
  236. if (ArtistCount >= 200) {
  237. return;
  238. }
  239. var ArtistField = document.createElement("input");
  240. ArtistField.type = "text";
  241. ArtistField.id = "idols_" + ArtistCount;
  242. ArtistField.name = "idols[]";
  243. ArtistField.size = 45;
  244. var x = $('#idolfields').raw();
  245. x.appendChild(document.createElement("br"));
  246. x.appendChild(ArtistField);
  247. x.appendChild(document.createTextNode('\n'));
  248. if ($("#idols_0").data("gazelle-autocomplete")) {
  249. $(ArtistField).on('focus', function () {
  250. $(ArtistField).autocomplete({
  251. deferRequestBy: 300,
  252. serviceUrl: ARTIST_AUTOCOMPLETE_URL
  253. });
  254. });
  255. }
  256. ArtistCount++;
  257. }
  258. function RemoveArtistField() {
  259. window.getSelection().removeAllRanges()
  260. ArtistCount = $('input[name="idols[]"]').length;
  261. if (ArtistCount == 1) {
  262. return;
  263. }
  264. var x = $('#idolfields').raw();
  265. for (i = 0; i < 3; i++) {
  266. x.removeChild(x.lastChild);
  267. }
  268. ArtistCount--;
  269. }
  270. function AddScreenshotField() {
  271. var sss = $('[name="screenshots[]"]')
  272. if (sss.length >= 10) return
  273. var ScreenshotField = document.createElement("input");
  274. ScreenshotField.type = "text";
  275. ScreenshotField.id = "ss_" + sss.length;
  276. ScreenshotField.name = "screenshots[]";
  277. ScreenshotField.size = 45;
  278. var a = document.createElement("a")
  279. a.className = "brackets"
  280. a.innerHTML = "−"
  281. a.onclick = function () { RemoveScreenshotField(this) }
  282. var x = $('#screenshots').raw()
  283. var y = document.createElement("div")
  284. y.appendChild(ScreenshotField);
  285. y.appendChild(document.createTextNode('\n'));
  286. y.appendChild(a);
  287. x.appendChild(y);
  288. }
  289. function RemoveScreenshotField(el) {
  290. var sss = $('[name="screenshots[]"]')
  291. el.parentElement.remove()
  292. }
  293. function CheckVA() {
  294. /*
  295. if ($('#artist').raw().value.toLowerCase().trim().match(/^(va|various(\sa|a)rtis(t|ts)|various)$/)) {
  296. $('#vawarning').gshow();
  297. } else {
  298. $('#vawarning').ghide();
  299. }
  300. */
  301. }
  302. function CheckYear() {
  303. /*
  304. var media = $('#media').raw().options[$('#media').raw().selectedIndex].text;
  305. if (media == "---" || media == "Vinyl" || media == "Soundboard" || media == "Cassette") {
  306. media = "old";
  307. }
  308. var year = $('#year').val();
  309. var unknown = $('#unknown').prop('checked');
  310. if (year < 1982 && year != '' && media != "old" && !unknown) {
  311. $('#yearwarning').gshow();
  312. $('#remaster').raw().checked = true;
  313. $('#remaster_true').gshow();
  314. } else if (unknown) {
  315. $('#remaster').raw().checked = true;
  316. $('#yearwarning').ghide();
  317. $('#remaster_true').gshow();
  318. } else {
  319. $('#yearwarning').ghide();
  320. }
  321. */
  322. }
  323. function ToggleUnknown() {
  324. /*
  325. if ($('#unknown').raw().checked) {
  326. $('#remaster_year').raw().value = "";
  327. $('#remaster_title').raw().value = "";
  328. $('#remaster_record_label').raw().value = "";
  329. $('#remaster_catalogue_number').raw().value = "";
  330. if ($('#groupremasters').raw()) {
  331. $('#groupremasters').raw().selectedIndex = 0;
  332. $('#groupremasters').raw().disabled = true;
  333. }
  334. $('#remaster_year').raw().disabled = true;
  335. $('#remaster_title').raw().disabled = true;
  336. $('#remaster_record_label').raw().disabled = true;
  337. $('#remaster_catalogue_number').raw().disabled = true;
  338. } else {
  339. $('#remaster_year').raw().disabled = false;
  340. $('#remaster_title').raw().disabled = false;
  341. $('#remaster_record_label').raw().disabled = false;
  342. $('#remaster_catalogue_number').raw().disabled = false;
  343. if ($('#groupremasters').raw()) {
  344. $('#groupremasters').raw().disabled = false;
  345. }
  346. }
  347. */
  348. }
  349. function AnimeAutofill() {
  350. var map = {
  351. artist: 'idols_0',
  352. title: 'title',
  353. title_rj: 'title_rj',
  354. title_jp: 'title_jp',
  355. year: 'year',
  356. description: 'album_desc'
  357. }
  358. var aid = $('#anidb').raw().value
  359. $.getJSON('/ajax.php?action=autofill&cat=anime&aid=' + aid, function (data) {
  360. if (data.status != "success") return
  361. for (i in data.response) {
  362. if (map[i] && !($('#' + map[i]).raw().value)) {
  363. $('#' + map[i]).raw().value = data.response[i]
  364. }
  365. }
  366. })
  367. }
  368. function JavAutofill() {
  369. var map = {
  370. cn: 'javdb',
  371. idols: 'idols',
  372. title: 'title',
  373. title_jp: 'title_jp',
  374. year: 'year',
  375. studio: 'studio',
  376. image: 'image',
  377. tags: 'tags',
  378. description: 'album_desc'
  379. }
  380. var cn = $('#javdb_tr #catalogue').raw().value.toUpperCase()
  381. $.getJSON('/ajax.php?action=autofill&cat=jav&cn=' + cn, function (data) {
  382. if (data.status != "success") {
  383. $('#catalogue').raw().value = 'Failed'
  384. return
  385. } else {
  386. $('#catalogue').raw().value = data.response.cn
  387. }
  388. for (i in data.response) {
  389. if (Array.isArray(data.response[i])) {
  390. for (j in data.response[i]) {
  391. if (i == 'idols') {
  392. if (!($('#' + map[i] + '_' + j).raw())) {
  393. AddArtistField()
  394. }
  395. $('#' + map[i] + '_' + j).raw().value = data.response[i][j]
  396. }
  397. if (map[i] == 'tags' && !($('#' + map[i]).raw().value)) {
  398. $('#' + map[i]).raw().value = data.response[i].join(', ')
  399. }
  400. }
  401. }
  402. if (map[i] && $('#' + map[i]).raw() && !($('#' + map[i]).raw().value)) {
  403. $('#' + map[i]).raw().value = data.response[i]
  404. }
  405. }
  406. if (data.response.screens.length) {
  407. $('#album_desc').raw().value = ('[spoiler=Automatically located thumbs][img]' + data.response.screens.join('[/img][img]') + '[/img][/spoiler]\n\n') + $('#album_desc').raw().value
  408. }
  409. })
  410. }
  411. function MangaAutofill() {
  412. var map = {
  413. artists: 'idols',
  414. title: 'title',
  415. title_jp: 'title_jp',
  416. year: 'year',
  417. tags: 'tags',
  418. lang: 'lang',
  419. cover: 'image',
  420. circle: 'series',
  421. pages: 'pages',
  422. description: 'release_desc'
  423. }
  424. var nh = $('#ehentai_tr #catalogue').raw().value
  425. $.getJSON('/ajax.php?action=autofill&cat=manga&url=' + nh, function (data) {
  426. if (data.status != "success") {
  427. $('#catalogue').raw().value = 'Failed'
  428. return
  429. }
  430. for (i in data.response) {
  431. if (Array.isArray(data.response[i])) {
  432. for (j in data.response[i]) {
  433. if (i == 'artists') {
  434. if (!($('#' + map[i] + '_' + j).raw())) {
  435. AddArtistField()
  436. }
  437. $('#' + map[i] + '_' + j).raw().value = data.response[i][j]
  438. }
  439. if (map[i] == 'tags' && !($('#' + map[i]).raw().value)) {
  440. $('#' + map[i]).raw().value = data.response[i].join(', ')
  441. }
  442. }
  443. }
  444. if (map[i] && $('#' + map[i]).raw() && (!($('#' + map[i]).raw().value) || $('#' + map[i]).raw().value == '---')) {
  445. $('#' + map[i]).raw().value = data.response[i]
  446. }
  447. }
  448. })
  449. }
  450. function SetResolution() {
  451. if ($('#ressel').raw().value != 'Other') {
  452. $('#resolution').raw().value = $('#ressel').raw().value
  453. $('#resolution').ghide()
  454. } else {
  455. $('#resolution').raw().value = ''
  456. $('#resolution').gshow()
  457. $('#resolution').raw().readOnly = false
  458. }
  459. }
  460. function MediaInfoExtract() {
  461. /*
  462. const mi = $('#mediainfo').raw().value
  463. function getval(mi, key) {
  464. var match = mi.match(new RegExp('^' + key + '\\s*:\\s*(.*)', 'mi'))
  465. return (match && match[1]) ? match[1] : false
  466. }
  467. ['container', 'codec', 'resolution', 'audioformat', 'lang'].forEach((sel) => {
  468. if (sel == 'resolution') {
  469. var width = getval(mi, 'Width')
  470. var height = getval(mi, 'Height')
  471. if (!(width && height)) { return }
  472. width = width.match(/[0-9 ]+/)[0].replace(/ /g, '')
  473. height = height.match(/[0-9 ]+/)[0].replace(/ /g, '')
  474. var ressel = $('[name=ressel]').raw()
  475. if (width == '680' && height == '480') { ressel.value = 'SD' }
  476. else if (height == '480') { ressel.value = '480p' }
  477. else if (height == '720') { ressel.value = '720p' }
  478. else if (height == '1080' && getval(mi, 'Scan type' == 'Interlaced')) { ressel.value = '1080i' }
  479. else if (height == '1080') { ressel.value = '1080p' }
  480. else if (width == '3840') { ressel.value = '4K' }
  481. else {
  482. ressel.value = 'Other'
  483. $('[name=resolution]').raw().value = width + 'x' + height
  484. }
  485. } else if (sel == 'lang') {
  486. var val1 = getval(mi.slice(mi.search(/^Audio$/m)), 'Language')
  487. var val2 = getval(mi.slice(mi.search(/^Audio\nID.*[^1]/m)), 'Language')
  488. var val = (val2 && val2 != val1 && (val1 + val2 == 'EnglishJapanese' || val1 + val2 == 'JapaneseEnglish')) ? 'Dual Language' : val1
  489. if (val) { $('[name=lang]').raw().value = val }
  490. } else if (sel == 'container') {
  491. var containerTable = { 'Matroska': 'MKV', 'MPEG-4': 'MP4', 'AVI': 'AVI', 'OGG': 'OGM', 'Windows Media': 'WMV' }
  492. var cont = getval(mi, 'Format')
  493. if (containerTable[cont]) { $('[name=container]').raw().value = containerTable[cont] }
  494. } else if (sel == 'codec') {
  495. var codecTable = { 'WMV1': 'WMV', 'VC-1': 'WMV', 'HEVC': 'HEVC' }
  496. var codec = getval(mi.slice(mi.search(/^Video$/m)), 'Format')
  497. var formatProfile = getval(mi.slice(mi.search(/^Video$/m)), 'Format profile')
  498. var codecID = getval(mi, 'Codec ID')
  499. var codel = $('[name=codec]').raw()
  500. if (codec == 'AVC') {
  501. codel.value = (formatProfile.includes('High 10')) ? '10-bit h264' : 'h264'
  502. }
  503. else if (codec == 'MPEG-4 Visual') {
  504. codel.value = (codecID == 'XVID') ? 'XVID' : 'DIVX'
  505. }
  506. else if (codecTable[codec]) {
  507. codel.value = codecTable[codec]
  508. }
  509. }
  510. })
  511. */
  512. }
  513. function initAutofill() {
  514. $('[autofill]').each(function (i, el) {
  515. el.addEventListener('click', function (event) {
  516. ({ 'douj': MangaAutofill, 'anime': AnimeAutofill, 'jav': JavAutofill })[el.attributes['autofill'].value]()
  517. })
  518. })
  519. }
  520. $(function () {
  521. Categories();
  522. initAutofill();
  523. $(document).on('click', '.add_artist_button', AddArtistField);
  524. $(document).on('click', '.remove_artist_button', RemoveArtistField);
  525. })