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

Commit

Permalink
default no qr use -g to generage qr
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong0618 committed Sep 26, 2019
1 parent 626c2d3 commit 4e88f0c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
28 changes: 16 additions & 12 deletions gadio/crawlers/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def download_audio(audio: Audio, file_dir: str):
return

@staticmethod
def download_assets(radio: Radio, file_dir: str):
def download_assets(radio: Radio, file_dir: str, with_quote: bool):
id = str(radio.radio_id)
file_dir = file_dir + os.sep + id
Crawler.download_image(radio.cover, file_dir)
Expand All @@ -85,7 +85,8 @@ def download_assets(radio: Radio, file_dir: str):

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

@staticmethod
def get_latest():
Expand Down Expand Up @@ -128,13 +129,16 @@ def make_quote_qr_image(text, name, file_dir):
print("Saving qr_quotes", name)
if text:
name = name.split('.')[0] + ".png"
myqr.run(
text,
version=2,
level="H",
picture=None,
colorized=False,
contrast=1.0,
save_name=name,
save_dir=file_dir,
)
try:
myqr.run(
text,
version=2,
level="H",
picture=None,
colorized=False,
contrast=1.0,
save_name=name,
save_dir=file_dir,
)
except:
print("wrong qr code")
16 changes: 11 additions & 5 deletions gcores.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,33 @@
from gadio.text.text import *
import sys

def main(id: int, skip_crawling: bool):

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

if __name__ == "__main__":
skip_crawling = False
if (len(sys.argv) == 1 or sys.argv[1]=='-s'):
with_quote = False
if (len(sys.argv) == 1 or sys.argv[1] == '-s' or sys.argv[1] == '-q'):
if "-q" in sys.argv:
with_quote = True
print("----------")
print("Start to create the latest gadio video...")
id = Crawler.get_latest()
print(id)
main(id, False)
main(id, False, with_quote)
else:
title = sys.argv[1]
skip_crawling = False
if (len(sys.argv) > 2):
if ("-s" in sys.argv):
skip_crawling = True
main(int(title), skip_crawling)
elif "-q" in sys.argv:
with_quote = True
main(int(title), skip_crawling, with_quote)

0 comments on commit 4e88f0c

Please sign in to comment.