Skip to content

Commit

Permalink
50% performance of the tag research
Browse files Browse the repository at this point in the history
  • Loading branch information
lachhebo committed Jun 8, 2019
1 parent 77128b7 commit 27218d5
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 30 deletions.
10 changes: 5 additions & 5 deletions data/com.github.lachhebo.Gabtag.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<releases>
<release date="2019-06-08" version="1.3.0"/>
<release date="2019-06-09" version="1.3.1"/>
</releases>
<version>1.3.0</version>
<version>1.3.1</version>
​<categories>
<category>Audio</category>
<category>AudioVideo</category>
</categories>
<summary> An audio tagging tool </summary>
<description>
Expand All @@ -28,10 +28,10 @@
</description>
<screenshots>
<screenshot type="default" height="647" width="894">
<image>https://raw.githubusercontent.com/lachhebo/GabTag/screenshots/Gabtag-V1_2-1.png</image>
<image>https://raw.githubusercontent.com/lachhebo/GabTag/screenshots/Gabtag_v13_1.png</image>
</screenshot>
<screenshot type="default" height="647" width="894">
<image>https://raw.githubusercontent.com/lachhebo/GabTag/screenshots/Gabtag-V1_2-2.png</image>
<image>https://raw.githubusercontent.com/lachhebo/GabTag/screenshots/Gabtag_v13_2.png</image>
</screenshot>
</screenshots>
<update_contact>[email protected]</update_contact>
Expand Down
62 changes: 61 additions & 1 deletion src/Crawler_dir.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from threading import Thread, RLock
from .data_crawler import Data_Crawler
from .model import Model
import time

verrou = RLock()

Expand All @@ -17,6 +18,65 @@ def __init__(self, directory, store):
def run(self):
"""Code à exécuter pendant l'exécution du thread."""
with verrou :
self.data_crawler.crawl_data(self.directory,self.store)

filelist = self.data_crawler.get_filelist(self.directory)

filelist1 = []
filelist2 = []
filelist3 = []
filelist4 = []

i= 1
for filen in filelist :
if i == 1:
filelist1.append(filen)
i = 2
elif i == 2:
filelist2.append(filen)
i = 3
elif i == 3 :
filelist3.append(filen)
i = 4
elif i == 4 :
filelist4.append(filen)
i = 1

thread_mbz1 = Thread(target = self.data_crawler.get_data_from_online, args=(filelist1,self.directory)) #Writing data
thread_mbz2 = Thread(target = self.data_crawler.get_data_from_online, args=(filelist2,self.directory))
thread_mbz3 = Thread(target = self.data_crawler.get_data_from_online, args=(filelist3,self.directory))
thread_mbz4 = Thread(target = self.data_crawler.get_data_from_online, args=(filelist4,self.directory))


thread_mbz1.start()
thread_mbz2.start()
thread_mbz3.start()
thread_mbz4.start()

'''
while not self.data_crawler.is_finished(filelist):
time.sleep(0.3)
selection = self.model.selection
if selection != None :
model, listiter = selection.get_selected_rows()
print("model", len(listiter))
if len(listiter) == 1:
if model[listiter][0] in self.data_crawler.tag_finder and model[listiter][0] in self.data_crawler.lyrics:
data_scrapped = self.data_crawler.get_tags(model, listiter, 0)
lyrics_scrapped = self.data_crawler.get_lyrics(model, listiter, 0)
print("data scrapped", data_scrapped)
self.model.view.show_mbz(data_scrapped)
self.model.view.show_lyrics(lyrics_scrapped)
'''

thread_mbz1.join()
thread_mbz2.join()
thread_mbz3.join()
thread_mbz4.join()



30 changes: 15 additions & 15 deletions src/Crawler_modif.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ def run(self):
self.data_crawler.update_data_crawled(self.modifs,self.directory)


if(self.selectionequal(self.model.selection)):
model, listiter = self.model.selection.get_selected_rows()
if(self.selectionequal(self.model.selection)):
model, listiter = self.model.selection.get_selected_rows()

if len(listiter)> 1 :
multiple_line_selected = 1
else :
multiple_line_selected = 0
if len(listiter)> 1 :
multiple_line_selected = 1
else :
multiple_line_selected = 0


data_scrapped = self.data_crawler.get_tags(model, listiter, multiple_line_selected)
lyrics_scrapped = self.data_crawler.get_lyrics(model, listiter, multiple_line_selected)
data_scrapped = self.data_crawler.get_tags(model, listiter, multiple_line_selected)
lyrics_scrapped = self.data_crawler.get_lyrics(model, listiter, multiple_line_selected)

if(self.selectionequal(self.model.selection)):
self.model.view.show_mbz(data_scrapped)
self.model.view.show_lyrics(lyrics_scrapped)
else :
pass
if(self.selectionequal(self.model.selection)):
self.model.view.show_mbz(data_scrapped)
self.model.view.show_lyrics(lyrics_scrapped)
else :
pass



Expand All @@ -77,10 +77,10 @@ def selectionequal(self,selec):
for i in range(len(listiter)):
namefile = model[listiter[i]][0]
if namefile not in self.filenames:
print("why element ? ",namefile)
#print("why element ? ",namefile)
return False
else :
print("why size ?")
#print("why size ?")
return False

return True
Expand Down
23 changes: 19 additions & 4 deletions src/data_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,31 @@ def crawl_lyrics(self, namefile, directory):
def update_data_crawled(self,modifications, directory):
for namefile in modifications :
self.treeview.remove_crawled([namefile])
print("we update tags :",namefile)
#print("we update tags :",namefile)
if self.stop(directory):
break
self.crawl_one_file(namefile,directory)
if self.stop(directory):
break
self.crawl_lyrics(namefile,directory)

def crawl_data(self,directory,store):
self.directory = directory

def erase_data(self):
self.tag_finder = {}
self.lyrics = {}

def get_filelist(self,directory):
self.directory = directory

filelist = []
for (dirpath, dirnames, filenames) in walk(directory):
filelist.extend(filenames)
break

i = 0
return filelist

def get_data_from_online(self,filelist,directory):

for namefile in filelist:
if Moteur().check_extension(namefile) and self.internet == True :

Expand All @@ -117,6 +123,15 @@ def crawl_data(self,directory,store):
if self.stop(directory):
break

def is_finished(self,filelist):
for namefile in filelist :
if namefile in self.tag_finder :
if namefile not in self.lyrics:
return False
else :
return False
return True


def stop(self, directory):
if self.directory == directory :
Expand Down
1 change: 1 addition & 0 deletions src/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self):
self.directory = ""
self.modification = {}
self.view = View.getInstance()
self.selection = None
self.moteur = Moteur()
self.tagdico = { #TODO add that in a separate json file.
"title" :{ "value": ""},
Expand Down
4 changes: 0 additions & 4 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ def open_clicked(self, widget):
self.opened_directory = True
self.data_crawler.update_directory(dialog.get_filename())
model.update_directory(dialog.get_filename(),self.liststore1)
'''
thread_mbz = threading.Thread(target = self.data_crawler.crawl_data, args=(dialog.get_filename(),self.liststore1)) #Writing data
thread_mbz.start()
'''
thread = Crawler_Dir(model.directory,self.liststore1)
thread.start()

Expand Down
2 changes: 1 addition & 1 deletion src/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<property name="title" translatable="yes">About</property>
<property name="type_hint">dialog</property>
<property name="program_name">GabTag</property>
<property name="version">1.3.0</property>
<property name="version">1.3.1</property>
<property name="comments" translatable="yes">GabTag is an open-source audio tagging tool written in gtk3.</property>
<property name="authors">Ismaël Lachheb</property>
<property name="logo_icon_name">com.github.lachhebo.Gabtag</property>
Expand Down

0 comments on commit 27218d5

Please sign in to comment.