Upload insecta.py with huggingface_hub
Browse files- insecta.py +13 -16
insecta.py
CHANGED
|
@@ -12,26 +12,23 @@ from io import BytesIO
|
|
| 12 |
_HOME = f"https://www.modelscope.cn/datasets/Genius-Society/{os.path.basename(__file__)[:-3]}"
|
| 13 |
|
| 14 |
_URL = "https://master.dl.sourceforge.net/project/git-large-file-storage.mirror/v3.7.1/git-lfs-linux-amd64-v3.7.1.tar.gz"
|
| 15 |
-
|
| 16 |
# for sound
|
| 17 |
_ENDPOINT = "https://www.missevan.com"
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
def chrome_ver():
|
| 21 |
-
return requests.get(
|
| 22 |
-
"https://www.modelscope.cn/models/Genius-Society/latest_mirrors/resolve/master/chrome/version"
|
| 23 |
-
).text.split(".")[0]
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
_HEADER = {
|
| 27 |
-
"User-Agent": f"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{chrome_ver()}.0.0.0 Safari/537.36"
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
# for video
|
| 31 |
_BVID = "BV14krgYJE4B"
|
| 32 |
|
| 33 |
|
| 34 |
class insecta(datasets.GeneratorBasedBuilder):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
def _info(self):
|
| 36 |
if self.config.name == "default":
|
| 37 |
self.config.name = "image"
|
|
@@ -128,7 +125,7 @@ class insecta(datasets.GeneratorBasedBuilder):
|
|
| 128 |
response = requests.get(
|
| 129 |
f"{_ENDPOINT}/dramaapi/getdramaepisodedetails",
|
| 130 |
params={"drama_id": drama_id, "p": 1, "page_size": page_size},
|
| 131 |
-
headers=
|
| 132 |
)
|
| 133 |
response.raise_for_status()
|
| 134 |
return response.json()["info"]["Datas"]
|
|
@@ -140,7 +137,7 @@ class insecta(datasets.GeneratorBasedBuilder):
|
|
| 140 |
|
| 141 |
def _dld_img(self, url: str):
|
| 142 |
try:
|
| 143 |
-
response = requests.get(url, headers=
|
| 144 |
response.raise_for_status()
|
| 145 |
return Image.open(BytesIO(response.content))
|
| 146 |
|
|
@@ -154,7 +151,7 @@ class insecta(datasets.GeneratorBasedBuilder):
|
|
| 154 |
response = requests.get(
|
| 155 |
"https://api.bilibili.com/x/player/pagelist",
|
| 156 |
params={"bvid": _BVID},
|
| 157 |
-
headers=
|
| 158 |
)
|
| 159 |
response.raise_for_status()
|
| 160 |
return response.json()["data"]
|
|
|
|
| 12 |
_HOME = f"https://www.modelscope.cn/datasets/Genius-Society/{os.path.basename(__file__)[:-3]}"
|
| 13 |
|
| 14 |
_URL = "https://master.dl.sourceforge.net/project/git-large-file-storage.mirror/v3.7.1/git-lfs-linux-amd64-v3.7.1.tar.gz"
|
|
|
|
| 15 |
# for sound
|
| 16 |
_ENDPOINT = "https://www.missevan.com"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# for video
|
| 18 |
_BVID = "BV14krgYJE4B"
|
| 19 |
|
| 20 |
|
| 21 |
class insecta(datasets.GeneratorBasedBuilder):
|
| 22 |
+
def _chrome_ver(self):
|
| 23 |
+
return requests.get(
|
| 24 |
+
"https://www.modelscope.cn/models/Genius-Society/latest_mirrors/resolve/master/chrome/version"
|
| 25 |
+
).text.split(".")[0]
|
| 26 |
+
|
| 27 |
+
def _header(self):
|
| 28 |
+
return {
|
| 29 |
+
"User-Agent": f"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{self._chrome_ver()}.0.0.0 Safari/537.36"
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
def _info(self):
|
| 33 |
if self.config.name == "default":
|
| 34 |
self.config.name = "image"
|
|
|
|
| 125 |
response = requests.get(
|
| 126 |
f"{_ENDPOINT}/dramaapi/getdramaepisodedetails",
|
| 127 |
params={"drama_id": drama_id, "p": 1, "page_size": page_size},
|
| 128 |
+
headers=self._header(),
|
| 129 |
)
|
| 130 |
response.raise_for_status()
|
| 131 |
return response.json()["info"]["Datas"]
|
|
|
|
| 137 |
|
| 138 |
def _dld_img(self, url: str):
|
| 139 |
try:
|
| 140 |
+
response = requests.get(url, headers=self._header())
|
| 141 |
response.raise_for_status()
|
| 142 |
return Image.open(BytesIO(response.content))
|
| 143 |
|
|
|
|
| 151 |
response = requests.get(
|
| 152 |
"https://api.bilibili.com/x/player/pagelist",
|
| 153 |
params={"bvid": _BVID},
|
| 154 |
+
headers=self._header(),
|
| 155 |
)
|
| 156 |
response.raise_for_status()
|
| 157 |
return response.json()["data"]
|