0.1.64
This commit is contained in:
parent
150d169681
commit
9c26a7ec96
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.1.63
|
version = 0.1.64
|
||||||
author = guanjihuan
|
author = guanjihuan
|
||||||
author_email = guanjihuan@163.com
|
author_email = guanjihuan@163.com
|
||||||
description = An open source python package
|
description = An open source python package
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: guan
|
Name: guan
|
||||||
Version: 0.1.63
|
Version: 0.1.64
|
||||||
Summary: An open source python package
|
Summary: An open source python package
|
||||||
Home-page: https://py.guanjihuan.com
|
Home-page: https://py.guanjihuan.com
|
||||||
Author: guanjihuan
|
Author: guanjihuan
|
||||||
|
@ -763,180 +763,6 @@ def compress_wav_to_mp3(wav_path, output_filename='a.mp3', bitrate='16k'):
|
|||||||
sound = AudioSegment.from_mp3(wav_path)
|
sound = AudioSegment.from_mp3(wav_path)
|
||||||
sound.export(output_filename,format="mp3",bitrate=bitrate)
|
sound.export(output_filename,format="mp3",bitrate=bitrate)
|
||||||
|
|
||||||
# 播放学术单词
|
|
||||||
@guan.statistics_decorator
|
|
||||||
def play_academic_words(reverse=0, random_on=0, bre_or_ame='ame', show_translation=1, show_link=1, translation_time=2, rest_time=1):
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
import re
|
|
||||||
import urllib.request
|
|
||||||
import requests
|
|
||||||
import os
|
|
||||||
import pygame
|
|
||||||
import time
|
|
||||||
import ssl
|
|
||||||
import random
|
|
||||||
ssl._create_default_https_context = ssl._create_unverified_context
|
|
||||||
html = urllib.request.urlopen("https://www.guanjihuan.com/archives/4418").read().decode('utf-8')
|
|
||||||
if bre_or_ame == 'ame':
|
|
||||||
directory = 'words_mp3_ameProns/'
|
|
||||||
elif bre_or_ame == 'bre':
|
|
||||||
directory = 'words_mp3_breProns/'
|
|
||||||
exist_directory = os.path.exists(directory)
|
|
||||||
html_file = urllib.request.urlopen("https://file.guanjihuan.com/words/"+directory).read().decode('utf-8')
|
|
||||||
if exist_directory == 0:
|
|
||||||
os.makedirs(directory)
|
|
||||||
soup = BeautifulSoup(html, features='lxml')
|
|
||||||
contents = re.findall('<h2.*?</a></p>', html, re.S)
|
|
||||||
if random_on==1:
|
|
||||||
random.shuffle(contents)
|
|
||||||
if reverse==1:
|
|
||||||
contents.reverse()
|
|
||||||
for content in contents:
|
|
||||||
soup2 = BeautifulSoup(content, features='lxml')
|
|
||||||
all_h2 = soup2.find_all('h2')
|
|
||||||
for h2 in all_h2:
|
|
||||||
if re.search('\d*. ', h2.get_text()):
|
|
||||||
word = re.findall('[a-zA-Z].*', h2.get_text(), re.S)[0]
|
|
||||||
exist = os.path.exists(directory+word+'.mp3')
|
|
||||||
if not exist:
|
|
||||||
try:
|
|
||||||
if re.search(word, html_file):
|
|
||||||
r = requests.get("https://file.guanjihuan.com/words/"+directory+word+".mp3", stream=True)
|
|
||||||
with open(directory+word+'.mp3', 'wb') as f:
|
|
||||||
for chunk in r.iter_content(chunk_size=32):
|
|
||||||
f.write(chunk)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
print(h2.get_text())
|
|
||||||
try:
|
|
||||||
pygame.mixer.init()
|
|
||||||
track = pygame.mixer.music.load(directory+word+'.mp3')
|
|
||||||
pygame.mixer.music.play()
|
|
||||||
if show_link==1:
|
|
||||||
print('https://www.ldoceonline.com/dictionary/'+word)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
translation = re.findall('<p>.*?</p>', content, re.S)[0][3:-4]
|
|
||||||
if show_translation==1:
|
|
||||||
time.sleep(translation_time)
|
|
||||||
print(translation)
|
|
||||||
time.sleep(rest_time)
|
|
||||||
pygame.mixer.music.stop()
|
|
||||||
print()
|
|
||||||
|
|
||||||
# 播放挑选过后的学术单词
|
|
||||||
@guan.statistics_decorator
|
|
||||||
def play_selected_academic_words(reverse=0, random_on=0, bre_or_ame='ame', show_link=1, rest_time=3):
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
import re
|
|
||||||
import urllib.request
|
|
||||||
import requests
|
|
||||||
import os
|
|
||||||
import pygame
|
|
||||||
import time
|
|
||||||
import ssl
|
|
||||||
import random
|
|
||||||
ssl._create_default_https_context = ssl._create_unverified_context
|
|
||||||
html = urllib.request.urlopen("https://www.guanjihuan.com/archives/24732").read().decode('utf-8')
|
|
||||||
if bre_or_ame == 'ame':
|
|
||||||
directory = 'words_mp3_ameProns/'
|
|
||||||
elif bre_or_ame == 'bre':
|
|
||||||
directory = 'words_mp3_breProns/'
|
|
||||||
exist_directory = os.path.exists(directory)
|
|
||||||
html_file = urllib.request.urlopen("https://file.guanjihuan.com/words/"+directory).read().decode('utf-8')
|
|
||||||
if exist_directory == 0:
|
|
||||||
os.makedirs(directory)
|
|
||||||
soup = BeautifulSoup(html, features='lxml')
|
|
||||||
contents = re.findall('<li>\d.*?</li>', html, re.S)
|
|
||||||
if random_on==1:
|
|
||||||
random.shuffle(contents)
|
|
||||||
if reverse==1:
|
|
||||||
contents.reverse()
|
|
||||||
for content in contents:
|
|
||||||
soup2 = BeautifulSoup(content, features='lxml')
|
|
||||||
all_li = soup2.find_all('li')
|
|
||||||
for li in all_li:
|
|
||||||
if re.search('\d*. ', li.get_text()):
|
|
||||||
word = re.findall('\s[a-zA-Z].*?\s', li.get_text(), re.S)[0][1:-1]
|
|
||||||
exist = os.path.exists(directory+word+'.mp3')
|
|
||||||
if not exist:
|
|
||||||
try:
|
|
||||||
if re.search(word, html_file):
|
|
||||||
r = requests.get("https://file.guanjihuan.com/words/"+directory+word+".mp3", stream=True)
|
|
||||||
with open(directory+word+'.mp3', 'wb') as f:
|
|
||||||
for chunk in r.iter_content(chunk_size=32):
|
|
||||||
f.write(chunk)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
print(li.get_text())
|
|
||||||
try:
|
|
||||||
pygame.mixer.init()
|
|
||||||
track = pygame.mixer.music.load(directory+word+'.mp3')
|
|
||||||
pygame.mixer.music.play()
|
|
||||||
if show_link==1:
|
|
||||||
print('https://www.ldoceonline.com/dictionary/'+word)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
time.sleep(rest_time)
|
|
||||||
pygame.mixer.music.stop()
|
|
||||||
print()
|
|
||||||
|
|
||||||
# 播放元素周期表上的单词
|
|
||||||
@guan.statistics_decorator
|
|
||||||
def play_element_words(random_on=0, show_translation=1, show_link=1, translation_time=2, rest_time=1):
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
import re
|
|
||||||
import urllib.request
|
|
||||||
import requests
|
|
||||||
import os
|
|
||||||
import pygame
|
|
||||||
import time
|
|
||||||
import ssl
|
|
||||||
import random
|
|
||||||
ssl._create_default_https_context = ssl._create_unverified_context
|
|
||||||
html = urllib.request.urlopen("https://www.guanjihuan.com/archives/10897").read().decode('utf-8')
|
|
||||||
directory = 'prons/'
|
|
||||||
exist_directory = os.path.exists(directory)
|
|
||||||
html_file = urllib.request.urlopen("https://file.guanjihuan.com/words/periodic_table_of_elements/"+directory).read().decode('utf-8')
|
|
||||||
if exist_directory == 0:
|
|
||||||
os.makedirs(directory)
|
|
||||||
soup = BeautifulSoup(html, features='lxml')
|
|
||||||
contents = re.findall('<h2.*?</a></p>', html, re.S)
|
|
||||||
if random_on==1:
|
|
||||||
random.shuffle(contents)
|
|
||||||
for content in contents:
|
|
||||||
soup2 = BeautifulSoup(content, features='lxml')
|
|
||||||
all_h2 = soup2.find_all('h2')
|
|
||||||
for h2 in all_h2:
|
|
||||||
if re.search('\d*. ', h2.get_text()):
|
|
||||||
word = re.findall('[a-zA-Z].* \(', h2.get_text(), re.S)[0][:-2]
|
|
||||||
exist = os.path.exists(directory+word+'.mp3')
|
|
||||||
if not exist:
|
|
||||||
try:
|
|
||||||
if re.search(word, html_file):
|
|
||||||
r = requests.get("https://file.guanjihuan.com/words/periodic_table_of_elements/prons/"+word+".mp3", stream=True)
|
|
||||||
with open(directory+word+'.mp3', 'wb') as f:
|
|
||||||
for chunk in r.iter_content(chunk_size=32):
|
|
||||||
f.write(chunk)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
print(h2.get_text())
|
|
||||||
try:
|
|
||||||
pygame.mixer.init()
|
|
||||||
track = pygame.mixer.music.load(directory+word+'.mp3')
|
|
||||||
pygame.mixer.music.play()
|
|
||||||
if show_link==1:
|
|
||||||
print('https://www.merriam-webster.com/dictionary/'+word)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
translation = re.findall('<p>.*?</p>', content, re.S)[0][3:-4]
|
|
||||||
if show_translation==1:
|
|
||||||
time.sleep(translation_time)
|
|
||||||
print(translation)
|
|
||||||
time.sleep(rest_time)
|
|
||||||
pygame.mixer.music.stop()
|
|
||||||
print()
|
|
||||||
|
|
||||||
# Guan软件包的使用统计(不涉及到用户的个人数据)
|
# Guan软件包的使用统计(不涉及到用户的个人数据)
|
||||||
global_variable_of_first_guan_package_calling = []
|
global_variable_of_first_guan_package_calling = []
|
||||||
def statistics_of_guan_package(function_name=None):
|
def statistics_of_guan_package(function_name=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user