chronicle-apple-podcasts 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +136 -0
- data/README.md +25 -0
- data/Rakefile +4 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/chronicle-apple-podcasts.gemspec +45 -0
- data/lib/chronicle/apple-podcasts/listen_extractor.rb +94 -0
- data/lib/chronicle/apple-podcasts/listen_transformer.rb +109 -0
- data/lib/chronicle/apple-podcasts/version.rb +7 -0
- data/lib/chronicle/apple-podcasts.rb +5 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3367bc3b410c66812dbfe80c779963f332c810bafc7b3c76a33887091ba5c507
|
4
|
+
data.tar.gz: ff20330e22e826d624754facdaa6b34609e39bf2ad2874231df5a38275f41edc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5861817ce03dc3141d09ae3bf8204a268955c9f6e18bd1ae8e990bb71f60306683a63e58de8a5520515d61e02ebef9ff736c1ca6d8bee7ab9f9964308f5083e2
|
7
|
+
data.tar.gz: 79a76dadd0d894716be313f08bac8397408a0a27f2505bc2012c1676849a51e6c9268d7c99ee8630aef0815ff5e94b4f44f1abd2f67d6fe5d0442c486feef1e7
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at andrew@hyfen.net. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
chronicle-apple-podcasts (0.1.0)
|
5
|
+
chronicle-etl (~> 0.5)
|
6
|
+
reverse_markdown (~> 2.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (7.0.3.1)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
addressable (2.8.1)
|
17
|
+
public_suffix (>= 2.0.2, < 6.0)
|
18
|
+
byebug (11.1.3)
|
19
|
+
chronic_duration (0.10.6)
|
20
|
+
numerizer (~> 0.1.1)
|
21
|
+
chronicle-etl (0.5.5)
|
22
|
+
activesupport (~> 7.0)
|
23
|
+
chronic_duration (~> 0.10.6)
|
24
|
+
colorize (~> 0.8.1)
|
25
|
+
gems (>= 1)
|
26
|
+
launchy
|
27
|
+
marcel (~> 1.0.2)
|
28
|
+
mini_exiftool (~> 2.10)
|
29
|
+
nokogiri (~> 1.13)
|
30
|
+
omniauth (~> 2)
|
31
|
+
sequel (~> 5.35)
|
32
|
+
sinatra (~> 2)
|
33
|
+
sqlite3 (~> 1.4)
|
34
|
+
thor (~> 1.2)
|
35
|
+
thor-hollaback (~> 0.2)
|
36
|
+
tty-progressbar (~> 0.17)
|
37
|
+
tty-prompt (~> 0.23)
|
38
|
+
tty-spinner
|
39
|
+
tty-table (~> 0.11)
|
40
|
+
xdg (>= 4.0)
|
41
|
+
coderay (1.1.3)
|
42
|
+
colorize (0.8.1)
|
43
|
+
concurrent-ruby (1.1.10)
|
44
|
+
gems (1.2.0)
|
45
|
+
hashie (5.0.0)
|
46
|
+
hollaback (0.1.1)
|
47
|
+
i18n (1.12.0)
|
48
|
+
concurrent-ruby (~> 1.0)
|
49
|
+
launchy (2.5.0)
|
50
|
+
addressable (~> 2.7)
|
51
|
+
marcel (1.0.2)
|
52
|
+
method_source (1.0.0)
|
53
|
+
mini_exiftool (2.10.2)
|
54
|
+
minitest (5.16.3)
|
55
|
+
mustermann (2.0.2)
|
56
|
+
ruby2_keywords (~> 0.0.1)
|
57
|
+
nokogiri (1.13.8-arm64-darwin)
|
58
|
+
racc (~> 1.4)
|
59
|
+
numerizer (0.1.1)
|
60
|
+
omniauth (2.1.0)
|
61
|
+
hashie (>= 3.4.6)
|
62
|
+
rack (>= 2.2.3)
|
63
|
+
rack-protection
|
64
|
+
pastel (0.8.0)
|
65
|
+
tty-color (~> 0.5)
|
66
|
+
pry (0.14.1)
|
67
|
+
coderay (~> 1.1)
|
68
|
+
method_source (~> 1.0)
|
69
|
+
pry-byebug (3.10.1)
|
70
|
+
byebug (~> 11.0)
|
71
|
+
pry (>= 0.13, < 0.15)
|
72
|
+
public_suffix (5.0.0)
|
73
|
+
racc (1.6.0)
|
74
|
+
rack (2.2.4)
|
75
|
+
rack-protection (2.2.2)
|
76
|
+
rack
|
77
|
+
rake (13.0.6)
|
78
|
+
reverse_markdown (2.1.1)
|
79
|
+
nokogiri
|
80
|
+
ruby2_keywords (0.0.5)
|
81
|
+
sequel (5.60.1)
|
82
|
+
sinatra (2.2.2)
|
83
|
+
mustermann (~> 2.0)
|
84
|
+
rack (~> 2.2)
|
85
|
+
rack-protection (= 2.2.2)
|
86
|
+
tilt (~> 2.0)
|
87
|
+
sqlite3 (1.5.0-arm64-darwin)
|
88
|
+
strings (0.2.1)
|
89
|
+
strings-ansi (~> 0.2)
|
90
|
+
unicode-display_width (>= 1.5, < 3.0)
|
91
|
+
unicode_utils (~> 1.4)
|
92
|
+
strings-ansi (0.2.0)
|
93
|
+
thor (1.2.1)
|
94
|
+
thor-hollaback (0.2.1)
|
95
|
+
hollaback (~> 0.1)
|
96
|
+
thor (>= 0.19.1)
|
97
|
+
tilt (2.0.11)
|
98
|
+
tty-color (0.6.0)
|
99
|
+
tty-cursor (0.7.1)
|
100
|
+
tty-progressbar (0.18.2)
|
101
|
+
strings-ansi (~> 0.2)
|
102
|
+
tty-cursor (~> 0.7)
|
103
|
+
tty-screen (~> 0.8)
|
104
|
+
unicode-display_width (>= 1.6, < 3.0)
|
105
|
+
tty-prompt (0.23.1)
|
106
|
+
pastel (~> 0.8)
|
107
|
+
tty-reader (~> 0.8)
|
108
|
+
tty-reader (0.9.0)
|
109
|
+
tty-cursor (~> 0.7)
|
110
|
+
tty-screen (~> 0.8)
|
111
|
+
wisper (~> 2.0)
|
112
|
+
tty-screen (0.8.1)
|
113
|
+
tty-spinner (0.9.3)
|
114
|
+
tty-cursor (~> 0.7)
|
115
|
+
tty-table (0.12.0)
|
116
|
+
pastel (~> 0.8)
|
117
|
+
strings (~> 0.2.0)
|
118
|
+
tty-screen (~> 0.8)
|
119
|
+
tzinfo (2.0.5)
|
120
|
+
concurrent-ruby (~> 1.0)
|
121
|
+
unicode-display_width (2.2.0)
|
122
|
+
unicode_utils (1.4.0)
|
123
|
+
wisper (2.0.1)
|
124
|
+
xdg (6.5.0)
|
125
|
+
|
126
|
+
PLATFORMS
|
127
|
+
arm64-darwin-20
|
128
|
+
|
129
|
+
DEPENDENCIES
|
130
|
+
bundler (~> 2.3)
|
131
|
+
chronicle-apple-podcasts!
|
132
|
+
pry-byebug (~> 3.9)
|
133
|
+
rake (~> 13.0)
|
134
|
+
|
135
|
+
BUNDLED WITH
|
136
|
+
2.3.8
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Chronicle::ApplePodcasts
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/chronicle-apple-podcasts.svg)](https://badge.fury.io/rb/chronicle-apple-podcasts)
|
3
|
+
|
4
|
+
Extract your Apple Podcasts listening history with this plugin for [chronicle-etl](https://github.com/chronicle-app/chronicle-etl)
|
5
|
+
|
6
|
+
## Available Connectors
|
7
|
+
### Extractors
|
8
|
+
- `listens` - Extractor for podcast episode listening history
|
9
|
+
|
10
|
+
### Transformers
|
11
|
+
- `listen` - Transforms a listen into Chronicle Schema
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```sh
|
16
|
+
# Install chronicle-etl and then this plugin
|
17
|
+
$ gem install chronicle-etl
|
18
|
+
$ chronicle-etl connectors:install apple-podcasts
|
19
|
+
|
20
|
+
# Extract all history
|
21
|
+
$ chronicle-etl --extractor apple-podcasts:listens
|
22
|
+
|
23
|
+
# Get last week of history and transform it into Chronicle Schema
|
24
|
+
$ chronicle-etl --extractor apple-podcasts:listens --since 1w --transformer apple-podcasts
|
25
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "chronicle/apple-podcasts"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "chronicle/apple-podcasts/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "chronicle-apple-podcasts"
|
9
|
+
spec.version = Chronicle::ApplePodcasts::VERSION
|
10
|
+
spec.authors = ["Andrew Louis"]
|
11
|
+
spec.email = ["andrew@hyfen.net"]
|
12
|
+
|
13
|
+
spec.summary = "Apple Podcasts importer for Chronicle"
|
14
|
+
spec.description = "Apple Podcasts connectors"
|
15
|
+
spec.homepage = "https://github.com/chronicle-app/chronicle-apple-podcasts"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/chronicle-app/chronicle-apple-podcasts"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/chronicle-app/chronicle-apple-podcasts"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_dependency "chronicle-etl", "~> 0.5"
|
40
|
+
spec.add_dependency 'reverse_markdown', '~> 2.0'
|
41
|
+
|
42
|
+
spec.add_development_dependency "bundler", "~> 2.3"
|
43
|
+
spec.add_development_dependency "rake", "~> 13.0.6"
|
44
|
+
spec.add_development_dependency "pry-byebug", "~> 3.9"
|
45
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'chronicle/etl'
|
2
|
+
require 'sqlite3'
|
3
|
+
|
4
|
+
module Chronicle
|
5
|
+
module ApplePodcasts
|
6
|
+
class ListenExtractor < Chronicle::ETL::Extractor
|
7
|
+
register_connector do |r|
|
8
|
+
r.provider = 'apple-podcasts'
|
9
|
+
r.identifier = 'listens'
|
10
|
+
r.description = 'listening history'
|
11
|
+
end
|
12
|
+
|
13
|
+
# macOS Catalina and higher
|
14
|
+
setting :input, default: File.join(Dir.home, 'Library', 'Group Containers', '243LU875E5.groups.com.apple.podcasts', 'Documents', 'MTLibrary.sqlite'), required: true
|
15
|
+
|
16
|
+
setting :icloud_account_id
|
17
|
+
setting :icloud_account_account_dsid
|
18
|
+
setting :icloud_account_account_display_name
|
19
|
+
|
20
|
+
def prepare
|
21
|
+
@db = SQLite3::Database.new(@config.input, results_as_hash: true, readonly: true)
|
22
|
+
@icloud_account = load_icloud_account
|
23
|
+
@history = load_history
|
24
|
+
end
|
25
|
+
|
26
|
+
def extract
|
27
|
+
@history.each do |entry|
|
28
|
+
entry.transform_keys!(&:to_sym)
|
29
|
+
yield Chronicle::ETL::Extraction.new(data: entry, meta: { icloud_account: @icloud_account } )
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def results_count
|
34
|
+
@history.count
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def load_icloud_account
|
40
|
+
{
|
41
|
+
id: @config.icloud_account_id || icloud_account_info_default[:AccountID],
|
42
|
+
dsid: @config.icloud_account_dsid || icloud_account_info_default[:AccountDSID],
|
43
|
+
display_name: @config.icloud_account_display_name || icloud_account_info_default[:DisplayName]
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def icloud_account_info_default
|
48
|
+
@icloud_account_info_default || begin
|
49
|
+
output = `defaults read MobileMeAccounts Accounts | plutil -convert json -r -o - -- -`
|
50
|
+
JSON.parse(output, symbolize_names: true).first
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_history
|
55
|
+
conditions = []
|
56
|
+
conditions << "last_played_utc < datetime('now')"
|
57
|
+
conditions << "last_played_utc > '#{@config.since.utc}'" if @config.since
|
58
|
+
conditions << "last_played_utc < '#{@config.until.utc}'" if @config.until
|
59
|
+
|
60
|
+
sql = <<~SQL
|
61
|
+
SELECT
|
62
|
+
datetime (episode.ZLASTDATEPLAYED + 978307200,
|
63
|
+
"unixepoch") AS last_played_utc,
|
64
|
+
datetime (episode.ZPUBDATE + 978307200,
|
65
|
+
"unixepoch") AS published_at_utc,
|
66
|
+
episode.ZTITLE,
|
67
|
+
episode.ZITEMDESCRIPTION,
|
68
|
+
episode.ZSTORETRACKID,
|
69
|
+
episode.ZAUTHOR,
|
70
|
+
pod.ZAUTHOR AS podcast_ZAUTHOR,
|
71
|
+
episode.ZWEBPAGEURL,
|
72
|
+
episode.ZENCLOSUREURL,
|
73
|
+
pod.ZTITLE AS podcast_ZTITLE,
|
74
|
+
pod.ZITEMDESCRIPTION AS podcast_ZITEMDESCRIPTION,
|
75
|
+
pod.ZSTORECOLLECTIONID AS podcast_ZSTORECOLLECTIONID,
|
76
|
+
pod.ZSTORECLEANURL AS podcast_ZSTORECLEANURL,
|
77
|
+
pod.ZIMAGEURL AS podcast_ZIMAGEURL,
|
78
|
+
pod.ZCATEGORY AS podcast_ZCATEGORY,
|
79
|
+
pod.ZWEBPAGEURL AS podcast_ZWEBPAGEURL,
|
80
|
+
pod.ZFEEDURL AS podcast_ZFEEDURL
|
81
|
+
FROM
|
82
|
+
ZMTEPISODE AS episode
|
83
|
+
JOIN ZMTPODCAST AS pod ON pod.Z_PK = episode.ZPODCAST
|
84
|
+
SQL
|
85
|
+
|
86
|
+
sql += " WHERE #{conditions.join(" AND ")}" if conditions.any?
|
87
|
+
sql += " ORDER BY last_played_utc DESC"
|
88
|
+
sql += " LIMIT #{@config.limit}" if @config.limit
|
89
|
+
|
90
|
+
results = @db.execute(sql)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'chronicle/etl'
|
2
|
+
require 'reverse_markdown'
|
3
|
+
|
4
|
+
module Chronicle
|
5
|
+
module ApplePodcasts
|
6
|
+
class ListenTransformer < Chronicle::ETL::Transformer
|
7
|
+
register_connector do |r|
|
8
|
+
r.provider = 'apple-podcasts'
|
9
|
+
r.description = 'a history item'
|
10
|
+
r.identifier = 'listen'
|
11
|
+
end
|
12
|
+
|
13
|
+
def transform
|
14
|
+
@data = @extraction.data
|
15
|
+
build_listened
|
16
|
+
end
|
17
|
+
|
18
|
+
def id
|
19
|
+
@data[:ZSTORETRACKID]
|
20
|
+
end
|
21
|
+
|
22
|
+
def timestamp
|
23
|
+
Time.find_zone("UTC").parse(@data[:last_played_utc])
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def build_listened
|
29
|
+
record = ::Chronicle::ETL::Models::Activity.new({
|
30
|
+
verb: 'listened',
|
31
|
+
provider: 'apple-podcasts',
|
32
|
+
provider_id: id,
|
33
|
+
end_at: timestamp
|
34
|
+
})
|
35
|
+
record.dedupe_on << [:provider, :verb, :provider_id]
|
36
|
+
record.actor = build_actor
|
37
|
+
record.involved = build_episode
|
38
|
+
record
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_episode
|
42
|
+
record = ::Chronicle::ETL::Models::Entity.new({
|
43
|
+
title: @data[:ZTITLE],
|
44
|
+
represents: 'episode',
|
45
|
+
body: body_as_markdown(@data[:ZITEMDESCRIPTION]),
|
46
|
+
provider: 'apple-podcasts',
|
47
|
+
provider_id: id,
|
48
|
+
})
|
49
|
+
record.containers = [build_podcast]
|
50
|
+
record.involvements = [build_published]
|
51
|
+
record
|
52
|
+
end
|
53
|
+
|
54
|
+
def build_podcast
|
55
|
+
record = ::Chronicle::ETL::Models::Entity.new({
|
56
|
+
title: @data[:podcast_ZTITLE],
|
57
|
+
body: body_as_markdown(@data[:podcast_ZITEMDESCRIPTION]),
|
58
|
+
provider: 'apple-podcasts',
|
59
|
+
provider_id: @data[:podcast_ZSTORECOLLECTIONID],
|
60
|
+
provider_url: @data[:podcast_ZSTORECLEANURL],
|
61
|
+
})
|
62
|
+
record.dedupe_on << [:provider_url]
|
63
|
+
record.dedupe_on << [:provider, :provider_id, :represents]
|
64
|
+
record.attachments = ::Chronicle::ETL::Models::Attachment.new({
|
65
|
+
url_original: @data[:podcast_ZIMAGEURL]
|
66
|
+
})
|
67
|
+
record
|
68
|
+
end
|
69
|
+
|
70
|
+
def build_published
|
71
|
+
record = ::Chronicle::ETL::Models::Activity.new({
|
72
|
+
verb: 'published',
|
73
|
+
provider: 'apple-podcasts',
|
74
|
+
provider_id: id,
|
75
|
+
end_at: Time.find_zone("UTC").parse(@data[:published_at_utc])
|
76
|
+
})
|
77
|
+
record.dedupe_on << [:provider, :verb, :provider_id]
|
78
|
+
record.actor = build_creator
|
79
|
+
record
|
80
|
+
end
|
81
|
+
|
82
|
+
def build_creator
|
83
|
+
record = ::Chronicle::ETL::Models::Entity.new({
|
84
|
+
title: @data[:ZAUTHOR],
|
85
|
+
provider: 'apple-podcasts',
|
86
|
+
represents: 'artist'
|
87
|
+
})
|
88
|
+
record.dedupe_on << [:provider, :title, :represents]
|
89
|
+
record
|
90
|
+
end
|
91
|
+
|
92
|
+
def build_actor
|
93
|
+
record = ::Chronicle::ETL::Models::Entity.new({
|
94
|
+
represents: 'identity',
|
95
|
+
provider: 'icloud',
|
96
|
+
provider_id: @extraction.meta[:icloud_account][:dsid],
|
97
|
+
title: @extraction.meta[:icloud_account][:display_name],
|
98
|
+
slug: @extraction.meta[:icloud_account][:id]
|
99
|
+
})
|
100
|
+
record.dedupe_on << [:provider, :represents, :slug]
|
101
|
+
record
|
102
|
+
end
|
103
|
+
|
104
|
+
def body_as_markdown(body)
|
105
|
+
ReverseMarkdown.convert(body)&.strip
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chronicle-apple-podcasts
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Louis
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-09-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: chronicle-etl
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: reverse_markdown
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 13.0.6
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 13.0.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.9'
|
83
|
+
description: Apple Podcasts connectors
|
84
|
+
email:
|
85
|
+
- andrew@hyfen.net
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- CODE_OF_CONDUCT.md
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- chronicle-apple-podcasts.gemspec
|
99
|
+
- lib/chronicle/apple-podcasts.rb
|
100
|
+
- lib/chronicle/apple-podcasts/listen_extractor.rb
|
101
|
+
- lib/chronicle/apple-podcasts/listen_transformer.rb
|
102
|
+
- lib/chronicle/apple-podcasts/version.rb
|
103
|
+
homepage: https://github.com/chronicle-app/chronicle-apple-podcasts
|
104
|
+
licenses: []
|
105
|
+
metadata:
|
106
|
+
allowed_push_host: https://rubygems.org
|
107
|
+
homepage_uri: https://github.com/chronicle-app/chronicle-apple-podcasts
|
108
|
+
source_code_uri: https://github.com/chronicle-app/chronicle-apple-podcasts
|
109
|
+
changelog_uri: https://github.com/chronicle-app/chronicle-apple-podcasts
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubygems_version: 3.3.3
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Apple Podcasts importer for Chronicle
|
129
|
+
test_files: []
|