-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For rss/atom * retrieving image url from top level data * processing media_content as done for enclosure * priorizing `summary` over `content`
- Loading branch information
Showing
9 changed files
with
284 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Generator, List, Optional | ||
|
||
|
||
def reach_in( | ||
entry, key: str, sub_key: Optional[str] = None | ||
) -> Generator[str, None, None]: | ||
value = entry.get(key) | ||
if isinstance(value, str): | ||
assert sub_key in {None, "value", "href"}, ( | ||
"shouldn't reach for anything else but " | ||
"'value' if landing on a string value" | ||
) | ||
yield value | ||
elif isinstance(value, list): | ||
for sub_value in value: | ||
if isinstance(sub_value, dict): | ||
if sub_value.get(sub_key): | ||
yield sub_value[sub_key] | ||
elif isinstance(value, dict): | ||
if value.get(sub_key): | ||
yield value[sub_key] | ||
|
||
|
||
def browse_keys( | ||
entry, keys: List[str], sub_key: Optional[str] = None | ||
) -> Optional[str]: | ||
for key in keys: | ||
for value in reach_in(entry, key, sub_key): | ||
return value | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.