mirror of
https://github.com/status-im/airbyte-custom-connector.git
synced 2025-02-21 05:08:08 +00:00
simplecast: adding analytic_episode_download
Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
parent
e34407cffb
commit
083fa2d6a7
@ -14,7 +14,7 @@ data:
|
|||||||
connectorSubtype: api
|
connectorSubtype: api
|
||||||
connectorType: source
|
connectorType: source
|
||||||
definitionId: 464a7cea-0317-485e-9a9c-bcd06155bfff
|
definitionId: 464a7cea-0317-485e-9a9c-bcd06155bfff
|
||||||
dockerImageTag: 1.1.1
|
dockerImageTag: 1.1.2
|
||||||
dockerRepository: harbor.status.im/status-im/airbyte/source-simplecast-fetcher
|
dockerRepository: harbor.status.im/status-im/airbyte/source-simplecast-fetcher
|
||||||
githubIssueLabel: source-simplecast-fecther
|
githubIssueLabel: source-simplecast-fecther
|
||||||
icon: simplecast-fecther.svg
|
icon: simplecast-fecther.svg
|
||||||
|
@ -56,20 +56,6 @@
|
|||||||
"sync_mode": "incremental",
|
"sync_mode": "incremental",
|
||||||
"destination_sync_mode": "overwrite"
|
"destination_sync_mode": "overwrite"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"stream": {
|
|
||||||
"name": "analytic_episode",
|
|
||||||
"json_schema": {
|
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"supported_sync_modes": [
|
|
||||||
"full_refresh", "incremental"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"sync_mode": "incremental",
|
|
||||||
"destination_sync_mode": "overwrite"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"stream": {
|
"stream": {
|
||||||
"name": "analytic_download",
|
"name": "analytic_download",
|
||||||
@ -153,6 +139,20 @@
|
|||||||
},
|
},
|
||||||
"sync_mode": "incremental",
|
"sync_mode": "incremental",
|
||||||
"destination_sync_mode": "overwrite"
|
"destination_sync_mode": "overwrite"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"stream": {
|
||||||
|
"name": "analytic_episode_download",
|
||||||
|
"json_schema": {
|
||||||
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"supported_sync_modes": [
|
||||||
|
"full_refresh", "incremental"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"sync_mode": "incremental",
|
||||||
|
"destination_sync_mode": "overwrite"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"title": "Generated schema for Root",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"href": {
|
||||||
|
"type": ["null", "string"]
|
||||||
|
},
|
||||||
|
"total": {
|
||||||
|
"type": ["null", "number"]
|
||||||
|
},
|
||||||
|
"interval": {
|
||||||
|
"type": ["null", "string"]
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": ["null", "string"]
|
||||||
|
},
|
||||||
|
"by_interval": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": ["null", "object"],
|
||||||
|
"properties": {
|
||||||
|
"interval": {
|
||||||
|
"type": ["null", "string"]
|
||||||
|
},
|
||||||
|
"downloads_total": {
|
||||||
|
"type": ["null", "number"]
|
||||||
|
},
|
||||||
|
"downloads_percent": {
|
||||||
|
"type": ["null", "number"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -152,25 +152,6 @@ class AnalyticTimeOfWeek(AnalyticSubStream):
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(endpoint="time_of_week", keys_dict=TIME_OF_WEEK_KEYS, collection_name="collection", **kwargs)
|
super().__init__(endpoint="time_of_week", keys_dict=TIME_OF_WEEK_KEYS, collection_name="collection", **kwargs)
|
||||||
|
|
||||||
class AnalyticEpisode(AnalyticSubStream):
|
|
||||||
primary_key=None
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
super().__init__(endpoint="episodes", keys_dict=[], collection_name="", **kwargs)
|
|
||||||
|
|
||||||
def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
|
|
||||||
data=response.json()
|
|
||||||
logger.debug("Response: %s", data)
|
|
||||||
for elt in data.get('collection'):
|
|
||||||
analytic_episode={
|
|
||||||
"id": elt.get("id"),
|
|
||||||
"type": elt.get("type"),
|
|
||||||
"title": elt.get("title"),
|
|
||||||
"downloads": elt.get("downloads").get("total"),
|
|
||||||
"number": elt.get("number")
|
|
||||||
}
|
|
||||||
yield analytic_episode
|
|
||||||
|
|
||||||
class AnalyticDownload(AnalyticSubStream):
|
class AnalyticDownload(AnalyticSubStream):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
@ -221,8 +202,20 @@ class AnalyticPodcastV2(HttpSubStream, SimplecastFectherStream):
|
|||||||
logger.debug("Response: %s", data)
|
logger.debug("Response: %s", data)
|
||||||
yield data
|
yield data
|
||||||
|
|
||||||
|
class AnalyticEpisodeDownload(HttpSubStream, SimplecastFectherStream):
|
||||||
|
def path(
|
||||||
|
self,
|
||||||
|
stream_state: Mapping[str, Any] = None,
|
||||||
|
stream_slice: Mapping[str, Any] = None,
|
||||||
|
next_page_token: Mapping[str, Any] = None
|
||||||
|
) -> str:
|
||||||
|
episode_id=stream_slice.get("parent").get("id")
|
||||||
|
return f"analytics/downloads?episode={episode_id}"
|
||||||
|
|
||||||
|
def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
|
||||||
|
data=response.json()
|
||||||
|
logger.debug("Response: %s", data)
|
||||||
|
yield data
|
||||||
# Source
|
# Source
|
||||||
class SourceSimplecastFecther(AbstractSource):
|
class SourceSimplecastFecther(AbstractSource):
|
||||||
def check_connection(self, logger, config) -> Tuple[bool, any]:
|
def check_connection(self, logger, config) -> Tuple[bool, any]:
|
||||||
@ -237,11 +230,11 @@ class SourceSimplecastFecther(AbstractSource):
|
|||||||
episodes,
|
episodes,
|
||||||
AnalyticLocation(authenticator=auth, parent=podcasts),
|
AnalyticLocation(authenticator=auth, parent=podcasts),
|
||||||
AnalyticTimeOfWeek(authenticator=auth, parent=podcasts),
|
AnalyticTimeOfWeek(authenticator=auth, parent=podcasts),
|
||||||
AnalyticEpisode(authenticator=auth, parent=podcasts),
|
|
||||||
AnalyticDownload(authenticator=auth,parent=podcasts),
|
AnalyticDownload(authenticator=auth,parent=podcasts),
|
||||||
TechnologyApplication(authenticator=auth, parent=podcasts),
|
TechnologyApplication(authenticator=auth, parent=podcasts),
|
||||||
TechnologyDeviceClass(authenticator=auth, parent=podcasts),
|
TechnologyDeviceClass(authenticator=auth, parent=podcasts),
|
||||||
TechnologyListeningMethod(authenticator=auth, parent=podcasts),
|
TechnologyListeningMethod(authenticator=auth, parent=podcasts),
|
||||||
AnalyticEpisodeV2(authenticator=auth, parent=episodes),
|
AnalyticEpisodeV2(authenticator=auth, parent=episodes),
|
||||||
AnalyticPodcastV2(authenticator=auth, parent=podcasts)
|
AnalyticPodcastV2(authenticator=auth, parent=podcasts),
|
||||||
|
AnalyticEpisodeDownload(authenticator=auth, parent=episodes)
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user