From 46ecc8ed04d4752d82d3b5332b276bf4324ce227 Mon Sep 17 00:00:00 2001 From: Chris Punches Date: Mon, 8 Oct 2018 00:26:41 -0400 Subject: [PATCH] fixed blocking subprocess launch to xdg-open for magnet link handling --- .gitignore | 1 + Scallywag | 21 +- .../__pycache__/__init__.cpython-36.pyc | Bin 172 -> 0 bytes .../__pycache__/proxylister.cpython-36.pyc | Bin 1664 -> 0 bytes .../__pycache__/searcher.cpython-36.pyc | Bin 3633 -> 0 bytes rsrc/Scraper/searcher.py | 10 +- rsrc/gui/#winMain.glade# | 211 ------------------ rsrc/gui/proxyselector.glade~ | 80 ------- rsrc/gui/winMain.glade~ | 210 ----------------- 9 files changed, 7 insertions(+), 526 deletions(-) create mode 100644 .gitignore delete mode 100644 rsrc/Scraper/__pycache__/__init__.cpython-36.pyc delete mode 100644 rsrc/Scraper/__pycache__/proxylister.cpython-36.pyc delete mode 100644 rsrc/Scraper/__pycache__/searcher.cpython-36.pyc delete mode 100644 rsrc/gui/#winMain.glade# delete mode 100644 rsrc/gui/proxyselector.glade~ delete mode 100644 rsrc/gui/winMain.glade~ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/Scallywag b/Scallywag index ad8f8a8..40ed384 100755 --- a/Scallywag +++ b/Scallywag @@ -21,14 +21,12 @@ class Config: class Scallywag: def on_btnRefresh_clicked( self, object, data=None ): + # TODO implement refresh self.status("refresh pressed") def on_btnSearch_clicked( self, object, data=None ): self.status("search pressed") - - - # clear the results_store # seeders, leechers, size, name self.results_store.clear() @@ -36,10 +34,6 @@ class Scallywag: for row in self.results_store: self.results_store.remove(row) - # prove to me that the results_store is populated - for row in self.results_store: - print(row[:]) - for column in self.results_tree_view.get_columns(): self.results_tree_view.remove_column(column) @@ -47,7 +41,6 @@ class Scallywag: self.results_tree_view.set_model(self.results_store) # add search result entries to the results store - # TODO add retrieval from search textentry search_field = self.builder.get_object("txtSearch") search_terms = search_field.get_text() @@ -55,10 +48,6 @@ class Scallywag: print( result.__str__() ) self.results_store.append( [ result.seeders, result.leechers, result.size, result.title, result.author, result.url ]) - # prove to me that the results_store is populated - for row in self.results_store: - print(row[:]) - for i, col_title in enumerate( [ "Seeders", "Leechers", "Size", "Title", "Author", "Url" ] ): # renderer creation renderer = Gtk.CellRendererText() @@ -69,8 +58,6 @@ class Scallywag: # add column to tvw self.results_tree_view.append_column(column) - - def get_current_proxy(self): return self.mnuPulldown.get_active_text() @@ -80,9 +67,7 @@ class Scallywag: self.status( str.format( "Changed PirateBay proxy site to {0}", self.config.proxy ) ) - def get_results(self, search_terms): - self.searcher = searcher.Scraper( self.config ) results = self.searcher.get_results( search_terms ) @@ -95,11 +80,10 @@ class Scallywag: selection = self.results_tree_view.get_selection() (tm, ti) = selection.get_selected() url = tm.get_value(ti, 5) - # TODO scrape url for magnet link then pass to xdg-open magnet = self.searcher.get_magnet( url ) - subprocess.call(["xdg-open", magnet]) + subprocess.Popen( "xdg-open {0}".format(magnet), shell=True ) self.status("Opening Magnet with xdg-open...") @@ -149,7 +133,6 @@ class Scallywag: self.window.show_all() - if __name__ == "__main__": main = Scallywag("config.ini") diff --git a/rsrc/Scraper/__pycache__/__init__.cpython-36.pyc b/rsrc/Scraper/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index 08dedf6d3b9eccafbb45935b59498f2b6074b775..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 172 zcmXr!<>mThv?H1U2p)q77+?f49Dul(1xTbY1T$zd`mJOr0tq9CUy=G5`MIh3Nr~y1 zMTz<;sb#4-`31SDc_sRpc_pbud5JkdMm#q0;1ZzXV)w+N#Pn4C;N+sjg481Y`1s7c b%#!$cy@JYH95%W6DWy57b|5Q@ftUdRpO`P1 diff --git a/rsrc/Scraper/__pycache__/proxylister.cpython-36.pyc b/rsrc/Scraper/__pycache__/proxylister.cpython-36.pyc deleted file mode 100644 index 58896eb815dfcfd4e464c0096d53052497f7f80e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1664 zcmZ`(&5qkP5GJV~YaQ=)lWv-Bfwn*p6xE@tLvBGD7$}0=i~`$}(m>#fTw4YuIV2r; z4d>*%Oy8i-!fQ@_g`PS?S z2&zbqZ>DI?az@D;A_5V9A|l+fJP`Dfq|rZMOC~9G;mp>m#IODV{0{F0D3atwT+8QRmsM}yKSzkY06w^q`KBI0R2UD0RVsYb= zqNtk676l$@uuy~z>H2hMe$j826u02P-r({H{|w58%pqj~$SFU zRP!U-FepMWStm1V7v@ElxuK7vz(CT0jsV96Q)zwX?sy+$vDC`NzjJM*cCqorcLS)F zg#x639)M$hd@XG`E3`CAWsQCS|9t5>afH|p0J}icN*dfZm@c7b^pvi@?sL6mQ{s02 zV7g;i<{5~dJ`!k$1lrO(1l^Me^hiXIYP>$_LA%)Zd_k-|U%rJ8L6I?YR#7a|hMbcP z-6Emc#AgCYqK`g7fuW~Cek8c%ix&FtLMvC+MI|@V93-v30_%scy0!)*wtjp!s*A3m zcY1p#I1FvmbreDr5ZJDlY_iU>%b@?Tn1&wkm6BXRYuBJfsueNsXNH9XZ7a@YW=B zH1L1!Fb5MJqX|xio;hCz4|F+PpY=iShQe#D+y9v_LqPFU1%@H`!c?Iy`oPsvrp#Xj zeGV3fl|ru{VHu2u(DnEC9k{>fFsbxou+!h5c!B}}Zh`JA;6}GY{sFA~5ee1bfj&u- zdx4OVzEbY!^{SK$3xm)*+;@cMK28UNrzSLslIY~b|AjcQ@Oh|Kwer;JE{YHDi}2S! OdD->*6;83fU%`JJA#S|@ diff --git a/rsrc/Scraper/__pycache__/searcher.cpython-36.pyc b/rsrc/Scraper/__pycache__/searcher.cpython-36.pyc deleted file mode 100644 index e69a64b54ec1e4009fe27f45beeee48277f3e326..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3633 zcmaJ^&668P6`!6jjXqY{*ba^p5*9;&hlHKPP8C#eh#+58R7yo*swlMO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0(X=d;(n>dkAmx!V$*w6RcfrzW>j?)zU0tzczmC6wD?nP|sqVLM48VpQtf6J5I5)qTX1wV{CFI8mIY=Q~$J`uvv zv_HGZ#X_U*vY+mqpjpfY;WsharcM->K@>*4DC!^E5me8&Nt0h(%!=BGen9F!ByvcE dOty~XFFQ)~u&#K2O%A_ZqQ|fdi`@RL{{rr~BUAtY diff --git a/rsrc/Scraper/searcher.py b/rsrc/Scraper/searcher.py index 8a1b5d3..0deb6a7 100644 --- a/rsrc/Scraper/searcher.py +++ b/rsrc/Scraper/searcher.py @@ -33,13 +33,11 @@ class Scraper: def craft_url(self, protocol, proxy, search_terms): # https://pirate.blue/s/?q=Raising+Arizona&category=0&page=0&orderby=99 f = { 'q': search_terms, 'category': 0, 'page': 0, 'orderby': 99 } - return str.format( "{0}://{1}/s/?{2}", protocol, proxy, urllib.parse.urlencode(f) ) - + url = str.format( "{0}://{1}/s/?{2}", protocol, proxy, urllib.parse.urlencode(f) ) + print(url) + return url def get_results(self, search_terms): - print("Fetching from") - print(self.config.proxy) - url = self.craft_url( "https", self.config.proxy, search_terms ) fetch_results = self.client.get( url ) @@ -76,7 +74,7 @@ class Scraper: title = tr.xpath('td[2]/div[1]/a[1]/text()')[0] seeders = tr.xpath('td[3]/text()')[0] leechers = tr.xpath('td[4]/text()')[0] - author = tr.xpath('td[2]/font/a/text()')[0] + author = tr.xpath('td[2]/font/a/text()') size_unprocessed = tr.xpath('td[2]/font/text()')[0] url = tr.xpath('td/div[@class="detName"]/a[@class="detLink"]/@href')[0] diff --git a/rsrc/gui/#winMain.glade# b/rsrc/gui/#winMain.glade# deleted file mode 100644 index 9dd5ab0..0000000 --- a/rsrc/gui/#winMain.glade# +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - winMain - False - 500 - 600 - - - - boxMain - True - False - vertical - - - True - False - - - False - True - 0 - - - - - True - False - - - mnuPulldown - True - False - 6 - 6 - 6 - - - - True - True - 0 - - - - - gtk-refresh - btnRefresh - True - True - True - 6 - 6 - True - True - - - - False - False - 3 - - - - - False - True - 0 - - - - - stsBar - True - False - 10 - 10 - 10 - 10 - 6 - 6 - True - 2 - - - False - True - end - 0 - - - - - True - False - - - False - True - 6 - 3 - - - - - Open in Client - btnDownload - True - True - True - - - - False - True - end - 4 - - - - - True - True - in - - - True - False - - - tvwResults - True - True - - - - - - - - - - True - True - end - 5 - - - - - boxSearch - True - False - - - txtSearch - True - True - True - True - True - 6 - 6 - True - - - - True - True - 0 - - - - - gtk-find - btnSearch - True - True - True - True - 6 - True - True - - - - False - True - 2 - - - - - False - True - 6 - - - - - - - True - False - - - - diff --git a/rsrc/gui/proxyselector.glade~ b/rsrc/gui/proxyselector.glade~ deleted file mode 100644 index 14fdcd3..0000000 --- a/rsrc/gui/proxyselector.glade~ +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - False - 440 - 250 - - - True - False - vertical - - - True - False - Select a PirateBay Proxy - - - True - False - 0 - - - - - True - False - - - True - False - - - True - True - 0 - - - - - Select - True - True - True - - - False - True - 1 - - - - - Refresh - True - True - True - - - False - True - 3 - - - - - False - True - 1 - - - - - - - - - diff --git a/rsrc/gui/winMain.glade~ b/rsrc/gui/winMain.glade~ deleted file mode 100644 index 5daefcf..0000000 --- a/rsrc/gui/winMain.glade~ +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - winMain - False - 500 - 600 - - - - boxMain - True - False - vertical - - - True - False - - - False - True - 0 - - - - - True - False - - - mnuPulldown - True - False - 6 - 6 - 6 - - - - True - True - 0 - - - - - gtk-refresh - btnRefresh - True - True - True - 6 - 6 - True - True - - - - False - False - 3 - - - - - False - True - 0 - - - - - stsBar - True - False - 10 - 10 - 10 - 10 - 6 - 6 - True - 2 - - - False - True - end - 0 - - - - - True - False - - - False - True - 6 - 3 - - - - - Open in Client - btnDownload - True - True - True - - - - False - True - end - 4 - - - - - True - True - in - - - True - False - - - tvwResults - True - True - - - - - - - - - - True - True - end - 5 - - - - - boxSearch - True - False - - - txtSearch - True - True - True - True - 6 - 6 - True - - - - True - True - 0 - - - - - gtk-find - btnSearch - True - True - True - True - 6 - True - True - - - - False - True - 2 - - - - - False - True - 6 - - - - - - - True - False - - - -