forked from spdconvos/encryptedbot_py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRadioIDs.py
48 lines (37 loc) · 1.14 KB
/
RadioIDs.py
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
import logging
from typing import Dict, List
log = logging.getLogger(__name__)
namecache: Dict[str, str] = {}
def _getSet(srcList: List[dict]) -> List[str]:
"""Generates a list of unique sources.
Args:
srcList (List[dict]): The srcList to process.
Returns:
List[str]: Unique source IDs.
"""
result = set()
for src in srcList:
result.add(src["src"])
return list(result)
def _scrape(sources: List[str]) -> List[str]:
"""[summary]
Args:
sources (List[str]): [description]
Returns:
List[str]: [description]
"""
names: List[str] = []
for source in sources:
if source in namecache.keys:
names.append(namecache[source])
else:
# API stuff here, in progress. Even cache none so the API isn't battered
name = None
namecache[source] = name
names.append(name)
return [name for name in names if not name == None]
def getNames(srcList: List[dict]) -> List[str]:
sources = _getSet(srcList)
names = _scrape(sources)
log.info(f"Found {len(names)}/{len(srcList)} names")
return names