Skip to content

Commit 9505488

Browse files
committed
Update SoundCloud_track_info.py
1 parent 5ccadb9 commit 9505488

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed
Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,70 @@
11
import youtube_dl
2-
2+
from typing import List
33

44
class SoundCloud:
5-
def __init__(self, url: str):
5+
def __init__(self, url: str) -> None:
66
self.url = url
77
self.info = self.extract_info()
88

9-
def ydl_option(self):
9+
def ydl_option(self) -> None:
1010
return {"dumpjson": True, "extract_flat": True}
1111

12-
def extract_info(self):
13-
try:
14-
with youtube_dl.YoutubeDL(self.ydl_option()) as ydl:
15-
return ydl.extract_info(url=self.url, download=False)
16-
except Exception as e:
17-
return e
18-
12+
def extract_info(self) -> dict:
13+
with youtube_dl.YoutubeDL(self.ydl_option()) as ydl:
14+
return ydl.extract_info(url=self.url, download=False)
15+
1916
@property
20-
def genre(self):
17+
def genre(self) -> str:
2118
return self.info["genre"]
2219

2320
@property
24-
def formats(self):
21+
def formats(self) -> List:
2522
return self.info["formats"]
2623

2724
@property
28-
def caption(self):
25+
def caption(self) -> str:
2926
return self.info["description"]
3027

3128
@property
32-
def thumbnails(self):
29+
def thumbnails(self) -> List:
3330
return self.info["thumbnails"]
3431

3532
@property
36-
def view_count(self):
33+
def view_count(self) -> int:
3734
return self.info["view_count"]
3835

3936
@property
40-
def comment_count(self):
37+
def comment_count(self) -> int:
4138
return self.info["comment_count"]
4239

4340
@property
44-
def repost_count(self):
41+
def repost_count(self) -> int:
4542
return self.info["repost_count"]
4643

4744
@property
48-
def like_count(self):
45+
def like_count(self) -> int:
4946
return self.info["like_count"]
5047

5148
@property
52-
def idd(self):
49+
def idd(self) -> str:
5350
return self.info["id"]
5451

5552
@property
56-
def uploader(self):
53+
def uploader(self) -> str:
5754
return self.info["uploader"]
5855

5956
@property
60-
def uploader_id(self):
57+
def uploader_id(self) -> str:
6158
return self.info["uploader_id"]
6259

6360
@property
64-
def uploader_url(self):
61+
def uploader_url(self) -> str:
6562
return self.info["uploader_url"]
6663

6764
@property
68-
def upload_date(self):
65+
def upload_date(self) -> int:
6966
return self.info["timestamp"]
7067

7168
@property
72-
def title(self):
69+
def title(self) -> str:
7370
return self.info["title"]

0 commit comments

Comments
 (0)