Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.04 KB | None | 0 0
  1. # encoding: utf-8
  2. require 'rubygems'
  3. require 'mechanize'
  4. require 'pathname'
  5.  
  6. $folder = ARGV[0]
  7. $foldercaps = $folder.upcase
  8. if ARGV.length > 1 and not (ARGV[1] == "-F" or ARGV[1] == "-f")
  9. $imdblink = ARGV[1]
  10. else
  11. $imdblink = ""
  12. end
  13. if ARGV.length > 3
  14. print("Too many arguments given. Ignoring them.")
  15. end
  16.  
  17. # Do not use directories with spaces in them.
  18. # Path for all the files
  19. $fpath = "C:/something/" !!!!!!!!!!
  20. # Temporary path
  21. $tpath = $fpath + $folder + "-temp12345/"
  22. # Path where to put torrent files
  23. $torpath = "C:/something/" !!!!!!!!!!
  24. # Path for 7-Zip
  25. $zpath = "C:/something/7z.exe" !!!!!!!!!!
  26. # Path to Mediainfo Command Line version
  27. $mpath = "C:/something/Mediainfo_CLI/mediainfo.exe" !!!!!!!!!!
  28. # Tracker url
  29. $trackerurl = ""
  30. # Command line for your torrent creator
  31. $torrentword_general = "py3createtorrent.py -P -f --exclude-pattern \"(\\.jpg|\\.rar|\\.sfv|\\.r..|\\.message)$\" -o " + $torpath + " " + $fpath + $folder + " tc"
  32. $torrentword_encode = "py3createtorrent.py -P -f --exclude-pattern \"(\\.m2ts|\\.jpg|\\.rar|\\.sfv|\\.r..|\\.message)$\" -o " + $torpath + " " + $fpath + $folder + " tc"
  33. # If files might contain rared content
  34. $archives = 1
  35. # 1 if windows, 0 if linux
  36. $os_windows = 1
  37. # 1 if you wish to be warned about possible duplicates
  38. $check_for_duplicates = 1
  39. # 1 if you wish not to upload adult content
  40. $no_adult = 1
  41.  
  42. # Logins
  43. $username = "" !!!!!!!!!!
  44. $password = "" !!!!!!!!!!
  45.  
  46. # FORCE UPLOAD
  47. if ARGV.include?("-f") or ARGV.include?("-F")
  48. $no_adult = 0
  49. $check_for_duplicates = 0
  50. end
  51.  
  52.  
  53. # Banned groups
  54. $banlist = []
  55. $banlist.push("aXXo", "DEViSE", "FLAWL3SS", "FZHD", "KingBen", "KLAXXON")
  56. $banlist.push("LTRG", "NhaNc3", "PRODJi", "SANTi", "VAMPS", "WHiiZz")
  57.  
  58. # Scenelist
  59. $scenelist = []
  60. $scenelist.push("7SinS","8BaLLRiPS")
  61. $scenelist.push("AN0NYM0US","ALLiANCE","AEN","aBD","AMIABLE","AiRLiNE","aAF","ARC","AFO","AEROHOLiCS")
  62. $scenelist.push("ARTHOUSE")
  63. $scenelist.push("BAND1D0S","BRMP","BiQ","BOV")
  64. $scenelist.push("COCAIN","CQF","CiNEFiLE","CMBHD","CoWRY","Counterfeit","CROKY")
  65. $scenelist.push("D3Si","DAA","DoNE","DEiMOS","DeBTXViD","DEMENTED","DEFiNiTE")
  66. $scenelist.push("EXVID","EwDp","ESPiSE","EXViDiNT","ERODELUXE","ETM","EPiSODE")
  67. $scenelist.push("FiCO","FLAiR","FUTIL","FAiLED","FRAGMENT")
  68. $scenelist.push("GECKOS","GERUDO","GALT","GxP","GeT")
  69. $scenelist.push("HD4U","HAGGiS","HLS","hV")
  70. $scenelist.push("iNFAMOUS","INSECTS","iGNiTiON","iNVANDRAREN","iND","IGUANA","IcHoR","iTCH","IMDBFIXTERMINATOR")
  71. $scenelist.push("iNVENTiONAL","ilLG","iNjECTiON","iMSORNY")
  72. $scenelist.push("Japhson","JETSET")
  73. $scenelist.push("KAFFEREP","KaKa","KiNOBOX","KYR")
  74. $scenelist.push("Ltu","LiViDiTY","Larceny","LCHD","LOUNG3D","LAP","LACHUH")
  75. $scenelist.push("MELiTE","MORTAL","MULTiPLY","MCHD","MOOVEE","MOMENTUM","MAGiCBOX")
  76. $scenelist.push("NERD","NODLABS","NOSCREENS","NeDiVx","NORDiCHD","NoSence","NnD","nDn","N0L")
  77. $scenelist.push("Ouzo","OSiTV")
  78. $scenelist.push("PARADiSE","PFa","PSYCHD","PURE","PFa","PHOBOS","PROD","PPi","ProPL")
  79. $scenelist.push("QCF","QoM")
  80. $scenelist.push("ROVERS","RUSTED","RedBlade","ROUGH","RedBlade","REACTOR","RiTALiX","RAWNiTRO")
  81. $scenelist.push("SPRiNTER","SML","SKA","SMAHD","SCREAM","SMOKEY","SPARKS","SCARED","SViNTO","SKiTFiSKE")
  82. $scenelist.push("Taurine","TASTE","TASTETV","TUSAHD","TRexHD","Trojan","TWiST","TARGET","TXF","TED")
  83. $scenelist.push("TWiZTED")
  84. $scenelist.push("ULSHD","UNVEiL","USi")
  85. $scenelist.push("VERYMUCH","VETO","VeDeTT","VoMiT","VhV")
  86. $scenelist.push("XSTREEM")
  87. $scenelist.push("WHiSKEY","WiDE","WaLMaRT","W4F")
  88.  
  89. $imdb = ""
  90. $container = ""
  91. $extension = ""
  92. $desc = ""
  93. $format = ""
  94. $genre = ""
  95. $image = ""
  96. $mediainfo = ""
  97. $nfo = ""
  98. $nfocaps = ""
  99. $poster = ""
  100. $postername = ""
  101. $quality = ""
  102. $scrtxt = ""
  103. $scrurl = ""
  104. $source = ""
  105. $title = ""
  106. $type = ""
  107. $year = ""
  108.  
  109. $remaster = 0
  110. $remasterinfo = ""
  111. $scene = 0
  112. $sceneinfo = ""
  113.  
  114. $genre_adventure = 0
  115. $genre_animation = 0
  116. $genre_biography = 0
  117. $genre_crime = 0
  118. $genre_family = 0
  119. $genre_fantasy = 0
  120. $genre_filmnoir = 0
  121. $genre_horror = 0
  122. $genre_history = 0
  123. $genre_reality = 0
  124. $genre_music = 0
  125. $genre_mystery = 0
  126. $genre_romance = 0
  127. $genre_scifi = 0
  128. $genre_sport = 0
  129. $genre_thriller = 0
  130. $genre_war = 0
  131. $genre_western = 0
  132.  
  133. def numeric?(object)
  134. true if Float(object) rescue false
  135. end
  136.  
  137. def os_walk(dir)
  138. root = Pathname(dir)
  139. files, dirs = [], []
  140. Pathname(root).find do |path|
  141. unless path == root
  142. dirs << path if path.directory?
  143. files << path if path.file?
  144. end
  145. end
  146. [root, files, dirs]
  147. end
  148.  
  149. def unrar(files)
  150. for filee in files
  151. if File.extname(filee).to_s == ".r00" or File.extname(filee).to_s == ".7z"
  152. system($zpath + " x \"" + filee.to_s + "\" -y -aos -o" + File.dirname(filee).to_s + " -r-")
  153.  
  154. elsif File.extname(filee).to_s == ".rar" and not (File.basename(filee).to_s.include? ".part" and numeric?(File.basename(filee)[File.basename(filee).length - 5].to_s))
  155. system($zpath + " x \"" + filee.to_s + "\" -y -o" + File.dirname(filee).to_s + " -r-")
  156. else
  157. system($zpath + " x \"" + filee.to_s + "\" -y -aos -o" + File.dirname(filee).to_s + " -r-")
  158.  
  159. end
  160. end
  161. end
  162.  
  163. def create_temp()
  164. if not FileTest::directory?($tpath)
  165. Dir::mkdir($tpath)
  166. else
  167. abort("Temporary folder already exists.")
  168. end
  169. print("Temporary directory created.")
  170. print("\n")
  171. end
  172.  
  173. def quit(message)
  174. print("\n")
  175. FileUtils.rm_rf($tpath)
  176. print("Temporary folder deleted." + "\n")
  177. print("Some info:\n")
  178. print("imdb: " + $imdblink + "\n")
  179. if $nfo == ""
  180. print("nfo empty." + "\n")
  181. end
  182. if $mediainfo == ""
  183. print("mediainfo empty." + "\n")
  184. end
  185. print("source: " + $source + "\n")
  186. print("quality: " + $quality + "\n")
  187. print("format: " + $format + "\n")
  188. print("container: " + $container + "\n")
  189. print("year: " + $year + "\n")
  190. print("title: " + $title + "\n")
  191. print("desc: " + $desc + "\n")
  192. print("genre: " + $genre + "\n")
  193. print("type: " + $type + "\n")
  194. print("scrtxt: " + $scrtxt + "\n")
  195. print("imdb: " + $imdb + "\n")
  196. abort(message)
  197. end
  198.  
  199. def check_scene()
  200. # Scene folders do not have spaces, they have dots and at least 1 -
  201. if (not $folder.include?(" ")) and $folder.count(".") > 1 and $folder.include?("-")
  202. b = Mechanize.new { |agent|
  203. agent.user_agent_alias = 'Mac Safari'
  204. }
  205. b.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  206. # Get scene information from predb.me
  207. begin
  208. b.get('http://predb.me/?search=' + $folder) do |page|
  209. page.encoding = "utf-8"
  210. if not page.body.include?("<h3>Error!</h3></div><div class=\"block-text\">Nothing found...")
  211. $scene = 1
  212. print("predb.me says: it's a scene release.\n")
  213. end
  214. end
  215. # If predb.me doesn't work, use the list
  216. rescue
  217. print("Could not use predb, using old system instead.\n")
  218. for i in $scenelist
  219. if $folder.end_with? i
  220. $scene = 1
  221. print("List says: it's a scene release.\n")
  222. end
  223. end
  224. end
  225.  
  226. # Get scene information from srrDB.com
  227. begin
  228. b.get('http://www.srrdb.com/release/details/' + $folder) do |page|
  229. page.encoding = "utf-8"
  230. if not page.body.include?("<h4>404 - Not found</h4>")
  231. $scene = 1
  232. print("srrDB says: it's a scene release.\n")
  233. end
  234. end
  235. # If srrDB.com doesn't work, use the list
  236. rescue
  237. print("Could not use predb, using old system instead.\n")
  238. for i in $scenelist
  239. if $folder.end_with? i
  240. $scene = 1
  241. print("List says: it's a scene release.\n")
  242. end
  243. end
  244. end
  245. end
  246.  
  247. # Special scene info
  248. if $scene == 1
  249. if $foldercaps.include? ".PROPER."
  250. $sceneinfo = "Proper"
  251. end
  252. if $foldercaps.include? ".RERIP."
  253. $sceneinfo = "Rerip"
  254. end
  255. if $foldercaps.include? ".REPACK."
  256. $sceneinfo = "Repack"
  257. end
  258. if $foldercaps.include? ".REAL.PROPER."
  259. $sceneinfo = "Real Proper"
  260. end
  261. end
  262.  
  263. print("Scene info retrieved.\n")
  264. end
  265.  
  266. def check_special_edition()
  267. if $foldercaps.include? ".UNRATED."
  268. $remaster = 1
  269. $remasterinfo = "Unrated"
  270. end
  271. if $foldercaps.include? ".DC."
  272. $remaster = 1
  273. $remasterinfo = "Director's Cut"
  274. end
  275. if $foldercaps.include? ".EXTENDED."
  276. $remaster = 1
  277. $remasterinfo = "Extended Edition"
  278. end
  279. if $foldercaps.include? ".SE."
  280. $remaster = 1
  281. $remasterinfo = "Special Edition"
  282. end
  283. if $foldercaps.include? ".CE."
  284. $remaster = 1
  285. $remasterinfo = "Collector's Edition"
  286. end
  287. if $foldercaps.include? ".RECUT."
  288. $remaster = 1
  289. $remasterinfo = "Recut"
  290. end
  291. if $foldercaps.include? ".RECUT."
  292. $remaster = 1
  293. $remasterinfo = "Recut"
  294. end
  295. if $foldercaps.include? ".WS."
  296. $remaster = 1
  297. $remasterinfo = "Widescreen"
  298. end
  299. if $foldercaps.include? ".REMASTERED."
  300. $remaster = 1
  301. $remasterinfo = "Remastered"
  302. end
  303. if $remaster == 1
  304. print("Special edition: " + $remasterinfo + "\n")
  305. end
  306. end
  307.  
  308. def check_subtitles()
  309. root, files, dirs = os_walk($fpath + $folder)
  310. subcount = 0
  311. idxcount = 0
  312. for filee in files
  313. if File.extname(filee).to_s.upcase == ".SUB"
  314. subcount = subcount + 1
  315. end
  316. if File.extname(filee).to_s.upcase == ".IDX"
  317. idxcount = idxcount + 1
  318. end
  319. end
  320. if idxcount > 0 and not subcount == idxcount
  321. quit("The number of subtitle idx files does not equal the number of sub files.")
  322. end
  323. end
  324.  
  325. def get_poster()
  326. begin
  327. if not $poster == ""
  328. # Get the imdb poster
  329. a = Mechanize.new { |agent|
  330. agent.user_agent_alias = 'Mac Safari'
  331. }
  332. a.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  333. a.get($poster) do |page|
  334. page.encoding = "utf-8"
  335. if page.body.include? "<link rel=\"image_src\" href=\""
  336. list = page.body.split("<link rel=\"image_src\" href=\"")
  337. list = list[1].split(".jpg")
  338. else
  339. list = page.body.split("<link rel='image_src' href=\"")
  340. list = list[1].split(".jpg")
  341. end
  342.  
  343. $poster = list[0] + ".jpg"
  344.  
  345. list = $poster.split("/")
  346. $postername = list[list.length - 1]
  347. a.pluggable_parser.default = Mechanize::Download
  348. a.get($poster).save($tpath + $postername)
  349. print("Poster dl'd from IMDB.")
  350. print("\n")
  351. end
  352.  
  353. print("Poster retrieved.")
  354. print("\n")
  355.  
  356.  
  357. if not try_to_up_to_freeimghosting()
  358. if not try_to_up_to_fotoshack()
  359. print("Poster too large. Searching tmdb to get smaller.")
  360. print("\n")
  361. get_poster_tmdb()
  362. print("Poster uploaded from tmdb.")
  363. print("\n")
  364. end
  365. end
  366.  
  367. else
  368. get_poster_tmdb()
  369. print("Poster uploaded from tmdb.")
  370. print("\n")
  371. return true
  372. end
  373.  
  374. rescue
  375. $poster = ""
  376. end
  377. end
  378.  
  379. def get_poster_tmdb()
  380. link = ""
  381. name = ""
  382. b = Mechanize.new { |agent|
  383. agent.user_agent_alias = 'Mac Safari'
  384. }
  385. b.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  386. b.get('http://www.themoviedb.org/search?query=tt' + $imdb) do |page|
  387. page.encoding = "utf-8"
  388. list = page.body.split("search_results movie\">")
  389. if list.length > 1
  390. list = list[1]
  391. list = list.split("<div class=\"info\">")
  392. list = list[1]
  393. list = list.split("<h3><a href=\"")
  394. list = list[1]
  395. list = list.split("\" title=\"")
  396. link = list[0]
  397. end
  398. end
  399.  
  400. b.get('http://www.themoviedb.org/' + link + "/posters") do |page|
  401. page.encoding = "utf-8"
  402. list = page.body.split("<img id=\"upload_poster\"")
  403. list = list[1]
  404. list = list.split("src=\"")
  405. list = list[1]
  406. list = list.split(".jpg")
  407. list = list[0]
  408. name = link.split("/")
  409. link = list + ".jpg"
  410. b.pluggable_parser.default = Mechanize::Download
  411. $postername = name[name.length - 1]
  412. b.get(link).save($tpath + $postername)
  413. end
  414. # Try different hosts for the poster
  415. if not try_to_up_to_freeimghosting()
  416. try_to_up_to_fotoshack()
  417. end
  418.  
  419. end
  420.  
  421. def get_nfo()
  422. root, files, dirs = os_walk($fpath + $folder)
  423. if $imdblink == ""
  424. begin
  425. $nfo = ""
  426. for filee in files
  427. word = ""
  428. # Search all .nfo and .txt files but choose the first imdb link found.
  429. if (File.extname(filee).to_s.upcase == ".NFO" or File.extname(filee).to_s.upcase == ".TXT") and $nfo == ""
  430. $nfo = $nfo + "[spoiler=NFO][size=2][pre]"
  431. File.open(filee,"r:cp850:utf-8") do |f1|
  432. while line = f1.gets
  433. word = word + line
  434. end
  435. end
  436.  
  437. $nfo = $nfo + word + "[/pre][/size][/spoiler]"
  438. list = [""]
  439. if word.include? "imdb.com/title/tt"
  440. list = word.split("imdb.com/title/tt")
  441. elsif word.include? "imdb.com/Title?"
  442. list = word.split("imdb.com/Title?")
  443. elsif word.include? "imdb.com/Plot?"
  444. list = word.split("imdb.com/Plot?")
  445. end
  446. word = list[1]
  447. truth = 1
  448. i = 0
  449. while truth == 1
  450. if numeric?(word[i])
  451. $imdb = $imdb + word[i]
  452. i = i + 1
  453. else
  454. truth = 0
  455. end
  456. end
  457. end
  458. end
  459. rescue
  460. $imdb == ""
  461. quit("No IMDB link or nfo file found.")
  462. end
  463. # Try to deduct the name
  464. if $imdb == ""
  465. name = deduct_name($folder)
  466. $imdb = compare_searches(name)
  467. end
  468. if $imdb == ""
  469. quit("No IMDB link or nfo file found.")
  470. end
  471.  
  472. print("Imdb link retrieved.")
  473. print("\n")
  474. else
  475. list = $imdblink.split("imdb.com/title/tt")
  476. list = list[1].split("/")
  477. $imdb = list[0]
  478. end
  479. if ARGV.length >= 2
  480. $nfo = ""
  481. for filee in files
  482. word = ""
  483. if File.extname(filee).to_s == ".nfo"
  484. $nfo = $nfo + "[spoiler=NFO][size=2][pre]"
  485. File.open(filee,"r:cp850:utf-8") do |f1|
  486. while line = f1.gets
  487. word = word + line
  488. end
  489. end
  490. $nfo = $nfo + word + "[/pre][/size][/spoiler]"
  491. end
  492. end
  493.  
  494.  
  495. end
  496. if $nfo == "[spoiler=NFO][size=2][pre][/pre][/size][/spoiler]" or $nfo == "[spoiler=NFO][size=2][pre]"
  497. $nfo = ""
  498. end
  499. $nfocaps = $nfo.upcase
  500. print("NFO file retrieved.")
  501. print("\n")
  502. end
  503.  
  504. def get_source()
  505. if $foldercaps.include? "TV" or $foldercaps.include? "TVRIP" or $foldercaps.include? "PDTV" or $foldercaps.include? "DTHEATER"
  506. $source = "Other"
  507. end
  508. if $foldercaps.include? ".CAM" or $foldercaps.include? " CAM"
  509. $source = "CAM (TS)"
  510. end
  511. if $foldercaps.include? ".R5" or $foldercaps.include? " R5"
  512. $source = "R5"
  513. end
  514. if $foldercaps.include? ".HDTV" or $foldercaps.include? "HDTV"
  515. $source = "HDTV"
  516. end
  517.  
  518. if $foldercaps.include? ".DVD" or $foldercaps.include? " DVD"
  519. $source = "DVD"
  520. end
  521. if $foldercaps.include? ".HDDVD" or $foldercaps.include? ".HD.DVD" or $foldercaps.include? " HDDVD" or $foldercaps.include? " HD.DVD"
  522. $source = "HD-DVD"
  523. end
  524. if $foldercaps.include? ".BDRIP" or $foldercaps.include? " BDRIP"
  525. $source = "Blu-ray"
  526. end
  527. if $foldercaps.include? "SCREENER" or $foldercaps.include? "DVDSCR" or $foldercaps.include? "BDSCR"
  528. $source = "Screener"
  529. end
  530. if $foldercaps.include? ".BLURAY" or $foldercaps.include? "BLURAY"
  531. $source = "Blu-ray"
  532. end
  533. if $foldercaps.include? ".WEBDL" or $foldercaps.include? ".WEB-DL" or $foldercaps.include? ".WEBRIP"
  534. $source = "WEB-DL"
  535. end
  536. if $source == ""
  537. # Very unreliable, but might work sometimes
  538. if $nfocaps.include? "R5"
  539. $source = "R5"
  540. end
  541. if $nfocaps.include? "HDTV"
  542. $source = "HDTV"
  543. end
  544. if $nfocaps.include? "CAM"
  545. $source = "CAM (TS)"
  546. end
  547. if $nfocaps.include? "Screener"
  548. $source = "Screener"
  549. end
  550. if $nfocaps.include? "DVD"
  551. $source = "DVD"
  552. end
  553. if $nfocaps.include? "HDDVD" or $nfocaps.include? "HD-DVD"
  554. $source = "HD-DVD"
  555. end
  556. if $nfocaps.include? "WEB-DL" or $nfocaps.include? "WEBDL"
  557. $source = "WEB-DL"
  558. end
  559. if $nfocaps.include? "BLURAY" or $nfocaps.include? "BLU-RAY"
  560. $source = "Blu-ray"
  561. end
  562.  
  563. end
  564. if $source == ""
  565. $source = "Other"
  566. end
  567. print("Source retrieved: " + $source)
  568. print("\n")
  569.  
  570. end
  571.  
  572. def get_quality()
  573. if $foldercaps.include? ".DVDRIP" or $foldercaps.include? " DVDRIP" or $foldercaps.include? "480p" or $foldercaps.include? ".SD" or $foldercaps.include? " SD"
  574. $quality = "Standard Def"
  575. end
  576. if $foldercaps.include? ".720P" or $foldercaps.include? " 720P"
  577. $quality = "720p"
  578. end
  579. if $foldercaps.include? ".1080P" or $foldercaps.include? " 1080P"
  580. $quality = "1080p"
  581. end
  582. if $foldercaps.include? ".1080I" or $foldercaps.include? " 1080I"
  583. $quality = "1080i"
  584. end
  585. if $quality == ""
  586. $quality = "Standard Def"
  587. end
  588. if $quality == ""
  589. quit("Quality unknown.")
  590. end
  591. print("Quality retrieved.")
  592. print("\n")
  593. end
  594.  
  595. def get_format()
  596. if $foldercaps.include? ".DVDR" or $foldercaps.include? " DVDR" or $container.include? "DVDR"
  597. $format = "DVDR"
  598. end
  599. if $foldercaps.include? ".AVC" or $foldercaps.include? "AVC"
  600. $format = "AVC"
  601. end
  602. if $foldercaps.include? "VC-1"
  603. $format = "VC-1"
  604. end
  605. if $foldercaps.include? "MPEG-2"
  606. $format = "MPEG-2"
  607. end
  608. if $foldercaps.include? "X264"
  609. $format = "x264"
  610. end
  611. if $foldercaps.include? "DIVX"
  612. $format = "DivX"
  613. end
  614. if $foldercaps.include? "XVID"
  615. $format = "XviD"
  616. end
  617. if $foldercaps.include? "H264" or $foldercaps.include? "H.264" or $foldercaps.include? "H 264"
  618. $format = "h.264"
  619. end
  620.  
  621. # Get format from mediainfo
  622. if $mediainfo.include?("Codec ID : V_MPEG4/ISO/AVC")
  623. $format = "h.264"
  624. end
  625. if $mediainfo.include?("Writing library : x264")
  626. $format = "x264"
  627. end
  628. if $mediainfo.include?("Writing library : XviD")
  629. $format = "XviD"
  630. end
  631. if $mediainfo.include?("Writing library : DivX")
  632. $format = "DivX"
  633. end
  634.  
  635. # If not recognised
  636. if $format == ""
  637. quit("Format unknown.")
  638. end
  639. print("Format retrieved: " + $format)
  640. print("\n")
  641. end
  642.  
  643. def get_container(largest_file)
  644. filee = largest_file
  645. if File.extname(filee).to_s.upcase == ".ISO" or File.extname(filee).to_s.upcase == ".VOB"
  646. if $foldercaps.include? "PAL"
  647. $container = "DVDR PAL"
  648. $extension = ".VOB"
  649. else
  650. $container = "DVDR NTSC"
  651. $extension = ".VOB"
  652. end
  653. end
  654. if File.extname(filee).to_s.upcase == ".M2TS"
  655. $container = "Blu-Ray"
  656. $extension = ".M2TS"
  657. end
  658. if File.extname(filee).to_s.upcase == ".EVO"
  659. $container = "HD-DVD"
  660. $extension = ".EVO"
  661. end
  662. if File.extname(filee).to_s.upcase == ".AVI"
  663. $container = "AVI"
  664. $extension = ".AVI"
  665. end
  666. if File.extname(filee).to_s.upcase == ".MKV"
  667. $container = "Matroska"
  668. $extension = ".MKV"
  669. end
  670. if File.extname(filee).to_s.upcase == ".TS"
  671. $container = "TS"
  672. $extension = ".TS"
  673. end
  674. if $container == ""
  675. quit("Container unknown.")
  676. end
  677. print("Container retrieved: " + $container)
  678. print("\n")
  679. end
  680.  
  681. def screenshot_routine(filee)
  682. temp = $mediainfo.split("Display aspect ratio : ")
  683. temp = temp[1]
  684. temp = temp.split("\n")
  685. ratio = temp[0]
  686. temp = ratio.split(":")
  687. multiplier1 = temp[0]
  688. multiplier2 = temp[1]
  689. temp = $mediainfo.split("Width : ")
  690. temp = temp[1]
  691. temp = temp.split(" ")
  692. width = temp[0]
  693. temp = $mediainfo.split("Height : ")
  694. temp = temp[1]
  695. temp = temp.split(" ")
  696. height = temp[0]
  697.  
  698. x_number = multiplier1.to_f * height.to_i
  699. y_number = multiplier2.to_f * height.to_i
  700. x_number = x_number.to_i
  701. y_number = y_number.to_i
  702.  
  703. #must divisible by 2
  704. if not x_number % 2 == 0
  705. x_number = x_number + 1
  706. end
  707.  
  708. if x_number < 1.03 * width.to_i and 0.97 * width.to_i < x_number
  709. x_number = width
  710. end
  711.  
  712. x_number = x_number.to_s
  713. y_number = y_number.to_s
  714.  
  715. screenshotlist = []
  716. screenshotsizelist = []
  717. $scrtxt = "[center][spoiler=Screenshots]\n"
  718. duration = get_duration()
  719. n = 10
  720. for count in 1..n do
  721. time = (count * duration / (n + 1)).floor
  722. #system("ffmpeg -loglevel warning -ss " + time.to_s + " -i \"" + filee.to_s + "\" -vframes 1 -f image2 \"" + $tpath + "screen" + count.to_s + ".png\"")
  723. if $source == "DVD" and $scene == 0
  724. system("ffmpeg -loglevel warning -ss " + time.to_s + " -i \"" + filee.to_s + "\" -vframes 1 -f image2 -s " + x_number + "x" + y_number + " \"" + $tpath + "screen" + count.to_s + ".png\"")
  725. else
  726. system("ffmpeg -loglevel warning -ss " + time.to_s + " -i \"" + filee.to_s + "\" -vframes 1 -f image2 \"" + $tpath + "screen" + count.to_s + ".png\"")
  727.  
  728. end
  729.  
  730. screenshot_path = $tpath + "screen" + count.to_s + ".png"
  731.  
  732. sizee = File.size?(screenshot_path)
  733. screenshotlist.push(screenshot_path)
  734. screenshotsizelist.push(sizee)
  735. end
  736. begin
  737. screenshotsizelist = screenshotsizelist.sort
  738. screenshotsizelist = screenshotsizelist.reverse
  739. limsize = screenshotsizelist[4]
  740.  
  741. for i in screenshotlist
  742. if File.size?(i) >= limsize
  743. begin
  744. bbcode = upload_screenshot_imagebam(i)
  745. rescue
  746. bbcode = ""
  747. end
  748.  
  749. if bbcode == ""
  750. begin
  751. bbcode = upload_screenshot_imagebam(i)
  752. rescue
  753. bbcode = ""
  754. end
  755. end
  756.  
  757. if bbcode == ""
  758. begin
  759. bbcode = try_to_up_screen_to_freeimghosting(screen)
  760. rescue
  761. bbcode = ""
  762. end
  763. end
  764.  
  765. $scrtxt = $scrtxt + bbcode
  766. end
  767. end
  768. rescue
  769. exit("Failed to upload screenshots.\n")
  770. end
  771.  
  772.  
  773.  
  774.  
  775. $scrtxt = $scrtxt + "[/spoiler][/center]\n\n"
  776. end
  777.  
  778. def upload_screenshot(screenshot_path)
  779. a = Mechanize.new { |agent|
  780. agent.user_agent_alias = 'Mac Safari'
  781. }
  782. a.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  783. a.get('http://postimage.org/') do |page|
  784. page.encoding = "utf-8"
  785.  
  786. form = page.forms[1]
  787.  
  788. form['content'] = "no"
  789. form['optsize'] = "Do not resize my image"
  790. form.file_uploads.first.file_name = screenshot_path
  791. begin
  792. page = form.submit
  793. rescue
  794. #quit("Could not upload screenshots. Quitting.\n")
  795. return ""
  796. end
  797.  
  798. # This should work always
  799. list = page.body.split("id=\"code_3\" scrolling=\"no\">")
  800. list = list[1].split("[img")
  801. part1 = list[0]
  802. list = list[1].split("[/url]")
  803. list = list[0].split("http://")
  804. list = list[1].split(".jpg")
  805. part2 = list[0]
  806.  
  807. bbcode = part1 + "[img]http://" + part2 + ".jpg[/img][/url]\n"
  808. print("Screenshot done.")
  809. print("\n")
  810.  
  811. return bbcode
  812.  
  813. end
  814. end
  815.  
  816. def upload_screenshot_imagebam(screenshot_path)
  817. a = Mechanize.new { |agent|
  818. agent.user_agent_alias = 'Mac Safari'
  819. }
  820. a.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  821. a.get('http://www.imagebam.com/basic-upload') do |page|
  822. page.encoding = "utf-8"
  823.  
  824. form = page.forms[0]
  825.  
  826. form['content_type'] = 0 #"FAMILY SAFE content"
  827. form['thumb_size'] = "350" #"350x350 pixel"
  828. form['thumb_aspect_ratio'] = "resize" #"keep aspect ratio"
  829. form['thumb_file_type'] = "jpg" #"JPEG"
  830. form.checkbox_with('gallery_options').uncheck
  831. form.file_uploads.first.file_name = screenshot_path
  832. begin
  833. page = form.submit
  834. rescue
  835. #quit("Could not upload screenshots. Quitting.\n")
  836. return ""
  837. end
  838. # This should work always
  839. list = page.body.split("<b>BB-Code</b><br>")
  840. list = list[1]
  841. list = list.split("</textarea>")
  842. list = list[0]
  843. list = list.split("[URL")
  844. list = list[1]
  845.  
  846. bbcode = "[URL" + list
  847. print("Screenshot done.")
  848. print("\n")
  849. return bbcode
  850.  
  851. end
  852.  
  853. end
  854.  
  855. def get_mediainfo(filee)
  856. system($mpath + " \"" + filee.to_s + "\" > \"" + $tpath + "mediainfo.txt\"")
  857. File.open($tpath + "mediainfo.txt", "r") do |f1|
  858. while line = f1.gets
  859. $mediainfo = $mediainfo + line
  860. end
  861. end
  862. list = $mediainfo.split($fpath)
  863. $mediainfo = list[0] + list[1]
  864. print("Mediainfo retrieved.")
  865. print("\n")
  866. end
  867.  
  868. def check_if_duration_long()
  869. list = $mediainfo.split("\nDuration")
  870. list = list[1]
  871. list = list.split("mn")
  872. duration = list[0]
  873. if duration.include?("h ")
  874. return true
  875. else
  876. return false
  877. end
  878. end
  879.  
  880. def get_movie_info()
  881. begin
  882. a = Mechanize.new { |agent|
  883. agent.user_agent_alias = 'Mac Safari'
  884. }
  885. a.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  886. a.get('http://www.imdb.com/title/tt' + $imdb + '/') do |page|
  887. page.encoding = "utf-8"
  888.  
  889. if page.body.include? "/genre/Action"
  890. $genre = "action"
  891. $genre_action = 1
  892. $type = "1"
  893. end
  894. if page.body.include? "/genre/Comedy"
  895. $genre = "comedy"
  896. $genre_comedy = 1
  897. $type = "2"
  898. end
  899. if page.body.include? "/genre/Documentary"
  900. $genre = "documentary"
  901. $genre_documentary = 1
  902. $type = "3"
  903. end
  904. if page.body.include? "/genre/Drama"
  905. $genre = "drama"
  906. $genre_drama = 1
  907. $type = "4"
  908. end
  909. if page.body.include? "/genre/Musical"
  910. $genre = "musical"
  911. $genre_musical = 1
  912. $type = "5"
  913. end
  914. if page.body.include? "/genre/Thriller"
  915. $genre = "thriller"
  916. $genre_thriller = 1
  917. $type = "6"
  918. end
  919. if $genre == ""
  920. $genre = "drama"
  921. $type = "4"
  922. end
  923.  
  924. if page.body.include? "/genre/Crime"
  925. $genre_crime = 1
  926. end
  927. if page.body.include? "/genre/Reality"
  928. $genre_reality = 1
  929. end
  930. if page.body.include? "/genre/Animation"
  931. $genre_animation = 1
  932. end
  933. if page.body.include? "/genre/Adventure"
  934. $genre_adventure = 1
  935. end
  936. if page.body.include? "/genre/Biography"
  937. $genre_biography = 1
  938. end
  939. if page.body.include? "/genre/History"
  940. $genre_history = 1
  941. end
  942. if page.body.include? "/genre/Family"
  943. $genre_family = 1
  944. end
  945. if page.body.include? "/genre/Fantasy"
  946. $genre_fantasy = 1
  947. end
  948. if page.body.include? "/genre/Film-Noir"
  949. $genre_filmnoir = 1
  950. end
  951. if page.body.include? "/genre/Horror"
  952. $genre_horror = 1
  953. end
  954. if page.body.include? "/genre/Music"
  955. $genre_music = 1
  956. end
  957. if page.body.include? "/genre/Mystery"
  958. $genre_mystery = 1
  959. end
  960. if page.body.include? "/genre/Romance"
  961. $genre_romance = 1
  962. end
  963. if page.body.include? "/genre/Sci-Fi"
  964. $genre_scifi = 1
  965. end
  966. if page.body.include? "/genre/Sport"
  967. $genre_sport = 1
  968. end
  969. if page.body.include? "/genre/Thriller"
  970. $genre_thriller = 1
  971. end
  972. if page.body.include? "/genre/War"
  973. $genre_war = 1
  974. end
  975. if page.body.include? "/genre/Western"
  976. $genre_western = 1
  977. end
  978.  
  979. if page.body.include? "/genre/Adult" and $no_adult == 1
  980. quit("This is an adult movie.\n")
  981. end
  982.  
  983. print("Genres retrieved.")
  984. print("\n")
  985.  
  986. list = page.body.split("<meta name=\"title\" content=\"")
  987. list = list[1].split(" (")
  988. $title = list[0]
  989. $title = $title.split("\n")[0]
  990.  
  991. list = page.body.split(") - IMDb</title>")
  992. list = list[0].split("(")
  993. $year = list[list.length - 1]
  994. $year = $year.split("\n")[0]
  995. if $year.start_with? "Video "
  996. list = $year.split("Video ")
  997. $year = list[1]
  998. end
  999. if $year.start_with? "TV "
  1000. list = $year.split("TV ")
  1001. $year = list[1]
  1002. end
  1003. if $year.start_with? "Movie "
  1004. list = $year.split("Movie ")
  1005. $year = list[1]
  1006. end
  1007. if $year.start_with? "Short"
  1008. list = $year.split("Short ")
  1009. $year = list[1]
  1010. end
  1011. if $year.start_with? "Episode"
  1012. list = $year.split("Episode ")
  1013. $year = list[1]
  1014. end
  1015. if not numeric? $year
  1016. quit("Year not determined correctly. Got\n" + $year)
  1017. end
  1018.  
  1019. list = page.body.split("<p itemprop=\"description\">")
  1020. if list.length >= 2
  1021. list = list[1].split("<")
  1022. $desc = list[0]
  1023. else
  1024. $desc = "No film description available."
  1025. end
  1026.  
  1027. list = page.body.split("<div class=\"image\">")
  1028. if list.length >= 2
  1029. list = list[1].split("<a href=\"")
  1030. list = list[1].split("?ref")
  1031. $poster = "http://www.imdb.com" + list[0]
  1032. print("Poster found from IMDB.")
  1033. print("\n")
  1034. end
  1035.  
  1036. end
  1037. print("Movie info retrieved.\n")
  1038. print("Title: " + $title)
  1039. print("\n")
  1040. rescue
  1041. quit("Failed to retrieve imdb data.\nCheck imdb link and if the site is up.")
  1042. end
  1043. end
  1044.  
  1045. def ask_for_dupe_confirmation()
  1046. if dupecheck()
  1047. print("This might be a duplicate. See:\n")
  1048. print("https://tehconnection.eu/torrents.php?searchstr=tt" + $imdb + "\n")
  1049. print("Type 1 to continue or 0 to abort.\n")
  1050. continue = STDIN.gets.chomp
  1051. if not continue == "1"
  1052. quit("Aborted because this might be a duplicate.\nSee: https://tehconnection.eu/torrents.php?searchstr=tt" + $imdb)
  1053. end
  1054. end
  1055. end
  1056.  
  1057. def dupecheck()
  1058. $tc.get('https://tehconnection.eu/torrents.php?searchstr=tt' + $imdb) do |page|
  1059. page.encoding = "utf-8"
  1060. list = page.body.split("<div class=\"box torrent_list_box\">")
  1061. list = list[1]
  1062. list = list.split("<tr class=\"group_torrent groupid_")
  1063. for i in list
  1064. if checkconditions(i)
  1065. # If we find a match return true for duplicate.
  1066. print("This might be a duplicate.\n")
  1067. return true
  1068. end
  1069. end
  1070.  
  1071. end
  1072. $tc.get('https://tehconnection.eu/torrents.php?action=search&release_name=' + $folder) do |page|
  1073. if not page.body.include?("{\"status\":\"ok\",\"releases\":[]}") and not $folder.include?(" ")
  1074. print("This might be a duplicate.\n")
  1075. return true
  1076. end
  1077. end
  1078.  
  1079. # This gets executed if no matches were found.
  1080. print("Not a duplicate.\n")
  1081. return false
  1082. end
  1083.  
  1084. def checkconditions(i)
  1085. # If they are all the same
  1086. if i.include?($container) and i.include?($format) and i.include?($quality) and i.include?($source)
  1087. if ($scene == 1 and i.include?("Scene")) or ($scene == 0 and not i.include?("Scene"))
  1088. return true
  1089. end
  1090. end
  1091. # Scene xvid trumps p2p xvid
  1092. if i.include?("XviD") and i.include?("AVI") and i.include?("Scene")
  1093. if $format == "XviD" and $container == "AVI" and $scene == 0
  1094. return true
  1095. end
  1096. end
  1097.  
  1098. # Bluray trumps DVD as source
  1099. if i.include?($container) and i.include?($format) and i.include?($quality)
  1100. if ($scene == 1 and i.include?("Scene")) or ($scene == 0 and not i.include?("Scene"))
  1101. if $source == "WEB-DL" and (i.include?("DVD") or i.include?("Blu-ray") or i.include?("HD-DVD"))
  1102. return true
  1103. end
  1104. if $source == "DVD" and (i.include?("Blu-ray") or i.include?("HD-DVD"))
  1105. return true
  1106. end
  1107. if $source == "HD-DVD" and i.include?("Blu-ray")
  1108. return true
  1109. end
  1110. end
  1111. end
  1112.  
  1113. return false
  1114. end
  1115.  
  1116. def doupload()
  1117. #$tc.get('https://tehconnection.eu/login.php') do |page|
  1118. #page.encoding = "utf-8"
  1119. #form = page.forms.first
  1120. #form['username'] = $username
  1121. #form['password'] = $password
  1122. #page = form.submit
  1123.  
  1124. #end
  1125. $tc.get('https://tehconnection.eu/upload.php') do |page|
  1126. page.encoding = "utf-8"
  1127. form = page.forms[page.forms.length - 1]
  1128.  
  1129. # torrent file
  1130. form.file_uploads.first.file_name = $torpath + $folder + ".torrent"
  1131.  
  1132. # genre
  1133. # max 3 little genres
  1134. i = 0
  1135. if $genre == "action"
  1136. form.checkbox_with('genre_132951').check
  1137. form['type'] = 0
  1138. i = i + 1
  1139.  
  1140. end
  1141. if $genre == "comedy"
  1142. form.checkbox_with('genre_122494').check
  1143. form['type'] = 1
  1144. i = i + 1
  1145. end
  1146. if $genre == "documentary"
  1147. form.checkbox_with('genre_132953').check
  1148. form['type'] = 2
  1149. i = i + 1
  1150. end
  1151. if $genre == "drama"
  1152. form.checkbox_with('genre_132952').check
  1153. form['type'] = 3
  1154. i = i + 1
  1155. end
  1156. if $genre == "musical"
  1157. form.checkbox_with('genre_122483').check
  1158. form['type'] = 4
  1159. i = i + 1
  1160. end
  1161. if $genre == "thriller"
  1162. form.checkbox_with('genre_132955').check
  1163. form['type'] = 5
  1164. i = i + 1
  1165. end
  1166. if $genre_adventure == 1 and i < 3
  1167. form.checkbox_with('genre_122473').check
  1168. i = i + 1
  1169. end
  1170. if $genre_animation == 1 and i < 3
  1171. form.checkbox_with('genre_122474').check
  1172. i = i + 1
  1173. end
  1174. if $genre_biography == 1 and i < 3
  1175. form.checkbox_with('genre_122475').check
  1176. i = i + 1
  1177. end
  1178. if $genre_crime == 1 and i < 3
  1179. form.checkbox_with('genre_122476').check
  1180. i = i + 1
  1181. end
  1182. if $genre_family == 1 and i < 3
  1183. form.checkbox_with('genre_122477').check
  1184. i = i + 1
  1185. end
  1186. if $genre_fantasy == 1 and i < 3
  1187. form.checkbox_with('genre_122478').check
  1188. i = i + 1
  1189. end
  1190. if $genre_filmnoir == 1 and i < 3
  1191. form.checkbox_with('genre_122479').check
  1192. i = i + 1
  1193. end
  1194. if $genre_history == 1 and i < 3
  1195. form.checkbox_with('genre_122480').check
  1196. i = i + 1
  1197. end
  1198. if $genre_horror == 1 and i < 3
  1199. form.checkbox_with('genre_122481').check
  1200. i = i + 1
  1201. end
  1202. if $genre_music == 1 and i < 3
  1203. form.checkbox_with('genre_132956').check
  1204. i = i + 1
  1205. end
  1206. if $genre_mystery == 1 and i < 3
  1207. form.checkbox_with('genre_122483').check
  1208. i = i + 1
  1209. end
  1210. if $genre_romance == 1 and i < 3
  1211. form.checkbox_with('genre_122485').check
  1212. i = i + 1
  1213. end
  1214. if $genre_scifi == 1 and i < 3
  1215. form.checkbox_with('genre_122486').check
  1216. i = i + 1
  1217. end
  1218. if $genre_sport == 1 and i < 3
  1219. form.checkbox_with('genre_122488').check
  1220. i = i + 1
  1221. end
  1222. if $genre_war == 1 and i < 3
  1223. form.checkbox_with('genre_122489').check
  1224. i = i + 1
  1225. end
  1226. if $genre_western == 1 and i < 3
  1227. form.checkbox_with('genre_122490').check
  1228. i = i + 1
  1229. end
  1230.  
  1231. form['imdb_number'] = $imdb
  1232. form['image'] = $image
  1233. $title = $title.force_encoding('UTF-8')
  1234. form['title'] = $title
  1235. form['year'] = $year
  1236. form['format'] = $format
  1237. form['container'] = $container
  1238. form['bitrate'] = $quality
  1239. form['media'] = $source
  1240. $desc = $desc.force_encoding('UTF-8')
  1241. form['album_desc'] = $desc
  1242. form['mediainfo'] = $mediainfo
  1243. $nfo = $nfo.force_encoding('UTF-8')
  1244. form['release_desc'] = $scrtxt + $nfo
  1245. if $scene == 1
  1246. form.checkbox_with('scene').check
  1247. form['scenetitle'] = $sceneinfo
  1248. end
  1249. if $remaster == 1
  1250. form.checkbox_with('remaster').check
  1251. form['remaster_year'] = $year
  1252. form['remaster_title'] = $remasterinfo
  1253. end
  1254. form['release_name'] = $folder
  1255.  
  1256. begin
  1257. page = form.submit
  1258. rescue
  1259. #File.open($fpath + "errorpagefile4554343.html", 'w') {|f| f.write(page.body) }
  1260. quit("Could not finish uploading. Something went wrong.\n")
  1261. #See the error page file at " + $fpath + "errorpagefile4554343.html.")
  1262. return false
  1263. end
  1264.  
  1265. end
  1266. print("Torrent uploaded.")
  1267. print("\n")
  1268. end
  1269.  
  1270. def createtorrent()
  1271. # Exclude some special files
  1272. if $format == "DivX" or $format == "XviD" or $format == "x264" or $format == "h.264"
  1273. system($torrentword_encode)
  1274. # Usual files excluded
  1275. else
  1276. system($torrentword_general)
  1277. end
  1278. print("Torrent created.")
  1279. print("\n")
  1280. end
  1281.  
  1282. def opentorrent()
  1283. if $os_windows == 1
  1284. system("start \"\" \"" + $torpath + $folder + ".torrent\"")
  1285. else
  1286. system("xdg-open \"\" \"" + $torpath + $folder + ".torrent\"")
  1287. end
  1288. end
  1289.  
  1290. def find_largest_file(files)
  1291. largest_size = 0
  1292. largest_file = ""
  1293. for filee in files
  1294. if File.size?(filee) > largest_size
  1295. largest_size = File.size?(filee)
  1296. largest_file = filee
  1297. end
  1298. end
  1299. print("Found the largest file.")
  1300. print("\n")
  1301. return largest_file
  1302. end
  1303.  
  1304. def retrieve_imdb_update()
  1305. begin
  1306. $tc.get('https://tehconnection.eu/imdb.php?id=' + $imdb)
  1307. print("IMDB update done.")
  1308. print("\n")
  1309. rescue
  1310. quit("IMDB update failed. I blame hwkns.\n")
  1311. end
  1312. end
  1313.  
  1314. def login_to_tc()
  1315. begin
  1316. $tc = Mechanize.new { |agent|
  1317. agent.user_agent_alias = 'Mac Safari'
  1318. }
  1319. $tc.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  1320. $tc.get('https://tehconnection.eu/login.php') do |page|
  1321. page.encoding = "utf-8"
  1322. form = page.forms.first
  1323. form['username'] = $username
  1324. form['password'] = $password
  1325. page = form.submit
  1326.  
  1327. end
  1328. rescue
  1329. quit("Login failed. I blame hwkns.\n")
  1330. end
  1331. end
  1332.  
  1333. def get_duration()
  1334. hours = 0
  1335. minutes = 0
  1336. seconds = 0
  1337. list = $mediainfo.split("Duration : ")
  1338. list = list[1]
  1339. list = list.split("\n")
  1340. list = list[0]
  1341. if list.include? "h"
  1342. hourlist = list.split("h")
  1343. hours = hourlist[0].to_i
  1344. list = list.split("h")
  1345. if list.length > 1
  1346. list = list[1]
  1347. else
  1348. list = [""]
  1349. end
  1350.  
  1351. end
  1352. if list.include? "mn"
  1353. minutelist = list.split("mn")
  1354. minutes = minutelist[0].to_i
  1355. list = list.split("mn")
  1356. if list.length > 1
  1357. list = list[1]
  1358. else
  1359. list = [""]
  1360. end
  1361. end
  1362. if list.include? "s"
  1363. secondslist = list.split("s")
  1364. seconds = secondslist[0].to_i
  1365. end
  1366.  
  1367. seconds = 60 * 60 * hours + 60 * minutes + seconds
  1368. print("Duration: " + seconds.to_s + " seconds.\n")
  1369. return seconds
  1370. end
  1371.  
  1372. def check_ban_list
  1373. for i in $banlist
  1374. if $folder.end_with?(i)
  1375. quit(i + " is a banned group. Check your upload.\n")
  1376. end
  1377. end
  1378. print("Not in banned groups list.\n")
  1379. end
  1380.  
  1381. def deduct_name(foldername)
  1382. striplist = ["DVDRIP","BDRIP","BLURAY","HDTV","TVRIP","480P","576P","1080I","STV","LIMITED","NTSC","PAL","SUBBED","DUBBED","TELESYNC","CAM","FESTIVAL","COMPLETE"]
  1383. striplist.push($source.upcase,$container.upcase,$extension.upcase,$format.upcase)
  1384. if $scene == 1 and not $sceneinfo == ""
  1385. striplist.push($sceneinfo.upcase)
  1386. end
  1387. if $remaster == 1 and not $remasterinfo == ""
  1388. striplist.push($remasterinfo.upcase)
  1389. end
  1390.  
  1391. name = foldername.upcase
  1392. name = name.gsub(".", " ")
  1393. name = name.gsub("(", " ")
  1394. name = name.gsub("[", " ")
  1395. name = name.gsub(")", " ")
  1396. name = name.gsub("]", " ")
  1397. name = name.gsub("-", " ")
  1398. for i in striplist
  1399. if name.include?(i)
  1400. name = name.split(i)
  1401. name = name[0]
  1402. end
  1403. end
  1404.  
  1405. return name
  1406. end
  1407.  
  1408. def compare_searches(name)
  1409. a = Mechanize.new { |agent|
  1410. agent.user_agent_alias = 'Mac Safari'
  1411. }
  1412. a.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  1413. name = name.rstrip
  1414. searchterm = name.gsub(" ", "+")
  1415. searchterm_tmdb = searchterm
  1416. while numeric?(searchterm_tmdb[searchterm_tmdb.length - 1]) or searchterm_tmdb[searchterm_tmdb.length - 1] == "+"
  1417. searchterm_tmdb = searchterm_tmdb.chop
  1418. searchterm_tmdb = searchterm_tmdb.rstrip
  1419. end
  1420.  
  1421. #IMDB
  1422. imdb_result = ""
  1423. begin
  1424. a.get('http://www.imdb.com/find?q=' + searchterm) do |page|
  1425. list = page.body.split("<h3 class=\"findSectionHeader\"><a name=\"tt\"></a>Titles</h3>")
  1426. list = list[1]
  1427. list = list.split("/title/")
  1428. list = list[1]
  1429. list = list.split("/?ref")
  1430. list = list[0]
  1431. imdb_result = list
  1432. end
  1433. print("IMDB says: http://www.imdb.com/title/" + imdb_result + "\n")
  1434. rescue
  1435. imdb_result = ""
  1436. end
  1437.  
  1438. # GOOGLE
  1439. google_result = ""
  1440. begin
  1441. a.get('https://www.google.com/search?q=site:imdb.com+' + searchterm + '&btnI') do |page|
  1442. google_result = page.uri.to_s
  1443. google_result = google_result.split("/title/")
  1444. google_result = google_result[1]
  1445. google_result = google_result.split("/?ref")
  1446. google_result = google_result[0]
  1447. google_result = google_result.split("/")
  1448. google_result = google_result[0]
  1449. end
  1450. print("Google says: http://www.imdb.com/title/" + google_result + "\n")
  1451. rescue
  1452. google_result = ""
  1453. end
  1454.  
  1455.  
  1456. if google_result == imdb_result and not google_result == ""
  1457. tt_result = ""
  1458. begin
  1459. a.get('http://www.themoviedb.org/search?query=' + imdb_result) do |page|
  1460. list = page.body.split("<ul class=\"search_results movie\">")
  1461. list = list[1]
  1462. list = list.split("<a href=\"")
  1463. list = list[1]
  1464. list = list.split("\" title=\"")
  1465. list = list[0]
  1466. tt_result = list
  1467. end
  1468. rescue
  1469. tt_result = ""
  1470. end
  1471.  
  1472. tmdb_result = ""
  1473. begin
  1474. a.get('http://www.themoviedb.org/search?query=' + searchterm_tmdb) do |page|
  1475. list = page.body.split("<ul class=\"search_results movie\">")
  1476. list = list[1]
  1477. list = list.split("<a href=\"")
  1478. list = list[1]
  1479. list = list.split("\" title=\"")
  1480. list = list[0]
  1481. tmdb_result = list
  1482. end
  1483. rescue
  1484. tmdb_result = ""
  1485. end
  1486. print("TMDB says: http://www.imdb.com/title/" + tmdb_result + "\n")
  1487.  
  1488. if tt_result == tmdb_result and not tt_result == ""
  1489. result = imdb_result.delete("tt")
  1490. return result
  1491. else
  1492. return ""
  1493. end
  1494. else
  1495. return ""
  1496. end
  1497. end
  1498.  
  1499. def try_to_up_screen_to_freeimghosting(screen)
  1500. b = Mechanize.new { |agent|
  1501. agent.user_agent_alias = 'Mac Safari'
  1502. }
  1503. b.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  1504.  
  1505. b.get('http://www.freeimagehosting.net/upload.php') do |page|
  1506. page.encoding = "utf-8"
  1507. form = page.forms.first
  1508. form.file_uploads.first.file_name = $tpath + screen
  1509.  
  1510. begin
  1511. page = form.submit
  1512. temp = page.body.split("<input name=\"htmlfull\"")
  1513. temp = temp[1]
  1514. temp = temp.split("&quot; alt=&quot;Free Web Proxy")
  1515. temp = temp[0]
  1516. temp = temp.split("http://www.freeimagehosting.net/newuploads/")
  1517. temp = temp[1]
  1518. temp = "http://www.freeimagehosting.net/newuploads/" + temp
  1519. return "[IMG]" + temp + "[/IMG]"
  1520.  
  1521. rescue
  1522. return ""
  1523. end
  1524. end
  1525. end
  1526. def try_to_up_to_freeimghosting()
  1527. b = Mechanize.new { |agent|
  1528. agent.user_agent_alias = 'Mac Safari'
  1529. }
  1530. b.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  1531.  
  1532. b.get('http://www.freeimagehosting.net/upload.php') do |page|
  1533. page.encoding = "utf-8"
  1534. form = page.forms.first
  1535. form.file_uploads.first.file_name = $tpath + $postername
  1536.  
  1537. begin
  1538. page = form.submit
  1539. temp = page.body.split("<input name=\"htmlfull\"")
  1540. temp = temp[1]
  1541. temp = temp.split("&quot; alt=&quot;Free Web Proxy")
  1542. temp = temp[0]
  1543. temp = temp.split("http://www.freeimagehosting.net/newuploads/")
  1544. temp = temp[1]
  1545. temp = "http://www.freeimagehosting.net/newuploads/" + temp
  1546. $image = temp
  1547. $poster = temp
  1548. print("Poster uploaded to Freeimagehosting.\n")
  1549. return true
  1550.  
  1551. rescue
  1552. $poster = ""
  1553. print("Could not upload poster. Continuing.\n")
  1554. return false
  1555. end
  1556. end
  1557. end
  1558.  
  1559. def try_to_up_to_fotoshack()
  1560. b = Mechanize.new { |agent|
  1561. agent.user_agent_alias = 'Mac Safari'
  1562. }
  1563. b.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  1564. b.get('http://www.fotoshack.us') do |page|
  1565. page.encoding = "utf-8"
  1566. form = page.forms.first
  1567. form.file_uploads.first.file_name = $tpath + $postername
  1568.  
  1569. begin
  1570. page = form.submit
  1571. temp = page.body.split("Direct link to image</td>")
  1572. temp = temp[0]
  1573. temp = temp.split("</a> image to friends</td>")
  1574. temp = temp[1]
  1575. temp = temp.split("value=\"")
  1576. temp = temp[1]
  1577. temp = temp.split("\" size")
  1578. temp = temp[0]
  1579. $image = temp
  1580. $poster = temp
  1581. print("Poster uploaded to Fotoshack.\n")
  1582. return true
  1583. rescue
  1584. $poster = ""
  1585. print("Could not upload poster. Continuing.\n")
  1586. return false
  1587. end
  1588. end
  1589. end
  1590.  
  1591. ### Running starts here.
  1592. if File.file?($fpath + $folder)
  1593. extname = File.extname($fpath + $folder)
  1594. foldername = $folder[0..$folder.length - extname.length - 1]
  1595. print(extname + "\n")
  1596. print(foldername + "\n")
  1597. if not File.directory?($fpath + foldername)
  1598. FileUtils.mkdir($fpath + foldername + "/")
  1599. FileUtils.copy($fpath + $folder,$fpath + foldername + "/" + $folder)
  1600. $folder = foldername
  1601. $foldercaps = $folder.upcase
  1602. else
  1603. quit("To-be-made folder already exists.")
  1604. end
  1605. end
  1606.  
  1607. if not File.directory?($fpath + $folder)
  1608. print($fpath + $folder)
  1609. quit("Given directory does not exist.")
  1610. end
  1611.  
  1612. # Check if banned group
  1613. check_ban_list()
  1614.  
  1615. # Twice to to work with some nested archives.
  1616. # Use trice if paranoid.
  1617. if $archives == 1
  1618. root, files_1, dirs_1 = os_walk($fpath + $folder)
  1619. unrar(files_1)
  1620. root, files_2, dirs_2 = os_walk($fpath + $folder)
  1621.  
  1622. for filee in files_2
  1623. if files_1.count(filee) > 0
  1624. files_2.delete(filee)
  1625. end
  1626. end
  1627. unrar(files_2)
  1628. print("All files extracted.")
  1629. print("\n")
  1630. end
  1631.  
  1632. # Find the main file
  1633. $root, $files, $dirs = os_walk($fpath + $folder)
  1634. largest_file = find_largest_file($files)
  1635.  
  1636. # Create the temp folder.
  1637. create_temp()
  1638.  
  1639. # Login to the site
  1640. login_to_tc()
  1641.  
  1642. # Check that subtitles were extracted correctly.
  1643. check_subtitles()
  1644.  
  1645. # Check if is scene and/or special edition
  1646. check_scene()
  1647. check_special_edition()
  1648.  
  1649. # Get mediainfo
  1650. get_mediainfo(largest_file)
  1651.  
  1652. # Container
  1653. get_container(largest_file)
  1654.  
  1655. # Retrieve source
  1656. get_source()
  1657.  
  1658. # Quality
  1659. get_quality()
  1660.  
  1661. # Format
  1662. get_format()
  1663.  
  1664. # Get IMDB info and nfo contents.
  1665. get_nfo()
  1666.  
  1667. # Make sure user isn't uploading a duplicate.
  1668. if $check_for_duplicates == 1
  1669. ask_for_dupe_confirmation()
  1670. end
  1671.  
  1672. # Get movie info
  1673. get_movie_info()
  1674.  
  1675. # Get poster and upload it
  1676. get_poster()
  1677.  
  1678. # Take screenshots and upload them.
  1679. screenshot_routine(largest_file)
  1680.  
  1681. # Create torrent
  1682. createtorrent()
  1683.  
  1684. # Uploading
  1685. doupload()
  1686.  
  1687. # Tell TC's retard code to fetch rating and peoples info for the film
  1688. retrieve_imdb_update()
  1689.  
  1690. # Open torrent file
  1691. opentorrent()
  1692.  
  1693. # Delete the temporary folder
  1694. FileUtils.rm_rf($tpath)
  1695. print("Temporary folder deleted.")
  1696. print("\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement