iBet uBet web content aggregator. Adding the entire web to your favor.
iBet uBet web content aggregator. Adding the entire web to your favor.



Link to original content: http://github.com/persepolisdm/persepolis/commit/d5097c9183021d7a3b5e59dcc0dc5ccfb0452fac
The bug of not registering the new category has been fixed. · persepolisdm/persepolis@d5097c9 · GitHub
Skip to content

Commit

Permalink
The bug of not registering the new category has been fixed.
Browse files Browse the repository at this point in the history
 Changes to be committed:
	modified:   persepolis/scripts/data_base.py
	modified:   persepolis/scripts/mainwindow.py
	modified:   persepolis/scripts/properties.py
  • Loading branch information
alireza-amirsamimi committed Oct 7, 2024
1 parent e7b8a00 commit d5097c9
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 63 deletions.
10 changes: 4 additions & 6 deletions persepolis/scripts/data_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ def returnItemsInAddLinkTable(self, category=None):

return addlink_dict

# this method updates download_db_table
# this method updates download_db_table
def updateDownloadTable(self, list_):
# lock data base
self.lockCursor()
Expand Down Expand Up @@ -965,7 +965,7 @@ def updateDownloadTable(self, list_):
# job is done! open the lock
self.lock = False

# this method updates category_db_table
# this method updates category_db_table
def updateCategoryTable(self, list_):
# lock data base
self.lockCursor()
Expand Down Expand Up @@ -1011,7 +1011,7 @@ def updateCategoryTable(self, list_):
# job is done! open the lock
self.lock = False

# this method updates addlink_db_table
# this method updates addlink_db_table
def updateAddLinkTable(self, list_):
# lock data base
self.lockCursor()
Expand Down Expand Up @@ -1044,14 +1044,12 @@ def updateAddLinkTable(self, list_):
update_query_set_statements_list.append(f"{key} = :{key}")

update_query_set_statements = ' ,\n '.join(update_query_set_statements_list)
update_query = f"""UPDATE addlink_db_table SET
update_query = f"""UPDATE addlink_db_table SET
{update_query_set_statements}
WHERE gid = :gid
"""

if len(update_query_set_statements_list) > 0:
self.persepolis_db_cursor.execute(update_query, dict_)

# commit the changes!
self.persepolis_db_connection.commit()

Expand Down
50 changes: 15 additions & 35 deletions persepolis/scripts/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2912,45 +2912,25 @@ def propertiesCallback(self, add_link_dictionary, gid, category,

def propertiesCallback2(self, add_link_dictionary, gid, category,
video_finder_dictionary=None):
# current_category_tree_text is current category
# that highlighted by user
# in the left side panel
current_category_tree_text = str(
self.category_tree.currentIndex().data())

selected_row_return = self.selectedRow() # find user's selected row

# find current category before changing
current_category = self.download_table.item(
selected_row_return, 12).text()

if video_finder_dictionary:
# add audio and video gid to the gid list
gid_list = [video_finder_dictionary['video_gid'],
video_finder_dictionary['audio_gid']]

else:
gid_list = [gid]

# find row of gid in gid_list!
for gid in gid_list:
# highlight category of this download item
# find selected category in left side panel
for i in range(self.category_tree_model.rowCount()):
category_tree_item_text = str(
self.category_tree_model.index(i, 0).data())
if category_tree_item_text == category:
category_index = i
break

row = None
for i in range(self.download_table.rowCount()):
row_gid = self.download_table.item(i, 8).text()
if gid == row_gid:
row = i
break
# highlight selected category in category_tree
category_tree_model_index = self.category_tree_model.index(
category_index, 0)

if row:
if current_category_tree_text == 'All Downloads':
# update category in download_table
item = QTableWidgetItem(str(category))
self.download_table.setItem(row, 12, item)
current_category_tree_text = current_category_tree_index.data()

elif (str(current_category) != str(category)):
# remove row from download_table
self.download_table.removeRow(row)
self.category_tree.setCurrentIndex(category_tree_model_index)
if current_category_tree_text != category:
self.categoryTreeSelected(category_tree_model_index)

# tell the CheckDownloadInfoThread that job is done!
global checking_flag
Expand Down
93 changes: 71 additions & 22 deletions persepolis/scripts/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,23 +331,22 @@ def queueChanged(self, combo):
self.start_checkBox.setEnabled(True)
self.end_checkBox.setEnabled(True)

def okButtonPressed(self, button):
# write user's new inputs in persepolis_setting for next time if needed
if self.folder_checkBox.isChecked() is True:
self.persepolis_setting.setValue(
'settings/download_path', self.download_folder_lineEdit.text())

# this method returns proxy information.
def getProxyInformation(self):
# http, https or socks5 proxy
if self.http_radioButton.isChecked() is True:

proxy_type = 'http'

elif self.https_radioButton.isChecked() is True:

proxy_type = 'https'

else:

proxy_type = 'socks5'

# get proxy information
if not (self.proxy_checkBox.isChecked()):
ip = None
port = None
Expand All @@ -359,7 +358,7 @@ def okButtonPressed(self, button):
if not (ip):
ip = None

port = str(self.port_spinBox.value())
port = self.port_spinBox.value()
if not (port):
port = None

Expand All @@ -371,33 +370,24 @@ def okButtonPressed(self, button):
if not (proxy_passwd):
proxy_passwd = None

if not (self.download_checkBox.isChecked()):
return ip, port, proxy_user, proxy_passwd, proxy_type

def getUserPass(self):
# get download username and password information
if not (self.download_checkBox.isChecked()):
download_user = None
download_passwd = None
else:

download_user = self.download_user_lineEdit.text()
if not (download_user):
download_user = None

download_passwd = self.download_pass_lineEdit.text()
if not (download_passwd):
download_passwd = None

if not (self.start_checkBox.isChecked()):
start_time = None
else:
start_time = self.start_time_qDataTimeEdit.text()

if not (self.end_checkBox.isChecked()):
end_time = None
else:
end_time = self.end_time_qDateTimeEdit.text()

connections = self.connections_spinBox.value()
download_path = self.download_folder_lineEdit.text()
return download_user, download_passwd

def getAdditionalInformation(self):
# referer
if self.referer_lineEdit.text() != '':
referer = self.referer_lineEdit.text()
Expand All @@ -422,6 +412,38 @@ def okButtonPressed(self, button):
else:
load_cookies = None

return referer, header, user_agent, load_cookies

def okButtonPressed(self, button):
# write user's new inputs in persepolis_setting for next time if needed
if self.folder_checkBox.isChecked() is True:
self.persepolis_setting.setValue(
'settings/download_path', self.download_folder_lineEdit.text())

# get proxy information
ip, port, proxy_user, proxy_passwd, proxy_type = self.getProxyInformation()
if proxy_type is not None:
self.persepolis_setting.setValue('add_link_initialization/proxy_type', proxy_type)

# get download username and password information
download_user, download_passwd = self.getUserPass()

if not (self.start_checkBox.isChecked()):
start_time = None
else:
start_time = self.start_time_qDataTimeEdit.text()

if not (self.end_checkBox.isChecked()):
end_time = None
else:
end_time = self.end_time_qDateTimeEdit.text()

connections = self.connections_spinBox.value()
download_path = self.download_folder_lineEdit.text()

# get additinal information
referer, header, user_agent, load_cookies = self.getAdditionalInformation()

self.add_link_dictionary_1['start_time'] = start_time
self.add_link_dictionary_1['end_time'] = end_time
self.add_link_dictionary_1['link'] = self.link_lineEdit.text()
Expand Down Expand Up @@ -466,12 +488,39 @@ def okButtonPressed(self, button):
# update data base
self.parent.persepolis_db.updateDownloadTable([self.download_table_dict_1])

# update category_db_table
# remove download item from old category
old_category_dict = self.parent.persepolis_db.searchCategoryInCategoryTable(self.current_category)
old_category_gid_list = old_category_dict['gid_list']
old_category_gid_list.remove(self.gid_1)
self.parent.persepolis_db.updateCategoryTable([old_category_dict])

# add download item to new category
new_category_dict = self.parent.persepolis_db.searchCategoryInCategoryTable(new_category)
new_category_gid_list = new_category_dict['gid_list']
new_category_gid_list.append(self.gid_1)
self.parent.persepolis_db.updateCategoryTable([new_category_dict])

if self.video_finder_dictionary:

# category for audio and video must be same as each other
self.download_table_dict_2['category'] = new_category
self.parent.persepolis_db.updateDownloadTable([self.download_table_dict_2])

# update category_db_table
# remove download item from old category
old_category_dict = self.parent.persepolis_db.searchCategoryInCategoryTable(self.current_category)
old_category_gid_list = old_category_dict['gid_list']
old_category_gid_list.remove(self.gid_2)
self.parent.persepolis_db.updateCategoryTable([old_category_dict])

# add download item to new category
new_category_dict = self.parent.persepolis_db.searchCategoryInCategoryTable(new_category)
new_category_gid_list = new_category_dict['gid_list']
new_category_gid_list.append(self.gid_2)
self.parent.persepolis_db.updateCategoryTable([new_category_dict])


# if any thing in add_link_dictionary_1 is changed,then update data base!
for key in self.add_link_dictionary_1.keys():
if self.add_link_dictionary_1[key] != self.add_link_dictionary_1_backup[key]:
Expand Down

0 comments on commit d5097c9

Please sign in to comment.