chore: update __all__
, fix tests
This commit is contained in:
parent
2cdda43cea
commit
2580e4cbfe
@ -1,7 +1,5 @@
|
|||||||
from dataclasses import dataclass
|
|
||||||
from http.cookiejar import LoadError, MozillaCookieJar
|
from http.cookiejar import LoadError, MozillaCookieJar
|
||||||
from json import dumps as dumpJson
|
from json import dumps as dumpJson
|
||||||
from typing import Iterable
|
|
||||||
|
|
||||||
from httpx import Client as HttpXClient
|
from httpx import Client as HttpXClient
|
||||||
from httpx import Request as HttpXRequest
|
from httpx import Request as HttpXRequest
|
||||||
@ -14,6 +12,8 @@ from .error import (
|
|||||||
)
|
)
|
||||||
from .object import NCMAlbum, NCMLyrics, NCMPlaylist, NCMTrack
|
from .object import NCMAlbum, NCMLyrics, NCMPlaylist, NCMTrack
|
||||||
|
|
||||||
|
__all__ = ["NCMApi"]
|
||||||
|
|
||||||
REQUEST_HEADERS = {
|
REQUEST_HEADERS = {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Accept-Encoding": "zstd, br, gzip, deflate",
|
"Accept-Encoding": "zstd, br, gzip, deflate",
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
from httpx import RequestError
|
from httpx import RequestError
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"NCMLyricsAppError",
|
||||||
|
"NCMApiError",
|
||||||
|
"NCMApiRequestError",
|
||||||
|
"NCMApiRetryLimitExceededError",
|
||||||
|
"ObjectParseError",
|
||||||
|
"ParseLinkError",
|
||||||
|
"UnsupportedLinkError",
|
||||||
|
"UnsupportedPureMusicTrackError",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class NCMLyricsAppError(Exception):
|
class NCMLyricsAppError(Exception):
|
||||||
"""NCMLyrics 错误"""
|
"""NCMLyrics 错误"""
|
||||||
|
@ -10,7 +10,7 @@ from .enum import LrcMetaType, LrcType
|
|||||||
from .error import UnsupportedPureMusicTrackError
|
from .error import UnsupportedPureMusicTrackError
|
||||||
from .object import NCMLyrics
|
from .object import NCMLyrics
|
||||||
|
|
||||||
__all__ = ["LrcType", "LrcMetaType", "Lrc"]
|
__all__ = ["Lrc"]
|
||||||
|
|
||||||
LRC_RE_COMMIT = reCompile(r"^\s*#")
|
LRC_RE_COMMIT = reCompile(r"^\s*#")
|
||||||
LRC_RE_META = reCompile(r"^\s*\[(?P<type>ti|ar|al|au|length|by|offset):\s*(?P<content>.+?)\s*\]\s*$")
|
LRC_RE_META = reCompile(r"^\s*\[(?P<type>ti|ar|al|au|length|by|offset):\s*(?P<content>.+?)\s*\]\s*$")
|
||||||
|
@ -10,6 +10,8 @@ from .enum import LinkType
|
|||||||
from .error import ParseLinkError, UnsupportedLinkError
|
from .error import ParseLinkError, UnsupportedLinkError
|
||||||
from .object import NCMTrack
|
from .object import NCMTrack
|
||||||
|
|
||||||
|
__all__ = ["Link", "parseLink", "testExistTrackSource", "pickOutput"]
|
||||||
|
|
||||||
RE_ANDROID_ALBUM_SHARE_LINK_PATH = reCompile(r"^/album/(?P<id>\d*)/?$")
|
RE_ANDROID_ALBUM_SHARE_LINK_PATH = reCompile(r"^/album/(?P<id>\d*)/?$")
|
||||||
RE_SAFE_FILENAME = reCompile(r"\*{2,}")
|
RE_SAFE_FILENAME = reCompile(r"\*{2,}")
|
||||||
TRANSLATER_SAFE_FILENAME = str.maketrans({i: 0x2A for i in ("<", ">", ":", '"', "/", "\\", "|", "?")})
|
TRANSLATER_SAFE_FILENAME = str.maketrans({i: 0x2A for i in ("<", ">", ":", '"', "/", "\\", "|", "?")})
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from ncmlyrics.api import NCMTrack
|
from ncmlyrics.enum import LinkType
|
||||||
from ncmlyrics.error import ParseLinkError, UnsupportLinkError
|
from ncmlyrics.error import ParseLinkError, UnsupportedLinkError
|
||||||
from ncmlyrics.util import Link, LinkType, parseLink, pickOutput, testExistTrackSource
|
from ncmlyrics.object import NCMTrack
|
||||||
|
from ncmlyrics.util import Link, parseLink, pickOutput, testExistTrackSource
|
||||||
|
|
||||||
|
|
||||||
class TestUtils(TestCase):
|
class TestUtils(TestCase):
|
||||||
@ -73,19 +74,19 @@ class TestUtils(TestCase):
|
|||||||
|
|
||||||
def test_parseLink_UnsupportShareLinkError(self):
|
def test_parseLink_UnsupportShareLinkError(self):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
UnsupportLinkError,
|
UnsupportedLinkError,
|
||||||
parseLink,
|
parseLink,
|
||||||
"https://www.google.com/",
|
"https://www.google.com/",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
UnsupportLinkError,
|
UnsupportedLinkError,
|
||||||
parseLink,
|
parseLink,
|
||||||
"https://music.163.com/unsupport?id=123",
|
"https://music.163.com/unsupport?id=123",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
UnsupportLinkError,
|
UnsupportedLinkError,
|
||||||
parseLink,
|
parseLink,
|
||||||
"https://music.163.com/album/123a",
|
"https://music.163.com/album/123a",
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user