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

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