Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

Commit 4e88f0c

Browse files
committed
default no qr use -g to generage qr
1 parent 626c2d3 commit 4e88f0c

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

gadio/crawlers/crawler.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def download_audio(audio: Audio, file_dir: str):
7575
return
7676

7777
@staticmethod
78-
def download_assets(radio: Radio, file_dir: str):
78+
def download_assets(radio: Radio, file_dir: str, with_quote: bool):
7979
id = str(radio.radio_id)
8080
file_dir = file_dir + os.sep + id
8181
Crawler.download_image(radio.cover, file_dir)
@@ -85,7 +85,8 @@ def download_assets(radio: Radio, file_dir: str):
8585

8686
for page in radio.timeline.values():
8787
Crawler.download_image(page.image, file_dir)
88-
Crawler.make_quote_qr_image(page.quote_href, page.image.local_name, file_dir + os.sep + "qr_quotes")
88+
if with_quote:
89+
Crawler.make_quote_qr_image(page.quote_href, page.image.local_name, file_dir + os.sep + "qr_quotes")
8990

9091
@staticmethod
9192
def get_latest():
@@ -128,13 +129,16 @@ def make_quote_qr_image(text, name, file_dir):
128129
print("Saving qr_quotes", name)
129130
if text:
130131
name = name.split('.')[0] + ".png"
131-
myqr.run(
132-
text,
133-
version=2,
134-
level="H",
135-
picture=None,
136-
colorized=False,
137-
contrast=1.0,
138-
save_name=name,
139-
save_dir=file_dir,
140-
)
132+
try:
133+
myqr.run(
134+
text,
135+
version=2,
136+
level="H",
137+
picture=None,
138+
colorized=False,
139+
contrast=1.0,
140+
save_name=name,
141+
save_dir=file_dir,
142+
)
143+
except:
144+
print("wrong qr code")

gcores.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,33 @@
44
from gadio.text.text import *
55
import sys
66

7-
def main(id: int, skip_crawling: bool):
7+
8+
def main(id: int, skip_crawling: bool, with_quote: bool):
89
parsed_json = Crawler.crawl(id)
910
cache_dir = os.sep.join([os.curdir, 'cache', str(id), 'data.json'])
1011
with open(cache_dir, 'r', encoding='utf-8') as file:
1112
radio = Radio.load_from_json(parsed_json)
1213
if (not skip_crawling):
13-
Crawler.download_assets(radio, os.curdir+os.sep+'cache')
14+
Crawler.download_assets(radio, os.curdir+os.sep+'cache', with_quote)
1415
Video.create_video(radio)
1516

1617
if __name__ == "__main__":
1718
skip_crawling = False
18-
if (len(sys.argv) == 1 or sys.argv[1]=='-s'):
19+
with_quote = False
20+
if (len(sys.argv) == 1 or sys.argv[1] == '-s' or sys.argv[1] == '-q'):
21+
if "-q" in sys.argv:
22+
with_quote = True
1923
print("----------")
2024
print("Start to create the latest gadio video...")
2125
id = Crawler.get_latest()
2226
print(id)
23-
main(id, False)
27+
main(id, False, with_quote)
2428
else:
2529
title = sys.argv[1]
2630
skip_crawling = False
2731
if (len(sys.argv) > 2):
2832
if ("-s" in sys.argv):
2933
skip_crawling = True
30-
main(int(title), skip_crawling)
34+
elif "-q" in sys.argv:
35+
with_quote = True
36+
main(int(title), skip_crawling, with_quote)

0 commit comments

Comments
 (0)