From ad61bc74c84869043654a6532e846bd8a9c7bfaa Mon Sep 17 00:00:00 2001 From: Elias Benbourenane Date: Tue, 7 Apr 2020 20:45:05 +0400 Subject: [PATCH] Release v6.5 --- README.md | 11 ++++---- home.py | 63 ++++++++++++++++++++++++++++++++------------- requirements.txt | Bin 698 -> 400 bytes search.py | 65 +++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 108 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index dc746b5..59d4743 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,12 @@ MagnetMagnet is well, a magnet link magnet, it's a scraper that allows you to sc - Choosing the category/subcategory to scrape magnet links from - Exporting magnet links to a .txt file in local directory - Copy specific magnet links to the clipboard on click +- Auto version checker ## To do list: - ~~Add Nyaa support~~ - ~~Add maximum scraping limit~~ -- Add a self updater +- ~~Add a self updater~~ - Make scraping asynchronous # Installation @@ -35,10 +36,10 @@ MagnetMagnet is well, a magnet link magnet, it's a scraper that allows you to sc # Usage: ### Home Screen: -- On launch you get five options of torrent indexers to scrape from: 1377x, KAT, Nyaa, RARBG and TPB, +- On launch you get five options of torrent indexers to scrape from: 1377x, Kick Ass Torrents, Nyaa, RARBG and The Pirate Bay - There is also a sixth tab named 'Search' which allows you to scrape the aforementioned torrent indexers for specific words -![Home Screen](https://user-images.githubusercontent.com/54410649/78558052-fdc52b80-7822-11ea-939f-cd7868a084bd.PNG) +![Home Screen](https://user-images.githubusercontent.com/54410649/78696205-30008700-7910-11ea-8c33-480725e58e36.PNG) ### Search: - In the Search app you have four user editable fields: - **Checkboxes:** you can select/deselect the torrent indexers you would like to search from @@ -46,10 +47,10 @@ MagnetMagnet is well, a magnet link magnet, it's a scraper that allows you to sc - **Table:** the table displays the title names, seeders and leechers for the torrents scraped, here you can copy the magnet link you would like by selecting a row - **Slider** the slider allows you to limit the amount of torrents scraped per torrent indexer -![Search](https://user-images.githubusercontent.com/54410649/78558044-fbfb6800-7822-11ea-9a36-ed6b0eff4a31.PNG) +![Search](https://user-images.githubusercontent.com/54410649/78696214-3131b400-7910-11ea-8306-5be6d2069886.PNG) ### Scrapers: - There are only two user changeable fields in the scraper apps: - **Domain:** the first field is for the domain, here just choose the torrent indexer's domain - **Category:** the second field is for the category which you can choose from the drop down box -![Scrapers](https://user-images.githubusercontent.com/54410649/78558049-fdc52b80-7822-11ea-94e1-4cc48413ef75.PNG) +![Scrapers](https://user-images.githubusercontent.com/54410649/78696217-31ca4a80-7910-11ea-8d2d-4b26cf67a256.PNG) diff --git a/home.py b/home.py index 2312284..608243f 100644 --- a/home.py +++ b/home.py @@ -1,7 +1,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets from search import Ui_searchMainWindow from imagebytes import * -import os, requests, re +import os, requests, re, webbrowser path = '%s\\eliasbenb' % os.environ['APPDATA'] if not os.path.exists(path): @@ -9,29 +9,29 @@ if not os.path.exists(path+r'\images'): os.makedirs(path+r'\images') if not os.path.exists(path+r'\images\github.png'): - with open(path+r'\images\github.png','wb') as w1: - w1.write(github_image_bytes) + with open(path+r'\images\github.png','wb') as w: + w.write(github_image_bytes) if not os.path.exists(path+r'\images\icon.png'): - with open(path+r'\images\icon.png','wb') as w2: - w2.write(icon_image_bytes) + with open(path+r'\images\icon.png','wb') as w: + w.write(icon_image_bytes) if not os.path.exists(path+r'\images\kat.png'): - with open(path+r'\images\kat.png','wb') as w3: - w3.write(kat_image_bytes) + with open(path+r'\images\kat.png','wb') as w: + w.write(kat_image_bytes) if not os.path.exists(path+r'\images\nyaa.png'): - with open(path+r'\images\nyaa.png','wb') as w4: - w4.write(nyaa_image_bytes) + with open(path+r'\images\nyaa.png','wb') as w: + w.write(nyaa_image_bytes) if not os.path.exists(path+r'\images\rarbg.png'): - with open(path+r'\images\rarbg.png','wb') as w5: - w5.write(rarbg_image_bytes) + with open(path+r'\images\rarbg.png','wb') as w: + w.write(rarbg_image_bytes) if not os.path.exists(path+r'\images\tpb.png'): - with open(path+r'\images\tpb.png','wb') as w6: - w6.write(tpb_image_bytes) + with open(path+r'\images\tpb.png','wb') as w: + w.write(tpb_image_bytes) if not os.path.exists(path+r'\images\website.png'): - with open(path+r'\images\website.png','wb') as w7: - w7.write(website_image_bytes) + with open(path+r'\images\website.png','wb') as w: + w.write(website_image_bytes) if not os.path.exists(path+r'\images\x1377.png'): - with open(path+r'\images\x1377.png','wb') as w8: - w8.write(x1377_image_bytes) + with open(path+r'\images\x1377.png','wb') as w: + w.write(x1377_image_bytes) class Ui_homeMainWindow(object): def setupUi(self, homeMainWindow): @@ -119,7 +119,34 @@ def setupUi(self, homeMainWindow): self.retranslateUi(homeMainWindow) QtCore.QMetaObject.connectSlotsByName(homeMainWindow) + def update_message(): + updateMessageBox = QtWidgets.QMessageBox() + updateMessageBox.setIcon(QtWidgets.QMessageBox.Information) + + updateMessageBox.setText("There is a newer version of MagnetMagnet. Would you like to update?") + updateMessageBox.setWindowTitle("Update Available!") + updateMessageBox.setStandardButtons(QtWidgets.QMessageBox.Ok) + updateMessageBox.setStandardButtons(QtWidgets.QMessageBox.Ok) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(path+r"/images/icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + updateMessageBox.setWindowIcon(icon) + + updateMessageBox.buttonClicked.connect(update) + + updateMessageBox.exec_() + + def update(): + webbrowser.open("https://github.com/eliasbenb/MagnetMagnet/releases/latest/") + + __VERSION__ = "6.5" + version_request = requests.get("https://github.com/eliasbenb/MagnetMagnet/releases/latest/") + version_url = version_request.url + version_url = version_url.split("/") + latest_version = version_url[7] + if latest_version != __VERSION__: + update_message() + def retranslateUi(self, homeMainWindow): _translate = QtCore.QCoreApplication.translate homeMainWindow.setWindowTitle(_translate("homeMainWindow", "MagnetMagnet @eliasbenb")) - self.searchPushButton.setText(_translate("homeMainWindow", "Search")) + self.searchPushButton.setText(_translate("homeMainWindow", "Search")) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 81424a074a7fb90172dab1b92daadf7b8033c6ce..62c43d3bec0eb84b23edf62f4d46488520100e41 100644 GIT binary patch delta 29 lcmdnRI)Rz#|G$Y!6DD2}n{2}X4>*>!ccp|Hc;z zVmiE0yC<^Xl-kUd6?IkY@J=}i%ujr0KF#1;nAqKuQM=3j?pXB+XR-xu^O(HIqgWgB zsp@Ro>J2ro%KMf7k(eiT@2uv#6GLqb|J8!G8p-C~rE|Zcq!X#ra$D}ky$a<%RXy|4 zgZ&|kv8Y<7i)aVpzpf4|o5OdI{}Levd@$rf{a(LNJ(zMwK6fZ?O|!Q-K8a}Q-Y=%z JS9SrP@(=W}Vb}lw diff --git a/search.py b/search.py index 01fc537..3915657 100644 --- a/search.py +++ b/search.py @@ -67,6 +67,7 @@ def x1377(): seeder = page_soup.find('span', class_="seeds").text leecher = page_soup.find('span', class_="leeches").text size = page_soup.findAll('span')[15].text + date = page_soup.findAll('span')[19].text magnet = page_soup.find('a', attrs={'href': re.compile("^magnet:?")}).get('href') row_position = self.tableTableWidget.rowCount() @@ -75,7 +76,8 @@ def x1377(): self.tableTableWidget.setItem(row_position, 1, QtWidgets.QTableWidgetItem(seeder)) self.tableTableWidget.setItem(row_position, 2, QtWidgets.QTableWidgetItem(leecher)) self.tableTableWidget.setItem(row_position, 3, QtWidgets.QTableWidgetItem(size)) - self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem("1377x")) + self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem(date)) + self.tableTableWidget.setItem(row_position, 5, QtWidgets.QTableWidgetItem("1377x")) self.magnets.append(magnet) limit_counter = limit_counter + 1 @@ -89,12 +91,14 @@ def kat(): seeders_soup = main_soup.findAll('td', class_="green center") leechers_soup = main_soup.findAll('td', class_="red lasttd center") sizes_soup = main_soup.findAll('td', class_="nobr center") + dates_soup = main_soup.findAll('td', class_="center", title=True) magnets_soup = main_soup.findAll('a', attrs={'href': re.compile("^magnet:?"), 'title': "Torrent magnet link"}) titles = [] seeders = [] leechers = [] sizes = [] + dates = [] limit_counter = 0 for title in titles_soup: if limit_counter < limit: @@ -116,6 +120,11 @@ def kat(): sizes.append(size.text) limit_counter = limit_counter + 1 limit_counter = 0 + for date in dates_soup: + if limit_counter < limit: + dates.append(date.text) + limit_counter = limit_counter + 1 + limit_counter = 0 count1 = 0 for magnet in magnets_soup: if limit_counter < limit: @@ -131,7 +140,8 @@ def kat(): self.tableTableWidget.setItem(row_position, 1, QtWidgets.QTableWidgetItem(seeders[count2])) self.tableTableWidget.setItem(row_position, 2, QtWidgets.QTableWidgetItem(leechers[count2])) self.tableTableWidget.setItem(row_position, 3, QtWidgets.QTableWidgetItem(sizes[count2])) - self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem("KAT")) + self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem(dates[count2])) + self.tableTableWidget.setItem(row_position, 5, QtWidgets.QTableWidgetItem("KAT")) count2 = count2 + 1 def nyaa(): @@ -144,12 +154,14 @@ def nyaa(): seeders_soup = main_soup.findAll('td', class_="text-center") leechers_soup = main_soup.findAll('td', class_="text-center") sizes_soup = main_soup.findAll('td', class_="text-center") + dates_soup = main_soup.findAll('td', class_="text-center") magnets_soup = main_soup.findAll('a', attrs={'href': re.compile("^magnet:?")}) titles = [] seeders = [] leechers = [] sizes = [] + dates = [] limit_counter = 0 for title in titles_soup: if limit_counter < limit: @@ -171,6 +183,11 @@ def nyaa(): sizes.append(size.text) limit_counter = limit_counter + 1 limit_counter = 0 + for date in dates_soup: + if limit_counter < limit*6: + dates.append(date.text) + limit_counter = limit_counter + 1 + limit_counter = 0 count1 = 0 for magnet in magnets_soup: if limit_counter < limit: @@ -201,6 +218,13 @@ def nyaa(): sizes = sizes[6-1::6] sizes.insert(0, size1) + date1 = dates[2] + dates.pop(0) + dates.pop(1) + dates.pop(2) + dates = dates[6-1::6] + dates.insert(0, date1) + count2 = 0 while count2 < count1: row_position = self.tableTableWidget.rowCount() @@ -209,7 +233,8 @@ def nyaa(): self.tableTableWidget.setItem(row_position, 1, QtWidgets.QTableWidgetItem(seeders[count2])) self.tableTableWidget.setItem(row_position, 2, QtWidgets.QTableWidgetItem(leechers[count2])) self.tableTableWidget.setItem(row_position, 3, QtWidgets.QTableWidgetItem(sizes[count2])) - self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem("Nyaa")) + self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem(dates[count2])) + self.tableTableWidget.setItem(row_position, 5, QtWidgets.QTableWidgetItem("Nyaa")) count2 = count2 + 1 def rarbg(): @@ -222,12 +247,14 @@ def rarbg(): seeders_soup = main_soup.split(',"') leechers_soup = main_soup.split(',"') sizes_soup = main_soup.split(',"') + dates_soup = main_soup.split(',"') magnets_soup = main_soup.split('"') titles = [] seeders = [] leechers = [] sizes = [] + dates = [] limit_counter = 0 for title in titles_soup: if limit_counter < limit: @@ -267,7 +294,14 @@ def convert_size(size): size = int(size.replace('size":', '')) convert_size(size) limit_counter = limit_counter + 1 - + limit_counter = 0 + for date in dates_soup: + if limit_counter < limit: + if date.startswith('pubdate":'): + date = date.replace('pubdate":"', '') + date = date.replace('+0000"', '') + dates.append(date) + limit_counter = limit_counter + 1 limit_counter = 0 count1 = 0 for magnet in magnets_soup: @@ -285,7 +319,8 @@ def convert_size(size): self.tableTableWidget.setItem(row_position, 1, QtWidgets.QTableWidgetItem(seeders[count2])) self.tableTableWidget.setItem(row_position, 2, QtWidgets.QTableWidgetItem(leechers[count2])) self.tableTableWidget.setItem(row_position, 3, QtWidgets.QTableWidgetItem(sizes[count2])) - self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem("RARBG")) + self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem(dates[count2])) + self.tableTableWidget.setItem(row_position, 5, QtWidgets.QTableWidgetItem("RARBG")) count2 = count2 + 1 def tpb(): @@ -300,12 +335,14 @@ def tpb(): leechers_soup = main_soup.findAll('td', attrs={'align': "right"}) leechers_soup = leechers_soup[1::2] sizes_soup = main_soup.findAll('font', class_="detDesc") + dates_soup = main_soup.findAll('font', class_="detDesc") magnets_soup = main_soup.findAll('a', attrs={'href': re.compile("^magnet")}) titles = [] seeders = [] leechers = [] sizes = [] + dates = [] limit_counter = 0 for title in titles_soup: if limit_counter < limit: @@ -329,6 +366,13 @@ def tpb(): size = size[1].replace("Size ", "") sizes.append(size) limit_counter = limit_counter + 1 + limit_counter = 0 + for date in dates_soup: + if limit_counter < limit: + date = date.text.split(", ") + date = date[0].replace("Uploaded ", "") + dates.append(date) + limit_counter = limit_counter + 1 count1 = 0 limit_counter = 0 for magnet in magnets_soup: @@ -345,7 +389,8 @@ def tpb(): self.tableTableWidget.setItem(row_position, 1, QtWidgets.QTableWidgetItem(seeders[count2])) self.tableTableWidget.setItem(row_position, 2, QtWidgets.QTableWidgetItem(leechers[count2])) self.tableTableWidget.setItem(row_position, 3, QtWidgets.QTableWidgetItem(sizes[count2])) - self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem("TPB")) + self.tableTableWidget.setItem(row_position, 4, QtWidgets.QTableWidgetItem(dates[count2])) + self.tableTableWidget.setItem(row_position, 5, QtWidgets.QTableWidgetItem("TPB")) count2 = count2 + 1 if (self.x1377CheckBox.isChecked() and self.katCheckBox.isChecked() and self.nyaaCheckBox.isChecked() and self.rarbgCheckBox.isChecked() and self.tpbCheckBox.isChecked()): @@ -599,7 +644,7 @@ def setupUi(self, searchMainWindow): self.tableTableWidget = QtWidgets.QTableWidget(self.centralwidget) self.tableTableWidget.setGeometry(QtCore.QRect(260, 20, 1161, 360)) self.tableTableWidget.setObjectName("tableTableWidget") - self.tableTableWidget.setColumnCount(5) + self.tableTableWidget.setColumnCount(6) self.tableTableWidget.setRowCount(0) item = QtWidgets.QTableWidgetItem() self.tableTableWidget.setHorizontalHeaderItem(0, item) @@ -611,6 +656,8 @@ def setupUi(self, searchMainWindow): self.tableTableWidget.setHorizontalHeaderItem(3, item) item = QtWidgets.QTableWidgetItem() self.tableTableWidget.setHorizontalHeaderItem(4, item) + item = QtWidgets.QTableWidgetItem() + self.tableTableWidget.setHorizontalHeaderItem(5, item) self.katCheckBox = QtWidgets.QCheckBox(self.centralwidget) self.katCheckBox.setGeometry(QtCore.QRect(30, 110, 90, 20)) self.katCheckBox.setObjectName("katCheckBox") @@ -671,6 +718,8 @@ def retranslateUi(self, searchMainWindow): item = self.tableTableWidget.horizontalHeaderItem(3) item.setText(_translate("searchMainWindow", "Sizes")) item = self.tableTableWidget.horizontalHeaderItem(4) + item.setText(_translate("searchMainWindow", "Dates")) + item = self.tableTableWidget.horizontalHeaderItem(5) item.setText(_translate("searchMainWindow", "Source")) self.katCheckBox.setText(_translate("searchMainWindow", "KAT")) self.nyaaCheckBox.setText(_translate("searchMainWindow", "Nyaa")) @@ -678,4 +727,4 @@ def retranslateUi(self, searchMainWindow): self.tpbCheckBox.setText(_translate("searchMainWindow", "TPB")) self.searchPushButton.setText(_translate("searchMainWindow", "Search")) self.minimumLabel.setText(_translate("searchMainWindow", "0")) - self.maximumLabel.setText(_translate("searchMainWindow", "20")) + self.maximumLabel.setText(_translate("searchMainWindow", "20")) \ No newline at end of file