Skip to content

Commit 6396087

Browse files
author
phanstudio
committed
update
1 parent 4f0c0d9 commit 6396087

File tree

13 files changed

+510
-512
lines changed

13 files changed

+510
-512
lines changed

Utility/subtitles_extracter.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import subprocess
2-
import sys, os
3-
2+
import os
43
from vosk import Model, KaldiRecognizer, SetLogLevel
54
from .constants import ROOTPATH
65

@@ -12,10 +11,22 @@ def exctractors_srt(url, num, nam):
1211
rec = KaldiRecognizer(model, SAMPLE_RATE)
1312
rec.SetWords(True)
1413

15-
with subprocess.Popen(["ffmpeg", "-loglevel", "quiet", "-i",
16-
url,
17-
"-ar", str(SAMPLE_RATE) , "-ac", "1", "-f", "s16le", "-"],
18-
stdout=subprocess.PIPE).stdout as stream:
14+
with subprocess.Popen(
15+
[
16+
"ffmpeg",
17+
"-loglevel",
18+
"quiet",
19+
"-i",
20+
url,
21+
"-ar",
22+
str(SAMPLE_RATE) ,
23+
"-ac",
24+
"1",
25+
"-f",
26+
"s16le",
27+
"-",
28+
],
29+
stdout=subprocess.PIPE).stdout as stream:
1930

2031

2132
# writing the string to a new file
@@ -24,4 +35,4 @@ def exctractors_srt(url, num, nam):
2435
if not os.path.exists(subtt):
2536
os.makedirs(subtt)
2637
with open(srtout, 'w') as newfile:
27-
newfile.write(rec.SrtResult(stream, 15))
38+
newfile.write(rec.SrtResult(stream, 15))

Utility/utility.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ def per_clamp(n, minn = 274.4, maxn= 1530.4):
1010
def cnr(ids, src, val, per, time, text):
1111
return {'ids':ids, 'src':src, 'val': val, 'per': per, 'time': time, 'text': text}
1212

13-
def p221(p2, page:pG):
14-
p2.onchange(per_clamp(page.window.width, 282.4))
15-
if page.route == '/lib':
16-
p2.update()
17-
1813
def change_theme(page:pG) -> None:
1914
page.theme_mode = (
2015
ft.ThemeMode.LIGHT

main.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import flet as ft
22
from Utility import *
3-
from user_controls import BookProgressSheet
43
from view import routes
54

65
# delete ffmpeg
@@ -29,18 +28,7 @@ def metadata(page: ft.Page):
2928

3029
def add_overlays(page):
3130
page.overlay.append(ft.SnackBar(ft.Text("love"), duration= 1000))
32-
page.overlay.append(BookProgressSheet(1000)) # remove and normall in add, and delete in add
3331
page.overlay.append(ft.FilePicker())
34-
# page.overlay.append(
35-
# Column(
36-
# controls=[
37-
# ElevatedButton('test', on_click= lambda _: change_theme(page)
38-
# ),
39-
# ]
40-
# ,bottom= 80,
41-
# alignment= 'end'
42-
# )
43-
# )
4432

4533
def main(page: ft.Page): # add security
4634
metadata(page)

user_controls/list_tile.py

Lines changed: 117 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -4,135 +4,135 @@
44
from Utility import ROOTPATH, GOLD
55
from textwrap import TextWrapper
66

7-
class ListTile(ft.IconButton):
8-
def __init__(self, txt, prog= 'd'):
9-
super().__init__()
10-
self.txt = txt
11-
self.on_click = self.onclick
12-
self.fin = False
13-
if prog == 'd':
14-
vis = [True,False,False]
15-
self.fin = False
16-
elif prog == 'p':
17-
vis = [False,False,True]
18-
else:
19-
self.fin = True
20-
vis = [False,True,False]
21-
self.prg = ft.Ref[ft.ProgressBar]()
22-
self.ico = ft.Ref[ft.Icon]()
23-
self.exit = ft.Ref[ft.Icon]()
7+
# class ListTile(ft.IconButton): # check
8+
# def __init__(self, txt, prog= 'd'):
9+
# super().__init__()
10+
# self.txt = txt
11+
# self.on_click = self.onclick
12+
# self.fin = False
13+
# if prog == 'd':
14+
# vis = [True,False,False]
15+
# self.fin = False
16+
# elif prog == 'p':
17+
# vis = [False,False,True]
18+
# else:
19+
# self.fin = True
20+
# vis = [False,True,False]
21+
# self.prg = ft.Ref[ft.ProgressBar]()
22+
# self.ico = ft.Ref[ft.Icon]()
23+
# self.exit = ft.Ref[ft.Icon]()
2424

25-
self.text_container = ft.Text(txt, size= 12)
25+
# self.text_container = ft.Text(txt, size= 12)
2626

27-
self.content= ft.Container(
28-
ft.Row([
29-
self.text_container,
30-
ft.ProgressBar(width=60, ref= self.prg, visible= vis[0]),
31-
ft.Icon(name= ft.Icons.DONE, color= GOLD, ref= self.ico, visible= vis[1]),
32-
ft.Icon(name= ft.Icons.CANCEL, color= GOLD, ref= self.exit, visible= vis[2])
33-
], alignment= ft.MainAxisAlignment.SPACE_BETWEEN),
34-
bgcolor= ft.Colors.with_opacity(0.1, GOLD),
35-
border_radius= 60,
36-
padding= 15,
37-
expand= True)
27+
# self.content= ft.Container(
28+
# ft.Row([
29+
# self.text_container,
30+
# ft.ProgressBar(width=60, ref= self.prg, visible= vis[0]),
31+
# ft.Icon(name= ft.Icons.DONE, color= GOLD, ref= self.ico, visible= vis[1]),
32+
# ft.Icon(name= ft.Icons.CANCEL, color= GOLD, ref= self.exit, visible= vis[2])
33+
# ], alignment= ft.MainAxisAlignment.SPACE_BETWEEN),
34+
# bgcolor= ft.Colors.with_opacity(0.1, GOLD),
35+
# border_radius= 60,
36+
# padding= 15,
37+
# expand= True)
3838

39-
def onclick(self, e):
40-
if self.fin:
41-
self.page.go(f'/lib/{self.txt}')
39+
# def onclick(self, e):
40+
# if self.fin:
41+
# self.page.go(f'/lib/{self.txt}')
4242

43-
def done(self, prog='d'):
44-
if prog == 'd':
45-
self.prg.current.visible = True
46-
self.ico.current.visible = False
47-
self.exit.current.visible = False
48-
self.fin = False
49-
self.update()
50-
else:
51-
self.exit.current.visible = False
52-
self.prg.current.visible = False
53-
self.ico.current.visible = True
54-
self.fin = True
55-
self.update()
43+
# def done(self, prog='d'):
44+
# if prog == 'd':
45+
# self.prg.current.visible = True
46+
# self.ico.current.visible = False
47+
# self.exit.current.visible = False
48+
# self.fin = False
49+
# self.update()
50+
# else:
51+
# self.exit.current.visible = False
52+
# self.prg.current.visible = False
53+
# self.ico.current.visible = True
54+
# self.fin = True
55+
# self.update()
5656

57-
class BookProgressSheet(ft.BottomSheet):
58-
def __init__(self, height: ft.OptionalNumber = None):
59-
self.body = ft.Ref[ft.Column]()
60-
self.list_body = ft.ListView([], expand= True)
61-
super().__init__(
62-
show_drag_handle = True,
63-
content = ft.Column(
64-
ref= self.body,
65-
controls=[
66-
ft.ElevatedButton(
67-
"x",
68-
height= 5,
69-
width= 100,
70-
on_click= self.onclose,
71-
visible= False,
72-
bgcolor= ft.Colors.with_opacity(0.3, ft.Colors.INVERSE_SURFACE)
73-
),
74-
ft.Text('Latest Adds'),
75-
self.list_body,
76-
],
77-
horizontal_alignment= ft.CrossAxisAlignment.CENTER,
78-
expand=True
79-
)
80-
)
57+
# class BookProgressSheet(ft.BottomSheet):
58+
# def __init__(self, height: ft.OptionalNumber = None):
59+
# self.body = ft.Ref[ft.Column]()
60+
# self.list_body = ft.ListView([], expand= True)
61+
# super().__init__(
62+
# show_drag_handle = True,
63+
# content = ft.Column(
64+
# ref= self.body,
65+
# controls=[
66+
# ft.ElevatedButton(
67+
# "x",
68+
# height= 5,
69+
# width= 100,
70+
# on_click= self.onclose,
71+
# visible= False,
72+
# bgcolor= ft.Colors.with_opacity(0.3, ft.Colors.INVERSE_SURFACE)
73+
# ),
74+
# ft.Text('Latest Adds'),
75+
# self.list_body,
76+
# ],
77+
# horizontal_alignment= ft.CrossAxisAlignment.CENTER,
78+
# expand=True
79+
# )
80+
# )
8181

82-
self.shadow = ft.BoxShadow(
83-
blur_style= ft.ShadowBlurStyle.OUTER,
84-
blur_radius= 4,
85-
color= ft.Colors.with_opacity(0.2, ft.Colors.INVERSE_SURFACE),
86-
)
87-
self.height = height
82+
# self.shadow = ft.BoxShadow(
83+
# blur_style= ft.ShadowBlurStyle.OUTER,
84+
# blur_radius= 4,
85+
# color= ft.Colors.with_opacity(0.2, ft.Colors.INVERSE_SURFACE),
86+
# )
87+
# self.height = height
8888

89-
# height
90-
@property
91-
def height(self) -> ft.OptionalNumber:
92-
return self._get_attr("height")
89+
# # height
90+
# @property
91+
# def height(self) -> ft.OptionalNumber:
92+
# return self._get_attr("height")
9393

94-
@height.setter
95-
def height(self, value: ft.OptionalNumber):
96-
self._set_attr("height", value)
94+
# @height.setter
95+
# def height(self, value: ft.OptionalNumber):
96+
# self._set_attr("height", value)
9797

98-
def clear(self):
99-
dts: list = self.page.client_storage.get_keys('Book')
100-
dts.remove('Book.hist')
101-
self.page.client_storage.set('Book.hist', [])
102-
# add clear the path
98+
# def clear(self):
99+
# dts: list = self.page.client_storage.get_keys('Book')
100+
# dts.remove('Book.hist')
101+
# self.page.client_storage.set('Book.hist', [])
102+
# # add clear the path
103103

104-
for i in dts:
105-
self.page.client_storage.remove(i)
106-
shutil.rmtree(os.path.join(ROOTPATH,'Books',f'{i.split(".")[-1]}'))
104+
# for i in dts:
105+
# self.page.client_storage.remove(i)
106+
# shutil.rmtree(os.path.join(ROOTPATH,'Books',f'{i.split(".")[-1]}'))
107107

108-
def onclose(self, e):
109-
# self.visible = False
110-
if self.expand == True:
111-
self.expand = False
112-
self.open = False
113-
for i in self.body.current.controls[1:]:
114-
i.visible = False
115-
else:
116-
self.expand = True
117-
self.open = True
118-
for i in self.body.current.controls[1:]:
119-
i.visible = True
120-
self.update()
108+
# def onclose(self, e):
109+
# # self.visible = False
110+
# if self.expand == True:
111+
# self.expand = False
112+
# self.open = False
113+
# for i in self.body.current.controls[1:]:
114+
# i.visible = False
115+
# else:
116+
# self.expand = True
117+
# self.open = True
118+
# for i in self.body.current.controls[1:]:
119+
# i.visible = True
120+
# self.update()
121121

122-
def popup(self):
123-
self.page.open(self)
124-
self.page.update()
122+
# def popup(self):
123+
# self.page.open(self)
124+
# self.page.update()
125125

126-
def did_mount(self):
127-
past_hist:list = self.page.client_storage.get('Book.hist')
128-
if past_hist != None:
129-
books = self.page.client_storage.get_keys('Book')
126+
# def did_mount(self):
127+
# past_hist:list = self.page.client_storage.get('Book.hist')
128+
# if past_hist != None:
129+
# books = self.page.client_storage.get_keys('Book')
130130

131-
past_hist.reverse()
132-
w = TextWrapper(25)
131+
# past_hist.reverse()
132+
# w = TextWrapper(25)
133133

134-
for i in past_hist:
135-
p = 'f' if 'Book.'+i in books else 'd'
136-
i = w.fill(i)
137-
self.list_body.controls.append(ListTile(i, p))
138-
return super().did_mount()
134+
# for i in past_hist:
135+
# p = 'f' if 'Book.'+i in books else 'd'
136+
# i = w.fill(i)
137+
# self.list_body.controls.append(ListTile(i, p))
138+
# return super().did_mount()

user_controls/navbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self, currect_index):
1313
ft.NavigationBarDestination('Home', ft.Icons.HOME_ROUNDED, data= '/'),
1414
ft.NavigationBarDestination('Add', ft.Icons.ADD_BOX, data= '/add'),
1515
ft.NavigationBarDestination('Lib', ft.Icons.LOCAL_LIBRARY_ROUNDED, data= '/lib'),
16-
ft.NavigationBarDestination('Section', ft.Icons.BOOK, data= '/section'),
16+
# ft.NavigationBarDestination('Section', ft.Icons.BOOK, data= '/section'),
1717
ft.NavigationBarDestination('Note', ft.Icons.EDIT_NOTE, data= '/note'),
1818
],
1919
on_change= self.onchange,

user_controls/note.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def onhover(self, e: ControlEvent):
7676
def onclick(self, e: ControlEvent):
7777
self.frame.scale = 1.01
7878
e.control.update()
79-
self.page.go(f'/note/{self.id}')
79+
self.page.session.set("NoteId", self.id)
80+
self.page.go(f'/editnote')
8081

8182
def tags(self, text, color):
8283
color = color[1:]

0 commit comments

Comments
 (0)