删除日志
This commit is contained in:
parent
fce38ab51d
commit
e68cec504d
|
@ -119,7 +119,6 @@ class CloudMusicRouter():
|
|||
|
||||
|
||||
async def async_browse_media(media_player, media_content_type, media_content_id):
|
||||
print(media_content_type, media_content_id)
|
||||
hass = media_player.hass
|
||||
cloud_music = hass.data['cloud_music']
|
||||
|
||||
|
@ -730,7 +729,6 @@ async def async_browse_media(media_player, media_content_type, media_content_id)
|
|||
|
||||
''' ================== 播放音乐 ================== '''
|
||||
async def async_play_media(media_player, cloud_music, media_content_id):
|
||||
print(media_content_id)
|
||||
hass = media_player.hass
|
||||
# 媒体库
|
||||
if media_source.is_media_source_id(media_content_id):
|
||||
|
|
|
@ -73,8 +73,6 @@ class CloudMusic():
|
|||
}
|
||||
save_json(self.userinfo_filepath, self.userinfo)
|
||||
return res_data
|
||||
else:
|
||||
print(res_data)
|
||||
|
||||
# 二维码登录
|
||||
async def qrcode_login(self, cookie_str):
|
||||
|
@ -127,9 +125,7 @@ class CloudMusic():
|
|||
async def netease_cloud_music(self, url):
|
||||
res = await http_get(self.api_url + url, self.userinfo.get('cookie', {}))
|
||||
code = res.get('code')
|
||||
print(code, url)
|
||||
if code != 200 and code != 801:
|
||||
print(res)
|
||||
msg = res.get('msg')
|
||||
if msg is not None:
|
||||
self.notification(msg)
|
||||
|
|
|
@ -35,8 +35,7 @@ class SimpleConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
if res['data']['code'] == 200:
|
||||
user_input[CONF_URL] = url
|
||||
return self.async_create_entry(title=DOMAIN, data=user_input)
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
except Exception as ex:
|
||||
errors = { 'base': 'api_failed' }
|
||||
else:
|
||||
user_input = {}
|
||||
|
|
|
@ -21,7 +21,6 @@ class HttpView(HomeAssistantView):
|
|||
cloud_music = hass.data['cloud_music']
|
||||
|
||||
query = request.query
|
||||
print(query)
|
||||
id = query.get('id')
|
||||
source = query.get('source')
|
||||
song = query.get('song')
|
||||
|
@ -65,7 +64,6 @@ class HttpView(HomeAssistantView):
|
|||
if result is not None:
|
||||
play_url = result.url
|
||||
|
||||
print(play_url)
|
||||
self.play_key = play_key
|
||||
self.play_url = play_url
|
||||
# 重定向到可播放链接
|
||||
|
@ -80,7 +78,6 @@ class HttpView(HomeAssistantView):
|
|||
'source': 'netease'
|
||||
})
|
||||
data = res.json()
|
||||
# print(data)
|
||||
return data.get('url')
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
pass
|
|
@ -1,45 +1,45 @@
|
|||
from bs4 import BeautifulSoup
|
||||
import requests, re
|
||||
import requests
|
||||
import re
|
||||
from .models.music_info import MusicInfo, MusicSource
|
||||
|
||||
|
||||
def get_last_part(path):
|
||||
last_slash_index = path.rfind('/')
|
||||
last_slash_index = path.rfind('/')
|
||||
if last_slash_index != -1:
|
||||
return path[last_slash_index + 1:]
|
||||
return path
|
||||
|
||||
|
||||
def get_music(keyword):
|
||||
# https://www.gequbao.com
|
||||
api = 'https://www.fangpi.net'
|
||||
session = requests.Session()
|
||||
try:
|
||||
response = session.get(f'{api}/s/{keyword}')
|
||||
soup = BeautifulSoup(response.text.encode(response.encoding), 'lxml')
|
||||
items = soup.select('.card-text .row')
|
||||
if len(items) > 1:
|
||||
row = items[1]
|
||||
# print(td)
|
||||
song = row.select('.col-5 a')[0].get_text().strip()
|
||||
singer = row.select('.col-4')[0].get_text().strip()
|
||||
# https://www.gequbao.com
|
||||
api = 'https://www.fangpi.net'
|
||||
session = requests.Session()
|
||||
try:
|
||||
response = session.get(f'{api}/s/{keyword}')
|
||||
soup = BeautifulSoup(response.text.encode(response.encoding), 'lxml')
|
||||
items = soup.select('.card-text .row')
|
||||
if len(items) > 1:
|
||||
row = items[1]
|
||||
song = row.select('.col-5 a')[0].get_text().strip()
|
||||
singer = row.select('.col-4')[0].get_text().strip()
|
||||
|
||||
a = row.select('.col-3 a')
|
||||
href = a[0].attrs['href']
|
||||
|
||||
# print(href)
|
||||
response = session.get(f'{api}{href}')
|
||||
html = response.text
|
||||
a = row.select('.col-3 a')
|
||||
href = a[0].attrs['href']
|
||||
|
||||
soup = BeautifulSoup(html, 'lxml')
|
||||
cover = soup.select('head meta[property="og:image"]')
|
||||
#print(cover)
|
||||
pic = 'https://p2.music.126.net/tGHU62DTszbFQ37W9qPHcg==/2002210674180197.jpg'
|
||||
# 封面
|
||||
if len(cover) > 0:
|
||||
pic = cover[0].attrs['content']
|
||||
response = session.get(f'{api}{href}')
|
||||
html = response.text
|
||||
|
||||
songId = get_last_part(href)
|
||||
album = ''
|
||||
audio_url = f'https://www.fangpi.net/api/play_url?id={songId}'
|
||||
return MusicInfo(songId, song, singer, album, 0, audio_url, pic, MusicSource.URL.value)
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
soup = BeautifulSoup(html, 'lxml')
|
||||
cover = soup.select('head meta[property="og:image"]')
|
||||
pic = 'https://p2.music.126.net/tGHU62DTszbFQ37W9qPHcg==/2002210674180197.jpg'
|
||||
# 封面
|
||||
if len(cover) > 0:
|
||||
pic = cover[0].attrs['content']
|
||||
|
||||
songId = get_last_part(href)
|
||||
album = ''
|
||||
audio_url = f'https://www.fangpi.net/api/play_url?id={songId}'
|
||||
return MusicInfo(songId, song, singer, album, 0, audio_url, pic, MusicSource.URL.value)
|
||||
except Exception as ex:
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue