forked from TheAlgorithms/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoundCloud_track_info.py
More file actions
70 lines (53 loc) · 1.58 KB
/
SoundCloud_track_info.py
File metadata and controls
70 lines (53 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import youtube_dl
from typing import List
class SoundCloud:
def __init__(self, url: str) -> None:
self.url = url
self.info = self.extract_info()
def ydl_option(self) -> None:
return {"dumpjson": True, "extract_flat": True}
def extract_info(self) -> dict:
with youtube_dl.YoutubeDL(self.ydl_option()) as ydl:
return ydl.extract_info(url=self.url, download=False)
@property
def genre(self) -> str:
return self.info["genre"]
@property
def formats(self) -> List:
return self.info["formats"]
@property
def caption(self) -> str:
return self.info["description"]
@property
def thumbnails(self) -> List:
return self.info["thumbnails"]
@property
def view_count(self) -> int:
return self.info["view_count"]
@property
def comment_count(self) -> int:
return self.info["comment_count"]
@property
def repost_count(self) -> int:
return self.info["repost_count"]
@property
def like_count(self) -> int:
return self.info["like_count"]
@property
def idd(self) -> str:
return self.info["id"]
@property
def uploader(self) -> str:
return self.info["uploader"]
@property
def uploader_id(self) -> str:
return self.info["uploader_id"]
@property
def uploader_url(self) -> str:
return self.info["uploader_url"]
@property
def upload_date(self) -> int:
return self.info["timestamp"]
@property
def title(self) -> str:
return self.info["title"]