Compare commits

..

630 Commits

Author SHA1 Message Date
f2ac198831
Merge branch 'master' of gitlab.gnome.org:World/podcasts 2020-06-21 21:15:03 +01:00
Jordan Petridis
abd263f127 Merge branch 'wip/exalm/tnum' into 'master'
Tabular figures; model buttons for speed rate popover

See merge request World/podcasts!134
2020-06-21 18:27:08 +00:00
Alexander Mikhaylenko
9c2d4ac6a7
episode: Use tabular figures
Prevents jumping during downloads.
2020-06-21 21:17:00 +03:00
Alexander Mikhaylenko
4d950ac17e
player: Use tabular figures for duration 2020-06-21 21:17:00 +03:00
Alexander Mikhaylenko
5e688c104c
player_rate: Use tabular figures for speed rate menu
Since gtk::ModelButton allows to set markup, the menu entries can now use
tabular figures.

Make the labels untranslatable, as they are generic enough already, and
being translatable would make even less sense with markup.
2020-06-21 21:17:00 +03:00
Alexander Mikhaylenko
4ce0819c68
player: Use model buttons for rate popover
Also simplify the xml.
2020-06-21 21:16:58 +03:00
Jordan Petridis
f7d9d0555c
meson: keep track of changes in Cargo.toml and lockfile 2020-06-21 18:55:25 +03:00
Jordan Petridis
b754182e0d
cargo fmt 2020-06-21 18:38:29 +03:00
Jordan Petridis
7b3a607b5e
improve test.sh further
Before we were able to call the script with ninja directly,
we were trying to override some of the envvars to fix how/where
cargo artifacts where stored.

This is no longer an issue as ninja is making sure the proper
setup will be met. This is also makes it so that Builder
doesn't rebuild everything since $BUILDDIR was empty before
causing rebuilds of the whole world.
2020-06-21 18:30:48 +03:00
Jordan Petridis
0e47e9c07f
test.sh: run the build proccess multithreaded 2020-06-21 18:21:32 +03:00
Jordan Petridis
c140e5a163
downloader: remove unused dependency on error-chain 2020-06-21 18:12:23 +03:00
Jordan Petridis
0bc379bf42 Merge branch 'alatiera/spelling' into 'master'
Fix spelling of things

See merge request World/podcasts!143
2020-06-21 15:11:41 +00:00
Jordan Petridis
9f0a3a0d9f
Fix spelling of things 2020-06-21 18:10:53 +03:00
Jordan Petridis
355cf9a36c Merge branch 'alatiera/rever-futures-upgrade' into 'master'
Revert 096197cf81

See merge request World/podcasts!144
2020-06-21 15:06:57 +00:00
Jordan Petridis
d9792e99c1
Revert 096197cf81
It breaks the testsuite 'sometime' which is fairly annoying.
The whole testuite setup is crap though and likely needs to be
fixed first.

Will re-revert the changes once a new stable release of the app
is done.
2020-06-21 17:03:36 +03:00
Jordan Petridis
6cb7de7fb3 Merge branch 'more-clone' into 'master'
Use clone! macro in more cases

See merge request World/podcasts!141
2020-06-21 13:38:19 +00:00
Julian Hofer
cb0860cddf
Use clone! macro in more cases 2020-06-20 18:30:44 +03:00
Thibault Martin
6edeb59b16 Update French translation 2020-06-19 17:35:06 +00:00
Jordan Petridis
a245aa73d4 Merge branch 'window-cleanup' into 'master'
Cleanup windows.rs

See merge request World/podcasts!140
2020-06-19 12:00:10 +00:00
Julian Hofer
08be9bdb4e Fix broken window.connect_delete_event
It was never called with the original configuration
2020-06-19 09:51:35 +00:00
Julian Hofer
2ee2181211 Cleanup windows.rs
It shouldn't result in any functional changes, but some unnecessary
parts were removed and windows.rs is now tracked by meson
2020-06-19 09:51:35 +00:00
Jordan Petridis
59e1c7d6f4
cargo update deps 2020-06-19 12:05:03 +03:00
Jordan Petridis
c2aca6e3a0
Flatpak: use the 3.36 runtime
Nightly has moved into fd.o-sdk 20.08 base and the rust-sdk
extension for that base is in flux and I haven't had time to
deal with it yet.
2020-06-19 11:42:44 +03:00
5f39da9273
Added playback speed 1.75, 2.0, 2.25, 2.5, 2.75, 3.0 in player 2020-06-19 00:21:16 +01:00
e16d69737e
Added playback speed 1.75, 2.0, 2.25, 2.5, 2.75, 3.0 to UI 2020-06-19 00:20:41 +01:00
Tim Sabsch
e6e2af38d3 Update German translation 2020-05-17 13:58:11 +00:00
Dz Chen
975697728e Add Chinese (China) translation 2020-04-18 10:36:24 +00:00
Yuri Chornoivan
a2789c9dba Add Ukrainian translation 2020-04-06 16:50:41 +00:00
Jordan Petridis
096197cf81 Merge branch 'futures-upgrade' into 'master'
Upgrade to Futures 0.3

See merge request World/podcasts!139
2020-03-21 20:33:45 +00:00
Julian Hofer
f9d577f596 Convert more functions to "async fn" 2020-03-18 01:09:11 +00:00
Julian Hofer
429356a217 Use tokio main-macro 2020-03-18 01:09:11 +00:00
Julian Hofer
636e2aefde Add tokio features and remove lazy keyword 2020-03-18 01:09:11 +00:00
Julian Hofer
e830589e38 Remove unused imports 2020-03-18 01:09:11 +00:00
Julian Hofer
933ba62f39 Upgrade to Futures 0.3 2020-03-18 01:09:11 +00:00
Goran Vidović
93f7aa4457 Update Croatian translation 2020-03-15 14:53:33 +00:00
Milo Casagrande
3ef45c42fb Update Italian translation 2020-03-06 08:47:09 +00:00
Nathan Follens
071e5978aa Update Dutch translation 2020-02-26 13:31:59 +00:00
Kukuh Syafaat
fba5102705 Update Indonesian translation 2020-02-24 15:33:10 +00:00
Jiri Grönroos
138e308c32 Update Finnish translation 2020-02-23 11:44:49 +00:00
Emin Tufan Çetin
fa8f1a0c8e Update Turkish translation 2020-02-19 07:54:22 +00:00
Balázs Úr
7325c3b4d3 Update Hungarian translation 2020-02-17 22:32:08 +00:00
Jordan Petridis
3e5ddb2aff Merge branch 'switch-clone' into 'master'
Switch to glib::clone macro and fix some typos

See merge request World/podcasts!138
2020-02-17 11:43:19 +00:00
Julian Hofer
d1ebbde778
Switch to glib::clone macro and fix some typos 2020-02-17 13:11:44 +02:00
Anders Jonsson
8a042c5714 Update Swedish translation 2020-02-13 21:39:22 +00:00
Piotr Drąg
7a2c252bbc Update Polish translation 2020-02-09 11:20:36 +00:00
Jordan Petridis
7d212174a6 Merge branch 'synchronize-feed-updates' into 'master'
Synchronize feed updates

Closes #166

See merge request World/podcasts!133
2020-02-08 21:42:04 +00:00
Timofey
685b35cb23 Rename refresh to schedule_refresh 2020-02-08 15:47:27 +00:00
Timofey
1175a54266 Synchronize feed updates 2020-02-08 15:47:27 +00:00
Yuri Gomes
d38064e1c0 Update Brazilian Portuguese translation 2020-02-08 02:46:04 +00:00
Jordan Petridis
59a57a740f Merge branch 'alatiera/updates' into 'master'
Update gtk-rs

See merge request World/podcasts!137
2020-02-07 19:22:28 +00:00
Jordan Petridis
f319851753
Upgrade gtk-rs stack 2020-02-07 20:48:04 +02:00
Jordan Petridis
ce424977c0 cargo update 2020-02-07 18:20:19 +00:00
Jordan Petridis
62c6b0d4cb flatpak: stop setting custom RUSTFLAGS
Builder no longer makes use of them
2020-02-07 18:20:19 +00:00
Daniel Mustieles
7685570da9 Update Spanish translation 2020-02-07 12:20:57 +00:00
Jordan Petridis
ff0c488968 Merge branch 'Remove-warnings' into 'master'
Get rid of warnings

See merge request World/podcasts!136
2020-02-07 12:13:46 +00:00
Julian Hofer
ebc6c8df4d Directly import ClassStruct and InstanceStruct 2020-02-07 11:44:03 +00:00
Julian Hofer
06a2c3ab12 Get rid of clippy warnings 2020-02-07 11:44:03 +00:00
Jordan Petridis
e877da1825 Merge branch 'potfiles-200202' into 'master'
Update POTFILES.in 200202

See merge request World/podcasts!135
2020-02-07 11:33:18 +00:00
Piotr Drąg
0b744b1179 Update POTFILES.in 2020-02-02 13:47:51 +01:00
Jordan Petridis
1041f21724 Merge branch 'now-playing' into 'master'
Adaptive "Now Playing" toolbar

Closes #158

See merge request World/podcasts!131
2020-02-01 14:52:59 +00:00
James Westman
73012f7976 Adaptive "Now Playing" toolbar
The "Now Playing" toolbar now shrinks to fit on small screens. On all
screen sizes, clicking the toolbar reveals a HdyDialog with the same
controls.

Also fixes #158.
2020-02-01 14:01:37 +00:00
Jordan Petridis
a1b4cece7d flatpak: set RUSTFLAGS to none to workaround a cargo bug 2020-02-01 16:00:48 +02:00
Fabio Tomat
ac4cd50929 Update Friulian translation 2020-01-21 10:01:04 +00:00
Kukuh Syafaat
bb5b3846a6 Update Indonesian translation 2020-01-17 03:10:59 +00:00
Piotr Drąg
3a11fbcf18 Update Polish translation 2019-12-25 16:05:48 +00:00
Anders Jonsson
a8da740ada Update Swedish translation 2019-12-22 11:01:49 +00:00
Jordi Mas i Hernandez
082ec0f592 Update Catalan translation 2019-12-16 06:31:10 +00:00
Daniel Mustieles
d49cad0bc0 Update Spanish translation 2019-12-11 11:32:00 +00:00
Rafael Fontenelle
75d8676de5 Update Brazilian Portuguese translation 2019-12-09 13:24:11 +00:00
Jordan Petridis
8228bc8996 Merge branch 'fix-81' into 'master'
Improve show description UI

Closes #81

See merge request World/podcasts!129
2019-12-08 20:02:52 +00:00
James Westman
8081990895 Improve show description UI
Instead of being a scroll window inside a scroll window, the show
description now shows just the first paragraph by default, then displays
a "Read More" button if there is more to the description. Clicking the
button reveals the rest.

Currently, to keep the button from glitching when updating it from the
size-allocate signal, a GtkRevealer with a transition-duration of
1 millisecond is used. It's a hacky workaround but I'm not quite sure
how to do it better.

Fixes #81
2019-12-08 19:26:25 +00:00
Jordan Petridis
eb2d5419f9
CI: fix typo in a9ba3fcbab 2019-12-08 20:53:44 +02:00
Jordan Petridis
a9ba3fcbab
CI: Refactor to use the citemplate
https://gitlab.gnome.org/GNOME/Initiatives/wikis/DevOps-with-Flatpak
2019-12-08 20:45:01 +02:00
Jordan Petridis
bcd610e2e3
cargo fmt 2019-11-18 10:23:59 +02:00
Jordan Petridis
217362fe14 Merge branch 'add-entry-activate' into 'master'
headerbar: Add activate handler to add entry

See merge request World/podcasts!130
2019-10-29 09:47:39 +00:00
James Westman
0e0d860cd2 headerbar: Add activate handler to add entry
This way, pressing Enter after typing/pasting a URL adds the podcast
feed, instead of needing to press the button separately.
2019-10-28 11:57:51 -05:00
Jordan Petridis
a8246a96cd Merge branch 'fix-156' into 'master'
Fix extra window appearing for some podcasts

Closes #156

See merge request World/podcasts!128
2019-10-25 00:28:19 +00:00
James Westman
33d28d1e7b Fix extra window appearing for some podcasts
Fixes #156.
2019-10-24 23:51:20 +00:00
Jordan Petridis
377d7bdf47 Merge branch 'fix-80-c' into 'master'
headerbar: Use Handy widgets

See merge request World/podcasts!127
2019-10-24 21:20:15 +00:00
James Westman
f6eb3dd90e headerbar: Use Handy widgets 2019-10-24 15:46:46 -05:00
Jordan Petridis
f632a66d60 Merge branch 'wip/christopherdavis/release-0.4.7' into 'master'
Release version 0.4.7

See merge request World/podcasts!126
2019-10-23 18:23:20 +00:00
Christopher Davis
ea0bb607b6
Release version 0.4.7 2019-10-23 20:45:37 +03:00
Jordan Petridis
85e15b77d9
fix the test script so it works outside flatpak again 2019-10-23 20:02:23 +03:00
Jordan Petridis
95055dea1d
update cargo deps 2019-10-23 19:22:48 +03:00
Jordan Petridis
630804c5b5
meson: Bump the required version of deps in order to build 2019-10-23 18:40:38 +03:00
Jordan Petridis
6cce4183e9
Flatpak: disable handy introspection generation 2019-10-20 20:25:18 +03:00
Jordan Petridis
35bd0d625c
p-data: Update the user agent 2019-10-20 20:22:36 +03:00
Jordan Petridis
073d00b45b
Update cargo deps 2019-10-20 20:21:32 +03:00
Jordan Petridis
982cb13e7e
shows_view: remove reduntant import 2019-10-20 20:14:11 +03:00
Jordan Petridis
6d3d4c8339
meson: install nightly icon 2019-10-20 20:03:07 +03:00
Jordan Petridis
911e420c24
Flatpak: remove dri access
There was a time where an inline videoplayer was a possibility,
and this would be needed for the GL widget, but it ain't
happening.
2019-10-20 19:40:46 +03:00
Jordan Petridis
e69ff0325e
Flatpak: remove dconf permissions.
Yay 🎉🎉🎉
2019-10-20 19:38:15 +03:00
Jordan Petridis
7c1353a8aa
Flatpak: Add fallback-x11 socket
This makes it so the x11 socket is made available only when
there is no wayland socket available in the system.
2019-10-20 19:35:05 +03:00
Jordan Petridis
4ce9a172b8 Merge branch 'wip/sadiq/small-width' into 'master'
Let the window work on smaller screens

See merge request World/podcasts!122
2019-10-20 16:22:16 +00:00
Mohammed Sadiq
61a7b24084 headerbar: Use a smaller width for entry
So that it fits better on smaller screens
2019-10-19 15:26:29 +00:00
Mohammed Sadiq
8b2ca19f1a episode_widget: Allow reaching smaller widths
So that the window fits fine on smaller screens
2019-10-19 15:26:29 +00:00
Jordan Petridis
deafa8f4d3 Merge branch 'fix-142' into 'master'
Show app icon in PulseAudio settings

Closes #142

See merge request World/podcasts!125
2019-10-19 15:25:59 +00:00
James Westman
c739935335 Show app icon in PulseAudio settings
According to the docs, `gtk::Window::set_default_icon_name` should take care of
this, but it evidently isn't. So we'll use the environment variable method
instead.

Fixes #142
2019-10-19 01:26:46 -05:00
Asier Sarasua Garmendia
34e4a4f483 Add Basque translation 2019-10-18 08:00:51 +00:00
Jordan Petridis
85c485509c Merge branch 'update_mpris_permissions' into 'master'
Remove unnecessary MPRIS Flatpak permissions

See merge request World/podcasts!124
2019-10-10 13:08:12 +00:00
Felix Häcker
026145e0c7 Remove unnecessary MPRIS Flatpak permissions 2019-10-09 21:03:13 +02:00
Jordan Petridis
bb0cf5b547 Merge branch 'update-coc' into 'master'
Update the Code of Conduct to the official GNOME CoC

See merge request World/podcasts!123
2019-10-08 17:37:43 +00:00
Christopher Davis
d8acffa844 Update the Code of Conduct to the official GNOME CoC 2019-10-08 09:55:20 -07:00
Jordan Petridis
a1f1cddcbe Merge branch 'revert-d8496fe4' into 'master'
Revert "Flatpak: use the 3.32 runtime version"

See merge request World/podcasts!115
2019-10-04 12:28:24 +00:00
Christopher Davis
d19612bb3c README: use new nightly and rust-stable locations
freedeskop-sdk is at 19.08 now, and sdk.g.o -> nightly.g.o
2019-10-04 11:53:05 +00:00
Christopher Davis
30e81961e8 Revert "Flatpak: use the 3.32 runtime version"
This reverts commit d8496fe4c4
2019-10-04 11:53:05 +00:00
Jordan Petridis
a9873da802
cargo fmt 2019-10-04 14:52:19 +03:00
Jordan Petridis
6046e62f11
Flatpak: update libhandy version to 0.11 2019-10-04 14:52:19 +03:00
Jordan Petridis
eb032619a0 Merge branch 'fix-link-and-typo' into 'master'
Fix link and typo

See merge request World/podcasts!121
2019-09-29 16:02:43 +00:00
Julian Hofer
d98f0a20a8 Fix link and typo 2019-09-24 21:34:10 +02:00
Jordan Petridis
945b40249c
Do not hardcode deny(warnings) in the source code
When a new version of the compiler introduces a new warning
it makes your perfectly fine older release require manual
patching in order to build again.
2019-09-13 03:05:38 +03:00
Jordan Petridis
1192642811
update cargo deps 2019-09-13 02:55:10 +03:00
Jordan Petridis
70772a61a9
meson.build: stop checking for cargo vendor
Since rust 1.37 release its now part of cargo itself.
2019-09-13 01:24:25 +03:00
Sabri Ünal
66b3f031a5 Update Turkish translation 2019-09-09 06:49:59 +00:00
Jordan Petridis
56a9c115f8 Merge branch 'reset-playback-rate' into 'master'
player:	Playback rate is reset when episode is started

Closes #65

See merge request World/podcasts!116
2019-09-04 14:45:45 +00:00
Julian Hofer
bd10ed93af
player: Playback rate is reset when episode is started
When an episode	is started the "radio_normal"-button is
set to true.
Fixes #65
2019-09-04 17:10:45 +03:00
Jordan Petridis
c3351f01e4 Merge branch 'url-parsing' into 'master'
headerbar: Refactor 'add' styling after url parsing

See merge request World/podcasts!119
2019-09-04 14:04:50 +00:00
FeuRenard
1d13384f6c headerbar: Refactor 'add' styling after url parsing
The current code includes many duplications.

I extract a single parameterized style function
accompanied by two delegate functions.

https://gitlab.gnome.org/World/podcasts/issues/45
2019-09-03 22:11:24 +02:00
Jordan Petridis
598e225b00 Merge branch 'zbrown/subclass-gtkapp' into 'master'
Subclass GtkApp

See merge request World/podcasts!113
2019-09-02 21:35:43 +00:00
Jordan Petridis
d8090a8172
Upgrade some cargo deps 2019-09-02 23:55:56 +03:00
Zander Brown
f47413686c
Use a custom GtkApplication instead of GtkApplication direct 2019-09-02 23:55:56 +03:00
Zander Brown
c8a194cf32
Use gtk-rs 0.7.0 2019-09-02 23:55:56 +03:00
Jordan Petridis
f07ac1f322 Merge branch 'url-creds' into 'master'
Parse url login info into basic auth header

Closes #124

See merge request World/podcasts!120
2019-09-02 18:49:42 +00:00
Peter Rice
02561b614f Parse url login info into basic auth header 2019-09-01 08:11:23 -04:00
Anders Jonsson
6ca2d02c69 Update Swedish translation 2019-08-22 15:54:41 +00:00
Jordan Petridis
300e103fed Merge branch 'cargo-update' into 'master'
build: Update Cargo.lock

Closes #147

See merge request World/podcasts!118
2019-08-05 00:34:13 +00:00
Christopher Davis
a77c0e5f32 build: Update Cargo.lock
Fixes https://gitlab.gnome.org/World/podcasts/issues/147
2019-08-04 04:04:15 -07:00
Jordan Petridis
cf644d508d Merge branch '145-contributing-merge-request-process' into 'master'
Resolve "CONTRIBUTING - Merge Request Process"

Closes #145

See merge request World/podcasts!117
2019-07-29 15:49:46 +00:00
Zander
452be8a22f Switch make for meson/ninja 2019-07-27 20:00:11 +00:00
Jordan Petridis
1e816f65a5 Merge branch 'alatiera/ci-3-32' into 'master'
Flatpak: use the 3.32 runtime version

See merge request World/podcasts!114
2019-07-16 08:05:17 +00:00
Jordan Petridis
d8496fe4c4
Flatpak: use the 3.32 runtime version
Until somebody find time to fix the CI image to work
with the 19.08 fd.o base.
2019-07-16 10:34:23 +03:00
Kukuh Syafaat
ca10956014 Update Indonesian translation 2019-07-11 08:22:04 +00:00
Goran Vidović
3984b84b6c Update Croatian translation 2019-06-22 20:30:46 +00:00
Daniel Mustieles
493114e825 Update Spanish translation 2019-06-19 10:34:04 +00:00
Yuri Gomes
7856b6fd27 Update Brazilian Portuguese translation 2019-06-13 18:42:37 +00:00
Jordan Petridis
957b47680d Merge branch 'empty-url' into 'master'
headerbar: Don't show error when add input is empty

See merge request World/podcasts!108
2019-06-09 04:18:48 +00:00
FeuRenard
86f6a944ff
headerbar: Don't show error when add input is empty
When you add a feed url and clear the input after entering some
characters, then the error label is shown. The empty url check in the
code is broken, because it is performed on a version of the url which
is not the original input and instead a version modified in the code.

I store in a variable whether the original input url is empty.

part of #45
2019-06-09 06:17:22 +03:00
Jordan Petridis
2631173a0d Merge branch 'red-border' into 'master'
headerbar: Add ERROR style to Add entry

See merge request World/podcasts!109
2019-06-09 03:12:33 +00:00
FeuRenard
0dc1f810d2
headerbar: Add ERROR style to Add entry
When you enter an invalid or duplicate URL an error message is shown.
But GTK's error style is not applied to the entry.

This commit applies GTK's error style to the URL entry when appropriate.

part of #45
2019-06-09 05:48:02 +03:00
Jordan Petridis
0b8d19fbbe Merge branch 'replace-label' into 'master'
headerbar: Replace Add error label with icon

See merge request World/podcasts!110
2019-06-09 02:38:40 +00:00
FeuRenard
51bbe4193b
headerbar: Replace Add error label with icon
Validation errors of an entry should be displayed by an icon with a
tooltip explaining the reason.

For the situation when you add a podcast URL I remove the existing
error label and show the former label text as tooltip of an error icon
in the entry.
2019-06-09 05:29:53 +03:00
Jordan Petridis
d5945f6ac6 Merge branch 'patreon_rss_fix' into 'master'
p-data/utils/url_cleaner: Keep query pairs in URLs

Closes #139

See merge request World/podcasts!111
2019-06-09 01:54:56 +00:00
Liban Hannan
539f8824d1 p-data/utils/url_cleaner: Keep query pairs in URLs
Removing query pairs prevents some podcasts from downloading. Patreon
private feeds (perhaps others) use tokens in query pairs to
authenticate downloads.
2019-06-09 01:27:10 +00:00
Jordan Petridis
539efc3f7b Merge branch 'code-of-conduct' into 'master'
Add Code Of Conduct

See merge request World/podcasts!112
2019-06-07 23:37:16 +00:00
Christopher Davis
c0861ba796 Add Code Of Conduct
This adopts the Contributor Covenant as the Code of Conduct
for all project spaces.
2019-06-07 16:03:45 -07:00
Balázs Úr
52d308e5ae Update Hungarian translation 2019-06-03 20:27:55 +00:00
Jiri Grönroos
57f3afae97 Update Finnish translation 2019-06-01 17:21:14 +00:00
Ask Hjorth Larsen
80ff75debc Update Danish translation 2019-05-28 01:34:31 +00:00
Piotr Drąg
d3a3bd2784 Update Polish translation 2019-05-19 10:38:13 +00:00
Jordan Petridis
2dcccb804e Merge branch 'piotrdrag/unicode-typography' into 'master'
Use a Unicode apostrophe in a new translatable string

See merge request World/podcasts!107
2019-05-18 12:55:23 +00:00
Piotr Drąg
ed7ac04d64 Use a Unicode apostrophe in a new translatable string
See https://developer.gnome.org/hig/stable/typography.html
2019-05-18 13:29:37 +02:00
Rodrigo Lledó
baf4d2bde6 Update Spanish translation 2019-05-16 16:24:52 +00:00
Jordan Petridis
ff047c5823 Merge branch 'alatiera/checkmark' into 'master'
episode: add a checkmark symbol to further indicate played state

Closes #106 and #69

See merge request World/podcasts!106
2019-05-14 09:11:16 +00:00
Christopher Davis
6c701e0c41 build: Add missing source file
In the transition to tightening our meson integration this
file was left untracked by meson.
2019-05-14 08:28:23 +00:00
Jordan Petridis
28ea14f2e9 episode: add a checkmark symbol to further indicate played state
Using only a dim styleclass on the widget is too light and does
not work with the HighContrast theme.

Close #69 #106
2019-05-14 08:28:23 +00:00
Jordan Petridis
f00f9b104c Merge branch 'piotrdrag/potfiles-190511' into 'master'
Update POTFILES.in

See merge request World/podcasts!105
2019-05-13 21:45:42 +00:00
Piotr Drąg
78d91826b1 Update POTFILES.in 2019-05-11 13:00:18 +02:00
Jordan Petridis
a5be789745 Merge branch 'alatiera/nuke-preferences' into 'master'
app: remove preferences dialog

Closes #67

See merge request World/podcasts!104
2019-05-10 16:05:46 +00:00
Jordan Petridis
028e318bd3 app: remove preferences dialog
The dark theme option is broken with themes that don't ship a
dark variant.

The episode garbage collection doesn't seem useful being
configurable at all.

The gsettings are still there, this just removes the ui
dialog since nothing useful made it into it ever.

Also, less toggles the better.

http://www.islinuxaboutchoice.com/
2019-05-10 17:08:35 +02:00
Jordan Petridis
b2b0b0f2c8
update dependencies 2019-05-10 15:57:55 +02:00
Jordan Petridis
42e73cb7e9
use mpris-player from crates.io 2019-05-10 15:56:28 +02:00
Jordan Petridis
89c3733ce8 Merge branch 'fix-#114' into 'master'
utils: use generic image when a show has no cover

See merge request World/podcasts!103
2019-05-10 13:40:59 +00:00
ZephOne
4be473dcea utils: use generic image when a show has no cover
When an episode from a show that has a cover is played. Switching to an
episode of a show that has no cover does not load the generic image in the
player. utils::set_image_from_path implementation does not deal with
DownloadError::NoImageLocation

utils::set_image_from_path deals with DownloadError::NoImageLocation,
this generic is set in this case.

https://gitlab.gnome.org/World/podcasts/issues/114
2019-05-10 14:01:47 +01:00
Jordan Petridis
97bdc32cce Merge branch 'master' into 'master'
Update CONTRIBUTING.md

See merge request World/podcasts!99
2019-04-07 15:55:20 +00:00
Julian Hofer
d2da46854e Update CONTRIBUTING.md 2019-04-07 13:17:39 +02:00
Jordan Petridis
150d3622e4 Merge branch 'patch-1' into 'master'
Fix  small errors in CONTRIBUTING.md

See merge request World/podcasts!98
2019-04-06 21:23:05 +00:00
Julian Hofer
990ab29200 Update CONTRIBUTING.md 2019-04-06 20:55:16 +00:00
Jordan Petridis
80d3bc84b8
cargo fmt 2019-04-06 23:54:17 +03:00
Jordan Petridis
b31c79431e
Fix the tests for Rust 2018 for real this time 2019-04-06 22:58:03 +03:00
Jordan Petridis
73587ff47b
Fix tests for Rust2018 2019-04-06 22:22:03 +03:00
Jordan Petridis
53e9db2f42
scripts/test.sh: export the rust binaries iniside flatpak environments
This allows the script to be able to be run directly from GNOME Builder's
build terminals.
2019-04-06 22:22:02 +03:00
Jordan Petridis
b290441956
scripts/cargo: fix debug build check 2019-04-06 21:33:42 +03:00
Jordan Petridis
9d0d20afbd
update deps 2019-03-30 18:13:39 +02:00
Jordan Petridis
4a7d3d5fc2
Use 2018 edition for the crates 2019-03-30 17:49:29 +02:00
Jordan Petridis
32ecb05902
don't export private macro 2019-03-30 17:08:28 +02:00
Jordan Petridis
644ca7d0d0
widgets/episode: replace deprecated method 2019-03-30 16:59:15 +02:00
Jordan Petridis
7dc1b25ee7
don't error on warnings
Nice and all when you keep up with development,
but can cause random errors by the addition of new
errors to the compiler.
2019-03-30 16:34:55 +02:00
Goran Vidović
3f28b9abc4 Update Croatian translation 2019-03-27 15:20:05 +00:00
Jordan Petridis
cf36d91da4 Merge branch 'patch-1' into 'master'
Fix typo in README.md

See merge request World/podcasts!97
2019-03-25 09:23:30 +00:00
Torkel Rogstad
8c1465d3a2 Fix typo in README.md 2019-03-25 08:52:22 +00:00
Jordan Petridis
bed7a4d6be
CI: fix the app_id that I forgot in the last commit 2019-03-20 23:54:40 +02:00
Jordan Petridis
23a91cca16
CI: fix the flatpak manifest path 2019-03-20 23:23:00 +02:00
Jordan Petridis
82c99e2cfa
meson: remove outdated fixme 2019-03-20 23:17:34 +02:00
Jordan Petridis
7d745179d4
app: Use a dot to separate the .Devel suffix in the app-id 2019-03-20 23:15:20 +02:00
Jordan Petridis
78283e51f6
app: remove .present() workaround
This should no longer be needed now.
https://gitlab.gnome.org/GNOME/gtk/issues/1754
2019-03-20 23:06:44 +02:00
Jordan Petridis
5a9ff8e331 Merge branch 'piotrdrag/update-potfiles-190307' into 'master'
Update POTFILES.in

See merge request World/podcasts!95
2019-03-16 12:42:21 +00:00
Piotr Drąg
814ddaa532 Update POTFILES.in 2019-03-16 12:29:47 +00:00
Bruce Cowan
b927b5fac2 Add British English translation 2019-03-16 11:47:15 +00:00
Anders Jonsson
e9cf140177 Update Swedish translation 2019-03-13 22:01:05 +00:00
Jordan Petridis
9ee9de7911
Flatpak: use ☢ emoji instead of the Nightly prefix 2019-03-10 21:07:29 +02:00
Nathan Follens
53844aa0ff Add Dutch translation 2019-03-10 12:54:18 +00:00
Jordan Petridis
f527f743fc
build: Require libhandy 0.0.9
Else libhandy breaks tranlations
2019-03-10 13:18:36 +01:00
Rafael Fontenelle
5801736955 Update Brazilian Portuguese translation 2019-03-10 01:32:30 +00:00
Tim Sabsch
11afc4c37d Update German translation 2019-03-09 18:58:46 +00:00
Jordan Petridis
5f1427cabd Merge branch 'wip/christopherdavis/tighten-meson-integration' into 'master'
build: Tighten integration between cargo and meson

Closes #55

See merge request World/podcasts!94
2019-03-07 05:16:03 +00:00
Jordan Petridis
27008e0f18
Flatpak: add builddir: true to the manifests
GNOME Builder carries a reimplementation of flatpak-builder.
flatpak-builder assumes that builddir is true for meson, but
Builder does not since it also supports out-of-tre builds.

This helps indicated to Builder that builddir can indeed be used.
2019-03-07 07:04:24 +02:00
Christopher Davis
8898fd6e2f
build: use build_by_default in cargo-build target
build_always_stale is deprecated and build_by_default can be
used now that we don't have build.rs.

Requires that we list our sources.
2019-03-07 07:04:24 +02:00
Christopher Davis
96d4cd50d4
CI: create blank versions of configured files before lint
Required now that we have dynamically generated
sources.
2019-03-07 07:04:24 +02:00
Christopher Davis
7a77f31aa3
build: Place target in meson build dir
Instead of putting target/ and target_test/ in the source
directory, we can tell our cargo script to put both target
and our cargo-home in meson's build directory.

In addition, makes tests and builds use the same target
directory, significantly reducing the time it takes to run tests.
2019-03-07 07:04:23 +02:00
Christopher Davis
78f29e726e
build: use add_dist_script for vendoring
Our workaround for getting meson and cargo working together
included a separate 'release' target that replaced
'ninja dist' so that we could vendor dependencies.

Now we use meson's add_dist_script to vendor the
dependencies as part of 'ninja dist', so we no longer need
the 'release' target.
2019-03-07 07:04:23 +02:00
Christopher Davis
92e2006782
build: hook up tests with meson
Adds our cargo test to meson's testing system so that
`ninja test` runs it in addition to our resource validation tests.
2019-03-07 07:04:23 +02:00
Christopher Davis
5b2edc73ec build: Build resources with meson instead of build.rs
Allows us to get rid of build.rs, which was only used to
compile resources. static_resource.rs is now created by
meson, and the meson path is used for include_bytes!.

Closes https://gitlab.gnome.org/World/podcasts/issues/55
2019-03-07 04:35:31 +00:00
Christopher Davis
395e31ff85 build: Use config.rs instead of env! macro
Previously we were using the env! macro to determine
build-time variables like version, app ID, and locale dir.
Instead of relying on env vars, we can create a configuration
file with meson and import it.
2019-03-07 04:35:31 +00:00
Sabri Ünal
dd0d828794 Update Turkish translation 2019-03-06 10:46:39 +00:00
Jordan Petridis
15bb1a2335 Merge branch 'escape-opml-export' into 'master'
p-data: Escape titles in OPML exports

See merge request World/podcasts!93
2019-03-04 04:26:38 +00:00
Christopher Davis
0a7b7880da
opml: escape characters when exporting
OPML is XML after all and parsers yell at us when we don't
escape &amps.
2019-03-04 05:54:01 +02:00
Jordan Petridis
277f324cf0 cargo fmt 2019-03-03 17:47:11 +02:00
Jordan Petridis
e496d5bf36 cargo: build debug symbols for release builds as well 2019-03-03 17:46:33 +02:00
Jordan Petridis
0ed6c8979e Upgrade crossbeam-channel 2019-03-03 17:45:43 +02:00
Jordan Petridis
075dd1adeb cargo: change email metadata of the crates 2019-03-03 04:59:52 +02:00
Jordan Petridis
027faf1949 Change formatting of podcasts-gtk/Cargo.toml 2019-03-03 04:58:40 +02:00
Jordan Petridis
54e049874c html2text: Use upstream git repo 2019-03-03 04:54:42 +02:00
Jordan Petridis
c4c6ba9ea4
Update dependencies 2019-03-03 04:46:19 +02:00
Jordan Petridis
a77bf0b8fb
Update gtk-rs family of crates 2019-03-03 04:46:19 +02:00
Jordan Petridis
b9bad14df6
build: Update libhandy to 0.0.8 at least
Earlier versions of libhandy broke translations for all apps.
sadly we can't require 0.0.9 yet as it hasn't been released yet.

https://mail.gnome.org/archives/desktop-devel-list/2019-March/msg00000.html
2019-03-03 04:10:47 +02:00
Kukuh Syafaat
b1058933b8 Update Indonesian translation 2019-03-02 12:18:56 +00:00
Jiri Grönroos
32c7f6b29e Update Finnish translation 2019-03-02 08:51:28 +00:00
Milo Casagrande
137705450b Update Italian translation 2019-02-28 08:25:39 +00:00
Ask Hjorth Larsen
4dc6034de8 Add Danish translation 2019-02-24 17:46:33 +00:00
Daniel Mustieles
7fa18fe38f Update Spanish translation 2019-02-19 15:05:09 +00:00
Jordan Petridis
7e34347ed7 Merge branch 'mpris-fix' into 'master'
add missing mpris callbacks / fix #115

Closes #115

See merge request World/podcasts!92
2019-02-05 21:52:55 +00:00
Felix Häcker
68fa547b06 Implement MPRIS pause and play methods.
Till now we were only using the play_pause method and
was enough for most of the usecases, but looks like
some mpris clients only use the individual methods.

https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:PlayPause

Close #115
2019-02-05 20:47:56 +00:00
Balázs Úr
a113ed049d Update Hungarian translation 2019-02-05 20:45:43 +00:00
Piotr Drąg
2f8a6a91f8 Update Polish translation 2019-02-02 15:31:37 +00:00
Jordan Petridis
f75ed257f2 Merge branch 'piotrdrag/unicode-typography' into 'master'
Use Unicode ellipsis in a user-visible string

See merge request World/podcasts!91
2019-02-02 15:17:22 +00:00
Piotr Drąg
06091d1af4 Use Unicode ellipsis in a user-visible string
See https://developer.gnome.org/hig/stable/typography.html
2019-02-02 12:14:29 +01:00
Daniel Mustieles
fb4e550122 Update Spanish translation 2019-01-29 15:28:41 +00:00
Balázs Úr
a74301f479 Update Hungarian translation 2019-01-28 22:42:49 +00:00
Rafael Fontenelle
c49f417d00 Update Brazilian Portuguese translation 2019-01-28 21:22:53 +00:00
Jordan Petridis
a2bcd8aa30 Merge branch 'opml-export' into 'master'
Add support for exporting to opml format

See merge request World/podcasts!77
2019-01-27 04:48:26 +00:00
Christopher Davis
6c34686d8d
p-data: Implment support for exporting the shows to an OPML file
Close #41
2019-01-27 06:06:46 +02:00
Jordan Petridis
86ec6f43cb
scripts:test.sh: fail upon exit code, and print stuff 2019-01-27 06:01:35 +02:00
Jordan Petridis
e9c7a3b99e
Flatpak: Add a nightly manifest 2019-01-27 01:44:06 +02:00
Jordan Petridis
f0ac63cd96
CI: add color to the test output 2019-01-21 03:13:51 +02:00
Jordan Petridis
b1e8663ba9
cargo update 2019-01-21 03:13:51 +02:00
Jordan Petridis
2cb6bf2b98
p-gtk: Update the libhandy bindings 2019-01-21 03:13:51 +02:00
Jordan Petridis
b35c63d1c8
Flatpak: Update libhandy to 0.0.7 and pin the commit
Lets avoid rolling git repos breaking the CI
2019-01-21 03:13:50 +02:00
Jordan Petridis
96b929b313
Flatpak: move USE_PLAYBIN3 env var to a finish arg 2019-01-21 03:13:50 +02:00
Jiri Grönroos
d8cddfafa0 Update Finnish translation 2019-01-16 18:04:16 +00:00
Jordan Petridis
de7d12d2c8 Merge branch 'patch-2' into 'master'
appdata: Improve the appdata file per the specs

See merge request World/podcasts!90
2019-01-10 06:18:19 +00:00
Bilal Elmoussaoui
bc8d521853 appdata: Improve the appdata file per the specs
freedesktop specs:https://freedesktop.org/software/appstream/docs/chap-Quickstart.html
kudos documentation: https://gitlab.gnome.org/GNOME/gnome-software/blob/master/doc/kudos.md
2019-01-09 19:21:29 +00:00
Jordan Petridis
a6c2666c82 Merge branch 'patch-1' into 'master'
Meson: add tests to validate desktop & appdata files

See merge request World/podcasts!89
2019-01-09 19:00:56 +00:00
Bilal Elmoussaoui
32424e7938 Meson: add tests to validate desktop & appdata files 2019-01-09 18:24:11 +00:00
Jordan Petridis
ca4a3d64eb
meson: remove dependency on gstreamer-bad-video-1.0
This has been moved to gst-base now.
b9e15fddb1
2019-01-05 15:41:46 +02:00
Jordan Petridis
2257688c65
Use rustfmt from the stable rustup channel 2019-01-05 15:11:27 +02:00
Jordan Petridis
ea9ddc58c0
scripts/test.sh: Minor tweaks 2019-01-05 15:11:27 +02:00
Milo Casagrande
c47d375a58 Update Italian translation 2018-12-11 16:49:14 +00:00
Jordan Petridis
36f97a5300
Flatpak: minor cleanup 2018-12-09 20:40:41 +02:00
Jordan Petridis
4adc3fadaa
Flatpak: Set an env var so gstreamer uses playbin3 2018-12-09 20:39:17 +02:00
Jordan Petridis
d9c64e7f87
CI: move the rustfmt check before the build/test 2018-12-09 04:02:29 +02:00
Jordan Petridis
9f8ae75691
Remove depricated lints 2018-12-09 03:53:17 +02:00
Jordan Petridis
7e0b88ddbd Merge branch 'remove-custom-devel-class' into 'master'
style.css: Remove custom .devel style class

See merge request World/podcasts!87
2018-12-08 23:00:14 +00:00
Christopher Davis
ed62f2b1f2 style.css: Remove custom .devel style class
GTK includes it's own .devel style class, so we don't need to
override by creating our own.
2018-12-06 00:30:00 -05:00
Jordan Petridis
4e89cdaca1 Merge branch 'alatiera/cargo-check' into 'master'
Boring build system stuff

Closes #109

See merge request World/podcasts!86
2018-12-02 00:40:49 +00:00
Jordan Petridis
b72ba8c66a
podcasts-gtk: make it possible to compile with just cargo
This is not supported at all, and it still won't run with cargo
run, thankfully, you should use meson instead...

The only purpose of this commit is to make it possible for
cargo check, and by extension rls, to function and work
properly.

Part of #110
2018-12-02 02:10:09 +02:00
Jordan Petridis
fc9de568bd
meson: remove dead code 2018-12-02 02:03:34 +02:00
Jordan Petridis
fe5a542e08
meson: Declare dependencies
Close #109
2018-12-02 02:03:33 +02:00
Jordan Petridis
5d86693d98 Merge branch 'fix/error-format' into 'master'
Remap rustc output to show errors in GNOME Builder sidebar

See merge request World/podcasts!81
2018-12-01 12:18:41 +00:00
Ricardo Silva Veloso
4caefdb3fd
Remap rustc output to show errors in GNOME Builder sidebar 2018-12-01 13:36:26 +02:00
Jordan Petridis
2f843a4d40 Merge branch 'patch-1' into 'master'
Support vendored builds / distribution packaging

See merge request World/podcasts!85
2018-11-30 11:25:59 +00:00
Michael Aaron Murphy
0175609f02 Support vendored builds / distribution packaging 2018-11-30 11:25:59 +00:00
Jordan Petridis
f9f0dad203
cargo fmt 2018-11-29 14:36:06 +02:00
Jordan Petridis
fdb064ffc8
Update dependancies 2018-11-29 11:57:27 +02:00
Jordan Petridis
e98231c327 Merge branch 'cleanups' into 'master'
Cleanups

See merge request World/podcasts!84
2018-11-18 13:27:59 +00:00
Jordan Petridis
0888da2197 Upgrade dependencies 2018-11-18 12:59:02 +00:00
Jordan Petridis
2d231ad989 Update dependancies 2018-11-18 12:59:01 +00:00
Jordan Petridis
19e0b7e565 Further preparations for Rusto 2018 edition 2018-11-18 12:59:01 +00:00
Jordan Petridis
fd4128c364 Prepare for Rust 2018 edition 2018-11-18 12:59:01 +00:00
Jordan Petridis
98f105fda0 Player: Use a wrapper struct to write methods on &self
Previously, methods that required the Player to be ref counted,
were using static methods with s: &Rc<Self> as the first argument.

Now the wrapper type auto-derefs to the inner struct and you can
declare methods on just &self.
2018-11-18 12:59:01 +00:00
Kukuh Syafaat
201f2e23c7 Update Indonesian translation 2018-11-15 16:42:30 +00:00
Jordan Petridis
32b257ec30
cargo fmt 2018-11-13 15:29:20 +02:00
Jordan Petridis
53bceb89cd
Merge branch 'Ophirr33/podcasts-master'
See !82 for more.
2018-11-07 01:34:06 +02:00
Jordan Petridis
04770a1e8f
Merge branch 'ZanderBrown/hammond-wip/zbrown/jump-to-start'
See !83 for more.
2018-11-07 00:49:47 +02:00
Zander Brown
fbda4c76f0
player.rs: Improve the fast-forward handling
Previously if you hit fast-forward but the offset remaining was
let that the amount you wanted to seek, it would do nothing.
Now it resets the stream and seekbar to the start.

Eventually this will just move on to the next episode in the
Queue once that's implemented.
2018-11-07 00:46:40 +02:00
Zander Brown
85387a0a9b
Fix for https://gitlab.gnome.org/World/podcasts/issues/105
Wow that was a quick one
2018-11-05 17:55:46 +00:00
Jordan Petridis
5ac4f6dcf9
Mpris: Actually raise the window
This fixes a bug where can_raise was never registered on dbus,
but it also works around a wayland issue with the .present()
method.

https://gitlab.gnome.org/GNOME/gtk/issues/624
2018-11-04 21:05:09 +02:00
Jordan Petridis
6671f8c6fe
podcasts-gtk: Add per file license annotations 2018-11-04 19:35:35 +02:00
Jordan Petridis
5b77bb4649
podcasts-downloader: Add per file license annotations 2018-11-04 19:35:35 +02:00
Jordan Petridis
8f6329d71d
podcasts-data: Add per file license annotations 2018-11-04 19:35:35 +02:00
Ty Coghlan
5d71ac584c gnome-podcasts: DRY out From impls in errors
From impls for errors generally just take some error type and map
it into a variant of some podcast error enum. This removes the duplicate
impls by using a pattern macro to make the impls from the type of the
enum, the given error type, and the desired enum variant.
2018-11-03 01:13:35 -04:00
Daniel Mustieles
534c627300 Update Spanish translation 2018-11-02 12:26:05 +00:00
Jordan Petridis
1a1e5ecd3f
Update App icon. Close #102 2018-10-30 20:34:47 +02:00
Alexandre Franke
3e555c64d9 Add French translation 2018-10-29 12:54:45 +00:00
Dušan Kazik
8d6b5f7105 Update Slovak translation 2018-10-28 21:00:26 +00:00
Dušan Kazik
4692be663e Add Slovak translation 2018-10-28 15:31:17 +00:00
gogo
5ae0fb1b0e Update Croatian translation 2018-10-24 19:46:48 +00:00
Jordan Petridis
990d830f24
cargo fmt 2018-10-23 13:23:01 +03:00
Jordan Petridis
c6aa90db3e Merge branch 'master' into 'master'
fix typo

See merge request World/podcasts!79
2018-10-23 09:56:48 +00:00
lightning1141
c1eed45194
fix typo 2018-10-23 10:52:33 +08:00
Anders Jonsson
31ee668311 Update Swedish translation 2018-10-16 19:53:58 +00:00
Jordan Petridis
9f60121609
Flatpak: Cleanup libhandy headers 2018-10-09 12:58:40 +03:00
Piotr Drąg
a61d04f445 Update Polish translation 2018-10-07 14:57:18 +00:00
Marek Černocký
8ba8ada253 Update Czech translation 2018-10-07 14:48:24 +00:00
Jordan Petridis
885b796f85
New release 0.4.6 2018-10-07 10:18:15 +03:00
Jordan Petridis
fa47806c93
Update Changelog 2018-10-07 10:18:14 +03:00
Emin Tufan Çetin
5997666bad Update Turkish translation 2018-10-06 15:53:09 +00:00
Jordan Petridis
40186ce155
Update dependancies 2018-10-06 11:29:52 +03:00
Jordan Petridis
9cfdb35224
AboutDialog: Update contributors list 2018-10-06 11:09:07 +03:00
Jordan Petridis
64860c4624
Update screenshots 2018-10-06 10:32:46 +03:00
Jordan Petridis
32bd2a89a3
Stacks: Check if there episodes insteads of shows
If you added a Feed where a Show exists but it had no episodes
entries, the stack would end up in a populated state, but the
HomeView would be blank without widgets.

This changes it so the stack state depends upon the episodes
table being populated instead of the show. The downside
is that if your only feed is one without episodes you can
no longer navigate and interact with it.
2018-10-06 10:22:24 +03:00
Rafael Fontenelle
1e6eca307b Update Brazilian Portuguese translation 2018-10-05 14:19:31 +00:00
Jordan Petridis
fc23fcd7c1 Merge branch 'patch-1' into 'master'
Fix typo

See merge request World/podcasts!78
2018-10-05 11:47:38 +00:00
Alexandre Franke
ab52825c71 Fix typo 2018-10-05 10:04:44 +00:00
Jordan Petridis
28def30510 Update CHANGELOG.md 2018-10-05 09:25:56 +00:00
Florian Heiser
8f4d017180 Update German translation 2018-10-05 04:41:29 +00:00
Jordan Petridis
df302ad517
Pipeline: Do not terminate the stream upon errors
Stream::for_each terminated the stream upon the first error. This
was causing feeds to not update if any one returned a non-200ish
result. To work around this, we create a succesfull result for
every entry regardless at the end.

While we are at it, aslo switch from FuturesOrdered stream
to FuturesUnordered. There is no reason to use Ordered, this was
a typo initially.
2018-10-04 18:48:11 +03:00
Jordan Petridis
357d99ac7c
Remove temporary file 2018-10-04 17:18:07 +03:00
Jordan Petridis
7e3fecc44a
Source: Refactor the clear_etags method api 2018-10-04 16:46:04 +03:00
Jordan Petridis
e0b3dd9795
Mpris: Implement the raise method 2018-10-04 16:46:04 +03:00
Jordan Petridis
6a52a2bc46 Merge branch 'alatiera/player-timeout' into 'master'
Player: Tweak the smart rewind behavior

See merge request World/podcasts!76
2018-10-04 07:55:21 +00:00
Jordan Petridis
cd2b087006 Player: Check the episode id before triggering a smart rewind 2018-10-04 05:27:11 +00:00
Jordan Petridis
ef2940142c PlayerInfo: Store the id of the current playing episode 2018-10-04 05:27:11 +00:00
Jordan Petridis
e13b8b8827 Player: Tweak the smart rewind behavior
Check if time interval passed since the last pause, and only
rewind if the delta to indicates that the user had
switched their focus.

In other words, avoid rewinding if the track was just paused and
resumed.
2018-10-04 05:27:11 +00:00
Jordan Petridis
43fce2e89a
CI: Use generic bundle name
When run an environment CI_COMMIT_SHA is not resolved and results
into a 404 url in the review apps
2018-10-04 08:25:50 +03:00
Jordan Petridis
7856f0d602 Merge branch 'mpris' into 'master'
Implement MPRIS, Close #68

See merge request World/podcasts!74
2018-10-04 03:26:03 +00:00
Jordan Petridis
bcc6ab50e2 PlayerInfo: Minor refactor of the mpris cover 2018-10-04 02:19:56 +00:00
Jordan Petridis
23aa8c05ab Player: Do not duplicate the mpris instance 2018-10-04 02:19:56 +00:00
Jordan Petridis
986d898217 Player: Remove an unwrap 2018-10-04 02:19:56 +00:00
Jordan Petridis
654c0e5e56 Player: Remove Initialization test
When constucting Player in the Sandbox, it tries to use X-11
for dbus-autolaunch which is disabled in the flatpak environment.

It fails with the following error:
D-Bus error: Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead (org.freedesktop.DBus.Error.NotSupported)
2018-10-04 02:19:56 +00:00
Felix Häcker
fed0edbf16 Player: use crates.io package of mpris 2018-10-04 02:19:56 +00:00
Felix Häcker
ede91da6f8 cargo fmt 2018-10-04 02:19:56 +00:00
Felix Häcker
1f18d4291f Player: implement fast forward / rewind for mpris 2018-10-04 02:19:56 +00:00
Felix Häcker
d066e8939d Player: implement mpris play/pause callbacks 2018-10-04 02:19:56 +00:00
Felix Häcker
e4c3435d34 Player: add basic mpris support 2018-10-04 02:19:56 +00:00
Jordan Petridis
fc80b180bc
CI: Allow rusftm check to fail for now
Stuff broke with rustfmt nightly 0.99.5 and I haven't found time
to look into it yet.
2018-10-04 05:17:21 +03:00
Jordan Petridis
0d9dca99e9
Meson: capture the output of the custom target
Previously meson would withhold the stdout output, and only
print it once the job was finished. This was a bit problematic
with the current way we wire cargo into meson, cause you have
no output of whats going on till then causing a degraded UX.

With this change output is printed directly to stdout and
behaves as expected.

https://mesonbuild.com/Reference-manual.html#custom_target
2018-10-04 04:58:57 +03:00
Kukuh Syafaat
2ff921cc1a Update Indonesian translation 2018-10-02 13:34:32 +00:00
Piotr Drąg
e0e66fa6af Update Polish translation 2018-09-30 17:17:46 +00:00
Marek Černocký
110e29ec5a Update Czech translation 2018-09-29 19:31:22 +00:00
Jordan Petridis
a2b6d622de
Update dependancies 2018-09-29 13:58:45 +03:00
Jordan Petridis
0887789f5e
Pipeline: Complete the move to Tokio Runtime 2018-09-29 13:35:45 +03:00
Jordan Petridis
3c4574f2ec
scripts/test.sh: Don't keep build-dirs 2018-09-29 12:07:21 +03:00
Jordan Petridis
62029f6164
Pipeline: Minor refactor
Use the proper Stream API to return a future to run on the
executor. Previously I was using a workaround to convert the
Stream into a future and run it to completion in the Executor,
since I was not aware of a better API.
2018-09-29 12:03:00 +03:00
Jordan Petridis
ba986847d6
Merge branch 'wip/hyper-12.X-update'
See merge request World/podcasts!75
2018-09-29 11:42:53 +03:00
Jordan Petridis
fded78ce6f
Flatpak: Switch to the master runtime again 2018-09-29 11:18:39 +03:00
Jordan Petridis
8d44649a1e
Update dependancies 2018-09-29 09:54:06 +03:00
Jordan Petridis
f4d0c51dc2
podcasts-downloader: Upgrade reqwests to 0.9 2018-09-29 09:54:06 +03:00
Jordan Petridis
ba60db9977
podcasts-gtk: Upgrade reqwests to 0.9 2018-09-29 09:54:06 +03:00
Jordan Petridis
0a5a7a684d
podcasts-downloader: Remove direct dependancy on hyper 2018-09-29 09:54:06 +03:00
Christopher Davis
7181c46ed5
podcasts-data: Upgrade hyper to 12.X
This also allows us to bump hyper_tls and native_tls, bringing
support for openssl 1.1.
2018-09-29 09:54:06 +03:00
Jordan Petridis
afa7e69347 Update CHANGELOG.md 2018-09-28 23:56:51 +00:00
Jordan Petridis
5050dda4d2
Hamburger: Update to reflect the latest HIG changes
Preferences are now grouped with the application actions.
The About label was renamed to "About Podcasts".

https://mail.gnome.org/archives/desktop-devel-list/2018-September/msg00015.html
2018-09-29 02:43:19 +03:00
Florian Heiser
9ea1e16ac8 Update German translation 2018-09-27 15:32:33 +00:00
Rodrigo Lledó
922f44f605 Update Spanish translation 2018-09-24 10:17:44 +00:00
Adolfo Jayme Barrientos
6ea3fc918b Add Catalan translation 2018-09-24 07:52:18 +00:00
Kukuh Syafaat
0c201533f0 Update Indonesian translation 2018-09-22 08:20:38 +00:00
Jordan Petridis
b1e99b96c4
CI: Switch the flatpak image 2018-09-22 04:53:08 +03:00
Jordan Petridis
de1c8485ae
Fix rustc warnings
New warnings were introduced with rustc 1.29.0

podcasts-data/src/lib.rs: this one can be removed once diesel is
upgraded.
https://github.com/diesel-rs/diesel/issues/1785#issuecomment-422577018

podcasts-gtk/src/i18n.rs: This is just a deprication warning
2018-09-22 04:47:24 +03:00
Jordan Petridis
565d1d0388
Build against the 3.28 runtime for now
Freedesktop 18.08.11 dropped openssl 1.0 which caused hyper to
no longer build. Reverting to the old runtime till hyper is
upgraded. See #84 for more.
2018-09-22 04:47:24 +03:00
gogo
a15fea1d65 Update Croatian translation 2018-09-19 12:24:57 +00:00
Jordan Petridis
da3cf6ca27
Flatpak: Pass configuration to libhandy
Do not build what we don't need.
2018-09-18 12:43:51 +03:00
Emin Tufan Çetin
d8dbbc6832 Update Turkish translation 2018-09-15 20:11:23 +00:00
Marek Černocký
3563a964ef Add Czech translation 2018-09-15 05:15:51 +00:00
Jordan Petridis
208f0c248d
Update rest of the dependancies 2018-09-13 15:47:40 +03:00
Jordan Petridis
c0e034726a
Upgrade gtk-rs and friends
Upgrade gtk-rs, and everything dependings on it like gst-rs and
libhandy bindigns
2018-09-13 15:47:40 +03:00
Rafael Fontenelle
d676a7071a Update Brazilian Portuguese translation 2018-09-11 00:12:22 +00:00
Rūdolfs Mazurs
a681b2c944 Add Latvian translation 2018-09-10 17:34:18 +00:00
Mario Blättermann
c53701d56b Update German translation 2018-09-10 07:50:51 +00:00
Anders Jonsson
a8c1f2eccc Update Swedish translation 2018-09-09 17:39:22 +00:00
Piotr Drąg
cf7ee44efc Update Polish translation 2018-09-09 17:00:14 +00:00
Jordan Petridis
2e4a9eaaeb
Update dependancies 2018-09-08 21:41:39 +03:00
Jordan Petridis
569a2b5694
Update CHANGELOG.md 2018-09-08 20:17:48 +03:00
Jordan Petridis
baa84773a5
EpisodeWidget: Change the "cancel" action icon 2018-09-08 20:17:47 +03:00
Jordan Petridis
a39e642b5a
EpisodeWidget: Change cacnel button to an icon
This also reworks the button_box to be just a GtkBox instead.
I couldn't get ButtonBox to behave the way I wanted.

Fixes #89
2018-09-08 20:17:47 +03:00
Jordan Petridis
e42cb49cbe
EpisodeWidget: Hide total_size if request fails
This moves the rest of the methods of Progress struct to the downloader
trait and cancels the Progress if the request does nto succed.

Close #90
2018-09-08 20:17:47 +03:00
Jordan Petridis
b40c12efbd
Pipeline: Avoid spamming stderr when not needed
This commit add a new DataError Variant for feeds that return 304.
Its expected behaviror and the current API of Source::into_feed
is kinda limiting the return type to make it easier to handle.

Up till now 304 was returning an Error to early return. Ideally
Source::into_feed will return a Multi variant Result Enum.

example:

enum FeedResult {
    Ok(Success(feed)),
    Ok(NotModified),
    Err(err),
}

Hopefully in a refactor in the near Future™

Till then we will just have to match and ignore
DataError::FeedNotModified.
2018-09-08 20:17:47 +03:00
Jordan Petridis
3c5ddad133
DataError: Improve the FeedRedirect variant 2018-09-08 20:17:47 +03:00
Jordan Petridis
1ca4cb40dd
Pipeline: clear the imports of fututres 2018-09-08 20:17:47 +03:00
Jordan Petridis
678b0b9db1
BaseView: Set minimum width to 360
While the HomeView and ShowView can't yet scale that low,
the ShowWidget could get to about 270p already which is not
desirable.

This commit sets the minimum width of all the Views to 360p,
which is our mobile target size.
2018-09-08 20:17:47 +03:00
Jordan Petridis
e633fa41ac
Pipeline: Minor formatting improvment 2018-09-08 20:17:47 +03:00
Jordan Petridis
dac303e33b
Pipeline: Use a custom tokio threadpool
This reverts commit e64883eecb
and 40dd2d6923

Seems like core.run() returns once its done even if there
are still tasks in the Runtime underneath. A way to solve that
would be to call the shutdown_on_idle method.

We need ownership of the threadpool in order to invoke
`shutdown_on_idle` method but core.runtime only returns a
referrence so we need to create our own threadpool.
2018-09-08 20:17:46 +03:00
Jordan Petridis
fd77d672c5
Update Changelog 2018-09-08 20:17:46 +03:00
Jordan Petridis
a991d9f512
DataError: Remove unused error variant
This was added due to Threadpool::spawn returning errors, but its
no longer used.
2018-09-08 20:17:46 +03:00
Jordan Petridis
674b3b54dc
Pipeline: reuse the prexisting runtime executor
Instead of creating our own threadpool, we should reuse the executor
of the tokio::runtime::Runtime that backs the tokio::reactor::Core.
2018-09-08 20:17:46 +03:00
Jordan Petridis
09948845ca
Pipeline: Remove use of clone! macro 2018-09-08 20:17:46 +03:00
Jordan Petridis
0b8a0695f7
Pipeline: Use tokio threadpool to index feeds 2018-09-08 20:17:46 +03:00
Jordan Petridis
a7c95d5718
Pipeline: Remove dependancy on rayon_futures
This requires a RUSTFLAG to be set before hand for rayon to build.
This brakes a lot of tools like rls and clippy by default and
require special configs for itnegration.

Additionally, rayon_futures is still 0.1 and not much work seem
to have gone into it. Ideally it should be replased with the tokio
runtime/threadpool.
2018-09-08 20:17:46 +03:00
Jordan Petridis
8a05597e52
Feed: Remove another unnecessary wrapper 2018-09-08 20:17:45 +03:00
Jordan Petridis
145d45f800
Feed: Remove unnecessary function wrapper 2018-09-08 20:17:45 +03:00
gogo
0476b67b2f Add Croatian translation 2018-09-06 18:29:14 +00:00
Balázs Meskó
2751a828e0 Add Hungarian translation 2018-09-05 22:09:46 +00:00
Jordan Petridis
a3f5dbfe07
CI: cache only the sources from flatpak-builder
Gitlab CI zips its cache target which causes it to strip
xattributes. This breaks ostree and the cache artifacts.

Cache only the sources instead.
2018-09-05 00:47:45 +03:00
Fabio Tomat
60e09c0dd7 Add Friulian translation 2018-09-04 18:18:27 +00:00
Milo Casagrande
a23297e56a Add Italian translation 2018-09-03 13:42:38 +00:00
Jordan Petridis
b05163632b
test.sh: build with devel profile as well 2018-09-03 11:17:03 +03:00
Daniel Mustieles
f59be31ded Update Spanish translation 2018-09-03 06:32:14 +00:00
Anders Jonsson
2e527250de Add Swedish translation 2018-09-02 23:35:41 +00:00
Piotr Drąg
91dd378f5d Update Polish translation 2018-09-01 17:49:54 +00:00
Jiri Grönroos
f5b3d033a3 Update Finnish translation 2018-09-01 16:59:07 +00:00
Rafael Fontenelle
db98e3b722 Add Brazilian Portuguese translation 2018-09-01 13:29:55 +00:00
Mario Blättermann
586cf16fdc Update German translation 2018-08-31 19:05:31 +00:00
Jordan Petridis
064d877205
Appdata: add release notes 2018-08-31 21:00:18 +03:00
Jordan Petridis
fbf8cc87c9 Version bump 2018-08-31 14:14:17 +00:00
Jordan Petridis
bebabf84a0 Update Changelog 2018-08-31 14:11:29 +00:00
Seong-ho Cho
36f169635a Add Korean translation 2018-08-31 00:56:44 +00:00
Jordan Petridis
3f509f44a1
Update dependancies. 2018-08-30 20:45:53 +03:00
Jordan Petridis
9bc8a8ac2b
Release: include meson_options.txt 2018-08-30 20:21:11 +03:00
Jordan Petridis
abfe98283b
EpisodeWidget: Allow size labels to elipsize 2018-08-30 20:21:10 +03:00
Kukuh Syafaat
ded0224f51 Add Indonesian translation 2018-08-30 10:43:20 +00:00
Fran Dieguez
0060a634d2 Add Galician translation 2018-08-30 08:45:45 +00:00
Jordan Petridis
d34005e04f Merge branch 'chng-readme' into 'master'
README.md: Change instructions for translators

See merge request World/podcasts!68
2018-08-29 08:43:48 +00:00
Rafael Fontenelle
c734bd48b5 README.md: Change instructions for translators
Change translation instructions to steer the translator to the translation platform D-L, to follow the proper workflow of the language teams.
2018-08-29 07:29:38 +00:00
Jordan Petridis
174c814541 Merge branch 'alatiera/cover_load_perf' into 'master'
Cover loading performance improvments

See merge request World/podcasts!67
2018-08-29 07:29:17 +00:00
Jordan Petridis
993b6e9d0a Utils: only queue a single cover download
Before we were inserting the id of the cover into the registry
from a rayon thread. But rayon will only execute N threads at the
same time and let the rest into a queue. This would casue mutliple
jobs being queued since the cover id was not inserted in the
registry until the downloading had started.

This fixes said behavior by having the main thread block and write
in the id in the registry.
2018-08-28 21:15:52 +00:00
Jordan Petridis
273c9f7b99 Utils: Change the priority of the cover caches
Since loadign a pixbuf from the pre-rendered cache is the most
common operation and it does not affect the behavior we can
first check that and then if the cover is midway downloading.

This avoids a mutex lock for the most common path.
2018-08-28 21:15:52 +00:00
Jordan Petridis
822deb2867 Utils: do not block the cover_dl registry
Accidently after f21398357b when a download would start,
it would lock the cover_dl_registry hashmap till it had finished.

Since the registry.read() happens on the main thread this would
cause the UI to block until the download was and the mutex guard
from the download thread dropped.
2018-08-28 21:15:52 +00:00
Merge Bot
132e2afce0 Merge branch 'wip/piotrdrag/update-potfiles-180828' into 'master'
Update POTFILES.in

See merge request World/podcasts!66
2018-08-28 20:54:09 +00:00
Piotr Drąg
2a888f0bce Update POTFILES.in 2018-08-28 19:44:34 +02:00
Jordan Petridis
f8202a7add Merge branch 'alatiera/meson-stuff' into 'master'
Parallel installation and meson cleanups

See merge request World/podcasts!64
2018-08-28 16:13:31 +00:00
Jordan Petridis
87e8d0b775
Fix the test-suite 2018-08-28 17:50:57 +03:00
Jordan Petridis
569c00ff5f
Allow for parallel development instance
This adds a configuration option in meson, if set it changes the
application ID allowing for stable and development version to be
run at the same time.
2018-08-28 17:22:13 +03:00
Jordan Petridis
15457e1db4
App/Build: Use env! macro to fetch the variable
env! is resolved at compile time which means we don't need to read
and set LOCALDI from build.rs
2018-08-28 17:22:13 +03:00
Jordan Petridis
0ae1eb9578
build: Translate desktop and appdata files 2018-08-28 17:22:13 +03:00
Jordan Petridis
aa1d0161d3
cargo fmt 2018-08-27 21:08:29 +03:00
Emin Tufan Çetin
a2d8b88337 Update Turkish translation 2018-08-27 08:43:08 +00:00
Jordan Petridis
a1b4306954
Merge remote-tracking branch 'zander/master'
See !65 for more.
2018-08-27 10:53:07 +03:00
Zander Brown
88e07031a6 Workaround for FileChooserNative oddness 2018-08-27 07:52:09 +00:00
Piotr Drąg
cb4daa1ba1 Update Polish translation 2018-08-26 16:31:44 +00:00
Jordan Petridis
46cfa79e89
Update .gitignore 2018-08-26 12:39:26 +03:00
Jordan Petridis
a480f47cea
cargo fmt 2018-08-26 12:38:36 +03:00
Jordan Petridis
4ef789e7b9
Meson: Fix build_always deprication warning
build_always has been replaced by build_always_stale and
build_by_default is assumed now.

https://mesonbuild.com/Reference-manual.html#custom_target
2018-08-26 12:38:36 +03:00
Mario Blättermann
05d6d8399d Update German translation 2018-08-25 21:27:45 +00:00
Jordan Petridis
8bc81d6b5e
Update pot files 2018-08-22 08:29:30 +03:00
Jordan Petridis
6c5cb8f07d
AboutDialog: Translate website label 2018-08-22 08:29:12 +03:00
Jordan Petridis
70e79e50d6
Change the website to point to the wiki page
Thanks a lot to @svito for creating the page!
2018-08-21 20:11:38 +03:00
Jordan Petridis
d2c6c6cc4d
Update pot files 2018-08-20 14:09:34 +03:00
Jordan Petridis
ba5e22bd21
README: Add flathub banner 2018-08-20 13:55:15 +03:00
Jordan Petridis
9d0bfdea44
README: Update build instructions 2018-08-20 13:41:19 +03:00
Jordan Petridis
92ae681517
Add gtk tests
Currently we only test the GtkBuilder files.
Also I can't find a way to get gtk to uninitialize and reinitialize
in a different thread.

Close #56
2018-08-20 13:14:41 +03:00
Jordan Petridis
3afa8c4441
Flatpak: avoid the git redirect 2018-08-20 05:27:31 +03:00
Emin Tufan Çetin
547fdef9c4 Update Turkish translation 2018-08-19 14:54:27 +00:00
Merge Bot
152c250300 Merge branch 'alatiera/content_states' into 'master'
content states

Closes #71

See merge request World/podcasts!63
2018-08-19 11:56:06 +00:00
Jordan Petridis
04161284a7
Headerbar: Make the switcher insensitive if empty
If there are no shows/episodes to display, there isn't any point
to being able to hit the switcher.
2018-08-19 14:31:27 +03:00
Jordan Petridis
14d4818867
App: Disable refresh action while in empty state
Close #71
2018-08-19 14:25:41 +03:00
Jordan Petridis
9f42e91088
Refactor content state with Application actions
Instead of each view/widget determening if its populated on its own,
make add Application Actions and apply the state globally.
2018-08-19 13:44:11 +03:00
Jordan Petridis
79ac3b9700
Update dependancies 2018-08-18 18:33:26 +03:00
Jordan Petridis
7a3178896b
Remove criterion
Haven't been able to use it effectivly with futures. Maybe will
revisit it again at a later time. For now it just adds extra
build time.
2018-08-18 18:02:28 +03:00
Jordan Petridis
ee95512321
Update .gitignore 2018-08-18 17:37:06 +03:00
Jordan Petridis
55519b1855
scripts/test.sh: avoid conlfict with vanila cargo
I am not sure why, but cargo does not like it if flatpak-builder
and gnome Builder try to use the same target/ directory, even
though the environment should be almost identical.

The only difference is that Builder uses flatpak build instead of
flatpak-builder as far as I can see.
2018-08-18 17:34:49 +03:00
Jordan Petridis
89b99614a0
Refactor the tests to use ? operator
As of ructc 1.27 #[test] can return errors. This improves a great
deal the ergonomics.
2018-08-18 17:02:31 +03:00
Jordan Petridis
7bbd9a1a4f
Update the test script 2018-08-18 16:25:43 +03:00
Tobias Bernard
0dfb48593e App icon: orange -> red 2018-08-17 12:49:44 +02:00
Jordan Petridis
3abe0803d6
Source: Remove reduntant save() call
Source::clear_etags does a save already, so it's not needed to call
it twice.
2018-08-17 09:57:49 +03:00
Merge Bot
1e0a919dc7 Merge branch 'alatiera/source-redirects-85' into 'master'
Source: Improve http redirections handling

Closes #85

See merge request World/podcasts!62
2018-08-17 04:33:12 +00:00
Jordan Petridis
489e8aa4b3
Source: Improve http redirections handling
We should follow all redirects, and update the Source uri for
301, 302 and 308 codes.

Closes #85
2018-08-17 07:09:12 +03:00
Merge Bot
5058f2f8d8 Merge branch 'alatiera/source-etags-71' into 'master'
Source: Only save Etag headers upon succesful requests

Closes #64

See merge request World/podcasts!61
2018-08-17 02:56:04 +00:00
Jordan Petridis
49aff9f22e
Source: Only save Etag headers upon succesful requests
Additionally clear the Etags if the returned code is not 200 or 304.
Just to be extra safe. This is not as clean as it should, as this is
a temporary workaround until the API is reworked.

Related to #64
2018-08-17 05:36:34 +03:00
Jordan Petridis
775d4accf7
Flatpak: switch to master branch of the runtime 2018-08-16 08:30:46 +03:00
Jordan Petridis
703a1baf8b
CI: Move repo export right before the bundle generation 2018-08-16 08:30:42 +03:00
Jordan Petridis
51fdad2ae2
CI: Use variables instread of hardcoding things 2018-08-16 08:30:38 +03:00
Jordan Petridis
86545e5f99
CI: Add git commit sha in the bundle name 2018-08-16 08:30:34 +03:00
Jordan Petridis
5a0413b3e4
CI: Remove --libdir=/app/libdir from meson config
This is not needed anymore I think.
2018-08-16 08:30:29 +03:00
Jordan Petridis
a0ff2b8ae4
CI: set CARGO_HOME before cargo test
This is set in the scripts/cargo.sh during building, but since we
invoke cargo test manually we need to also set it here.
2018-08-16 08:30:24 +03:00
Mario Blättermann
6b6c390cb8 Add German translation 2018-08-15 17:19:11 +00:00
Jordan Petridis
cd937c4844
utils: Refactor refresh_feed
Move channel creation inside the thread.
Drop the Result return type as its not needed anymore.
2018-08-14 15:24:25 +03:00
Jordan Petridis
cc1a5783fd
App: Do not update the db if its empty
If the source table is empty skipp the database refresh.
2018-08-14 15:19:31 +03:00
Jordan Petridis
5631caad36
Gitlab: Fix the bug issue template
Forgot to change this when it was copied from nautilus.
2018-08-14 14:23:35 +03:00
Jordan Petridis
d0144fb0d0
CI: Do not spin up review enviorment for tags 2018-08-14 14:11:16 +03:00
Jordan Petridis
5d1870c1cf
CI: Lower flatpak bundle lifespan 2018-08-14 14:03:06 +03:00
Jordan Petridis
fb87460bc7
CI: Clear unused stuff
No point on keeping them around since libhandy was added as a dep.
No distro packages libhandy currently, so only the flatpak will be
buildable for the foreseeable future.
2018-08-14 14:01:14 +03:00
Jordan Petridis
cb122cbc61
ShowWidget: Change description wrap mode 2018-08-14 13:59:42 +03:00
Jordan Petridis
efc4e299ac
CI: Add env viariable for the tests 2018-08-14 13:58:09 +03:00
Jordan Petridis
848caa275b
CI: re-enable the test-suite 2018-08-14 13:41:12 +03:00
Jordan Petridis
03754c56c6
Fix the test-suite 2018-08-14 13:40:37 +03:00
Jordan Petridis
471f6ff93b
Source: Remove ignore_etags option
This is never used anywhere else apart from the testsuite. Instead
of ignoring etags we should instead not save them if the feed does
not return 200 or 304. See #64.
2018-08-14 13:40:33 +03:00
Jordan Petridis
c53ad56a6d
Remove TODOs and FIXMEs
They are either no longer relevant or just forgotten
2018-08-14 13:40:28 +03:00
Tobias Bernard
646439d86a Merge branch 'alatiera/move-update-notif' into 'master'
Move the update indication into an In-app Notification

Closes #72

See merge request World/podcasts!60
2018-08-14 10:11:28 +00:00
Jordan Petridis
ae7f65e938
InAppNotif: Switch the timer to milliseconds
This allows for more responsive updates. The implementation still
sucks though. Ideally we would pass a receiver in the callback
and have an even lower timeout_add.
2018-08-14 07:58:29 +03:00
Jordan Petridis
b2d71a037c
Headerbar: Remove the update indicator 2018-08-14 07:52:41 +03:00
Jordan Petridis
019ec8972f
InAppNotif: Add a spinner 2018-08-14 07:41:58 +03:00
Jordan Petridis
e25e411ebe
App: Use the new updater notif
Initial wiring of the new InAppNotif update indicator. This still
misses a spinner, and its overall teribly implemented!
2018-08-14 07:28:10 +03:00
Jordan Petridis
911dcbac9f
InAppNotif: Pass revealer to the callback
Let the callback handle if/when the visibility of the notification
2018-08-14 06:22:02 +03:00
Jordan Petridis
25195c972c
InAppNotif: add a method to show/hide the close button
This will enable us to create persistant notifications.
2018-08-14 05:36:17 +03:00
Jordan Petridis
304c92f733
InAppNotification: Allow to set a custom timer
This allows for a custom timer to be set before the
callback will be run. Currently all the callbacks only
run once and then retunr glib::Continue(false) but this
would allow for setting a low timer and have a callback
that would determine if it needs to be run again, Continue(true),
in a relative responsive way.
2018-08-13 09:13:39 +03:00
Jordan Petridis
336b9a126e
InAppNotif: Fix ref cycles 2018-08-13 09:13:10 +03:00
Jordan Petridis
01efbf5c79
InAppNotif: Refactor to infer the undo state
If we use an Optional instead of passing empty closures, we
can infer if the Undo button needs to be shown.
2018-08-13 08:31:52 +03:00
Merge Bot, Bors Wannabe
866fa6a758 Merge branch 'fix-ref-cycles' into 'master'
Fix more refference cycles

See merge request World/podcasts!59
2018-08-13 04:28:49 +00:00
Jordan Petridis
b8bb5e6d82
ShowMenu: Fix a reference cycle 2018-08-13 06:48:39 +03:00
Jordan Petridis
cc4b3cce55
Player: Fix a refference cycle 2018-08-13 06:35:19 +03:00
Jordan Petridis
5699562133 App: Fix more refference cycles 2018-08-13 03:34:37 +00:00
Piotr Drąg
dae064d2bb Update Polish translation 2018-08-13 01:45:08 +00:00
Jordan Petridis
d54e15cd15
EmptyView: Fix a typo 2018-08-13 04:05:28 +03:00
Jordan Petridis
dbdf56d494
App: Do not placeholder strings as translatable
Also add license metadata, and update the targeted gtk3 version
2018-08-13 02:34:53 +03:00
Jordan Petridis
b07cd5515a
Refactor Empty states 2018-08-13 02:05:09 +03:00
Emin Tufan Çetin
73929f2d25 Add Turkish translation 2018-08-12 11:05:29 +00:00
Jordan Petridis
acaa06749e
ShowWidget: Keep the Frame from filling available the space 2018-08-12 02:41:22 +03:00
Piotr Drąg
1bd6efc0c1 Add Polish translation 2018-08-11 16:43:15 +00:00
Jiri Grönroos
936960269d Add Finnish translation 2018-08-11 14:10:14 +00:00
Jordan Petridis
5780df20ad Merge branch 'wip/piotrdrag/gschema-gettext' into 'master'
gschema: Add gettext-domain

See merge request World/podcasts!56
2018-08-11 09:24:05 +00:00
Piotr Drąg
14e5f33f2a gschema: Add gettext-domain
Without it DConf Editor won’t show localized schemas.
2018-08-11 01:35:28 +02:00
Jordan Petridis
7aa86bcec4 Merge branch 'wip/piotrdrag/update-potfiles-180810' into 'master'
Update POTFILES.in

See merge request World/podcasts!54
2018-08-10 23:20:38 +00:00
Piotr Drąg
c77a1e85a4 Update POTFILES.in 2018-08-10 20:58:18 +00:00
Jordan Petridis
093b8cb6df Merge branch 'wip/piotrdrag/desktop-comments' into 'master'
desktop: Add translator comments

See merge request World/podcasts!55
2018-08-10 20:56:30 +00:00
Piotr Drąg
6460198e1d desktop: Add translator comments 2018-08-10 22:03:04 +02:00
Jordan Petridis
662dc3fa85
HomeView: Properly align the frames
d5ea0d5a17 broke alignment
between the listboxes and the frame labels.
2018-08-10 22:49:54 +03:00
Merge Bot, Bors Wannabe
5a4bce2816 Merge branch 'alatiera/libhandy' into 'master'
Refactor views and use HdyColumn for views with that display `EpisodeWidget`s

Closes #70

See merge request World/podcasts!48
2018-08-10 18:35:58 +00:00
Jordan Petridis
d5ea0d5a17
HoveView and ShowWiget: Add margins around the listboxes 2018-08-10 21:14:49 +03:00
Jordan Petridis
9e525727fd
InAppNotif: allow the text to elipsize
Also fixe deprications in the glae file, add license
2018-08-10 20:49:59 +03:00
Jordan Petridis
95b6995649
Headerbar: Elipsisize update label 2018-08-10 15:54:12 +03:00
Jordan Petridis
745064c5ce
AddPopOver: Remove deprication warning 2018-08-10 15:47:20 +03:00
Jordan Petridis
223a3b46bf
Headerbar: Elipsisize show title 2018-08-10 15:46:28 +03:00
Jordan Petridis
fee3e320ab
ShowWidget: Move the listbox back to the glade file 2018-08-10 15:43:19 +03:00
Jordan Petridis
e068cff37b
ShowWidget: Increase the description char limit 2018-08-10 14:44:02 +03:00
Jordan Petridis
28f08ed196
HomeView: handle vadjustment with BaseView
Instead of using lazy_static to save the adjustment,
pass it to the widget upon creation. If its the first instance
created, pass None instead.
2018-08-10 14:43:58 +03:00
Jordan Petridis
056d971000
HomeView: make base view field publick
There is no point to re-export BaseView's methods.
2018-08-10 14:42:57 +03:00
Jordan Petridis
aa5195e5a9
ShowsView: handle vadjustment with BaseView
Instead of using lazy_static to save the adjustment,
pass it to the widget upon creation. If its the first instance
created, pass None instead.
2018-08-10 14:42:52 +03:00
Jordan Petridis
85aaaf80ac
ShowsView: make base view field publick
There is no point to re-export BaseView's methods.
2018-08-10 13:54:19 +03:00
Jordan Petridis
5d467a22d0
ShowWidget: make base view field publick
There is no point to re-export BaseView's methods.
2018-08-10 13:54:14 +03:00
Jordan Petridis
bcc1cfb67b
ShowWidget: handle vadjustment with BaseView
Instead of using lazy_static to save the adjustment,
pass it to the widget upon creation. If previous it doesn't
exists pass None instead.
2018-08-10 13:54:07 +03:00
Jordan Petridis
70a24fba69
BaseView: implement a set_adjustments method
Ment to replace the individual set_vadjustment of widgets.
Also remove unused method from ShowWiget.
2018-08-10 13:53:25 +03:00
Jordan Petridis
c3121bef84
ShowsChild: Remove the need for a .ui file
Its a simple enough widget that can be written by hand
and does not need a .ui builder file.
2018-08-10 13:53:12 +03:00
Jordan Petridis
8c25be7d05
BaseView: Set scroll policy 2018-08-10 13:53:00 +03:00
Jordan Petridis
7463e9d42c
ShowsView: Use BaseView abstraction 2018-08-10 13:52:56 +03:00
Jordan Petridis
e4dd9f5bb3
HomeView: Use libhandy::Column for the main widget 2018-08-10 13:52:52 +03:00
Jordan Petridis
4e59d648ef
HomeView: Use the new BaseView abstraction 2018-08-10 13:52:48 +03:00
Jordan Petridis
7538e76537
Gtk: Abstract a BaseView Widget
Currently it just re-exports its children with getters,
but the idea is that it will also be able to handle
the saving the state of its height adjustment later.
2018-08-10 13:52:44 +03:00
Jordan Petridis
20ddc54edc
ShowWidget: Put the whole thing inside HdyColumn 2018-08-10 13:52:35 +03:00
Jordan Petridis
ac75205933
ShowWidget: Initial prototype w/ libhandy::Column 2018-08-10 13:47:59 +03:00
Jordan Petridis
17b58b159a
ShowWidget: Remove unsused menu from the glade file 2018-08-10 13:47:12 +03:00
Jordan Petridis
191cf445ef
ShowWidget: Do not hardcode the episode listbox in the glade file 2018-08-10 13:47:07 +03:00
Jordan Petridis
65a0c08cb3
Flatpak: fix previous commit that broke it
I broke both the manifest and the CI in 4da68ff89c
2018-08-10 13:44:48 +03:00
Jordan Petridis
4da68ff89c
Flatpak: switch to using the 3.28 runtime again
Gtk was upgraded yesterday to 3.24. This causes a warning about
widgets being drawn without prior allocation. I am not sure yet if
the bug is in the bindings or if gtk's ABI broke.
2018-08-10 12:11:08 +03:00
Jordan Petridis
a7da4525fd
Flatpak: Grant access to thee dri
A warning suggested it, I assume it was coming from Gtk.
2018-08-10 12:08:54 +03:00
Jordan Petridis
92dfbce45a Merge branch 'wip/piotrdrag/review-strings' into 'master'
podcasts-gtk: Review ALL the strings!

See merge request World/podcasts!53
2018-08-10 05:58:11 +00:00
Piotr Drąg
bfdd6b5f7c podcasts-gtk: Review ALL the strings! 2018-08-10 05:23:15 +00:00
Jordan Petridis
a8a8c09b90 Merge branch 'wip/piotrdrag/appdata-fix' into 'master'
appdata: Remove duplicate tag

See merge request World/podcasts!49
2018-08-10 05:21:47 +00:00
Piotr Drąg
4bd13b81cf
appdata: Remove duplicate tag 2018-08-10 08:00:32 +03:00
Jordan Petridis
5a07600664 Merge branch 'wip/piotrdrag/unmark-placeholders' into 'master'
episode_widget: Unmark placeholder strings from translation

See merge request World/podcasts!50
2018-08-10 04:59:39 +00:00
Piotr Drąg
f2bc4b21cb episode_widget: Unmark placeholder strings from translation 2018-08-10 04:37:32 +00:00
Jordan Petridis
778975fbde Merge branch 'wip/piotrdrag/unmark-copyright' into 'master'
aboutdialog: Unmark copyright string from translation

See merge request World/podcasts!51
2018-08-10 04:36:54 +00:00
Piotr Drąg
57f920624f aboutdialog: Unmark copyright string from translation 2018-08-10 04:05:31 +00:00
Jordan Petridis
3d87940da9 Merge branch 'wip/piotrdrag/translate-appname' into 'master'
aboutdialog: Translate the app name

See merge request World/podcasts!52
2018-08-10 04:04:04 +00:00
Piotr Drąg
c33d0836eb
app: Translate the app name 2018-08-10 06:34:02 +03:00
Jordan Petridis
a01cf21f2c
Flatpak: use master runtime of GNOME sdk 2018-08-09 10:25:02 +03:00
Jordan Petridis
10fc1d4a2a
Gitlab: Add merge request template 2018-08-09 10:23:34 +03:00
Jordan Petridis
4fa973007d
App: Make sure to quit on delete event.
Since 9a76c6428a I've noticed
the applciation does not quit properly, and then it's unable
to be launched again till it's killed manually.

This patch is an attept to correct/workaroud that by calling
explcitly gio::ApplicationExt::quit().
2018-08-06 01:01:21 +03:00
Jordan Petridis
c27f5ec02e Merge branch 'readme_improvements' into 'master'
Fix some typos in README.md

See merge request World/podcasts!47
2018-08-05 08:57:26 +00:00
Matthew
5d6cf3d17d
Fix some typos in README.md 2018-08-05 11:32:42 +03:00
Jordan Petridis
f6c7731377
Fix Rust 2018 edition warnings 2018-08-05 11:24:20 +03:00
Jordan Petridis
bcd739da76 Merge branch 'i18n' into 'master'
Translation support and initial spanish translation

See merge request World/podcasts!46
2018-08-02 14:54:41 +00:00
Daniel García Moreno
bea4915317 Translation support and initial spanish translation
Added translation support based on the Fractal i18n. To do this I've
added the gettext-rs crate dep. I'm using my own fork because the
official gettext-rs release includes the gettext source files and that
increase the distribution package a lot and for distribution with
flatkap we don't need to build gettext, the lib is in the gnome sdk. So
this gettext-rs fork is the same, but removing the not needed gettext
source files.

The i18n.rs file adds some useful functions to translate strings. These
functions wraps the original gettext and adds more functionality, to be
able to translate compound strings, something that's not supported by
the gettext function.

The 'i18n' function works like the gettext, receives a plain string
without params.

The 'i18n_f' function receives a string with "{}" and a ref to an array
of &str with substitutions for the "{}" in the original string. The
substitution is done by order.

The 'i18n_k' function receives a string with "{named}" and a ref to an
array of (&str, &str) with substitutions for the "{named}" in the
original string. The substitution is done by name, where the first &str
in the tuple is the name and the second the string to use for the
replace.

This mod also include ni18n variants of the three functions for plural
and singular translations.

I've also created the spanish translation.

See #61

https://gitlab.gnome.org/World/podcasts/issues/61
2018-08-02 15:24:19 +02:00
Jordan Petridis
f695ba4605
cargo fmt 2018-08-02 07:10:22 +03:00
Jordan Petridis
24983ba3af Readme.md: Improve wording and formatting 2018-08-02 02:44:29 +00:00
Jordan Petridis
0a2a3b3377
Remove unused permission. 2018-08-01 02:14:27 +03:00
Jordan Petridis
d8d7193cbc
README: Add flahub instructions. 2018-07-31 11:40:05 +03:00
Jordan Petridis
042c9eed9c
Appdata: Remove 'lang=' metadata tag from the description.
This seems to confuse the flathub store website.
2018-07-31 11:22:15 +03:00
Jordan Petridis
b0c94dd998
Appdata: Add OARS Rating
This help with content age rating. Usefull for store
clients like gnome-software.

https://hughsie.github.io/oars/
2018-07-31 10:58:04 +03:00
Jordan Petridis
4c8cc9e823
Version bump. 2018-07-31 00:31:44 +03:00
Jordan Petridis
132c9bbdff
ShowModel: Remove dead unused methods. 2018-07-30 23:23:58 +03:00
Jordan Petridis
cc0caff8d0
EpisodeModels: Remove unused methods. 2018-07-30 23:20:10 +03:00
Jordan Petridis
3496df24f8
App: Fix refference cycles in actions. 2018-07-28 19:52:37 +03:00
Jordan Petridis
e4e35e4c57
App: Replace action macro with a generic fuction. 2018-07-28 19:52:27 +03:00
Jordan Petridis
838320785e
Replace SendCell with fragile.
SendCell is depricated now and its advised to use the Fragile
crate instead.

https://github.com/sdroege/send-cell/issues/5
2018-07-28 19:46:01 +03:00
Jordan Petridis
91bea85519
Update dependancies. 2018-07-28 19:15:26 +03:00
Jordan Petridis
88ea081661
Version bump. 2018-07-28 00:12:08 +03:00
Jordan Petridis
39c0a0dba5
Fix cargo vendor config. 2018-07-28 00:08:48 +03:00
Jordan Petridis
9d64d3e30d
AppStream: captions were too short. 2018-07-27 21:45:33 +03:00
Jordan Petridis
39ff238716
Version bump. 2018-07-27 20:21:28 +03:00
Jordan Petridis
7c96152f3f
Gtk: Change the minimum requests of the views. 2018-07-27 19:46:18 +03:00
Jordan Petridis
a2440c19e1
Appdata: Fix screenshots metadata. 2018-07-27 00:42:54 +03:00
Jordan Petridis
24dff5ce85
Update the release script. 2018-07-27 00:27:42 +03:00
Tobias Bernard
1ca8e15d19 Update org.gnome.Podcasts.appdata.xml 2018-07-26 21:15:10 +00:00
Tobias Bernard
f77a8f09bb Update podcasts.doap 2018-07-26 21:13:04 +00:00
Jordan Petridis
48a7c8140f
Update screenshots. 2018-07-26 23:53:08 +03:00
Jordan Petridis
b03ff46767
Version bump. 2018-07-26 08:33:45 +03:00
Jordan Petridis
e66e6364c3 Update Changelog 2018-07-26 05:30:46 +00:00
Jordan Petridis
89ef7ac4f6
Rename the .doap file. 2018-07-26 07:56:00 +03:00
Jordan Petridis
27e74ee064
Update the appdata summary. 2018-07-26 07:53:29 +03:00
Jordan Petridis
83c44aa12c
Replace links again 2018-07-26 07:41:43 +03:00
Jordan Petridis
17da62d53b
App: Fix some refference cycles. 2018-07-26 07:19:43 +03:00
Jordan Petridis
d43fc268f4
App: Only execute .show_all() at startup.
If you would had an instance running and activate the app again
the UI would break visually in all kind of ways.
2018-07-26 07:07:56 +03:00
Jordan Petridis
5a7ab9795d
Headerbar: rename menu-button to hamburger. 2018-07-25 04:57:00 +03:00
Jordan Petridis
cfcdba5aea
Headerbar: Avoid code duplication and ref cycles. 2018-07-25 04:38:24 +03:00
Jordan Petridis
aaca6a6704
Prefs: Use weak refs to avoid refference cycle. 2018-07-25 04:25:40 +03:00
Jordan Petridis
5f7c822deb
gtk: Rename left over home_view .ui files. 2018-07-25 03:55:42 +03:00
Jordan Petridis
53be091a31
Replace links 2018-07-25 03:26:41 +03:00
Jordan Petridis
04c68ba013
Initial massive renaming. 2018-07-25 03:26:35 +03:00
Jordan Petridis
518ea9c8b5
EmptyView: Improve wording of strings and Center stuff. 2018-07-24 15:07:13 +03:00
Jordan Petridis
6bb2142f35
Prefs: Fix typo. 2018-07-24 15:06:56 +03:00
Jordan Petridis
6aa931c866
Update deps. 2018-07-24 09:28:25 +03:00
Jordan Petridis
67ab54f820
Headerbar: Try to improve the add button behavior. 2018-07-24 09:05:55 +03:00
Jordan Petridis
cc9fc80328
Remove some unwraps. 2018-07-24 08:04:31 +03:00
Jordan Petridis
3e8a8a6b85
Hamburger: connect the MenuModel during initialization. 2018-07-24 07:36:41 +03:00
Jordan Petridis
70a2d0e5f3
EpisodeWidget: Improve total_size label wording. 2018-07-24 07:29:52 +03:00
Jordan Petridis
09e8d7e1da
AboutDialog: Update authors list. 2018-07-24 07:25:57 +03:00
Jordan Petridis
3c3d6c1e7f
EmptyView: Style improvments.
Suggest using the OPML import action from the hamburger menu.

Minor rework of the over style.
2018-07-24 07:23:00 +03:00
Jordan Petridis
0dcc95cd34
Hamburger: Hide unimplemented menu actions. 2018-07-24 06:47:43 +03:00
Jordan Petridis
edae1b0480
Add Application Icons.
Huge thanks to Tobias and Sam for these!
2018-07-24 06:27:34 +03:00
Jordan Petridis
5fb2cb7e76 Merge branch 'prefs' into 'master'
Prefrences dialog

See merge request World/hammond!34
2018-07-24 02:57:29 +00:00
Jordan Petridis
403bb71c5d
Prefs: Bikeshed on the naming of things. 2018-07-24 05:05:52 +03:00
Jordan Petridis
9e23b16ae7
App: Remove no longer needed allow(unused). 2018-07-24 05:05:43 +03:00
Jordan Petridis
60a93a2433
App: Use the gio::prelude 2018-07-24 05:05:39 +03:00
Zander Brown
14dfafcb7c
Sort out accelerators 2018-07-24 05:05:34 +03:00
Zander Brown
dcc06cf8c6
Initial dialog 2018-07-24 05:05:30 +03:00
Zander Brown
54c084040c
Minor rustfmt update 2018-07-24 05:05:26 +03:00
Zander Brown
a9c38f5a03
Remove the update section 2018-07-24 05:05:22 +03:00
Zander Brown
bce80cca0b
Fix some style issues 2018-07-24 05:05:19 +03:00
Zander Brown
f56fac6877
Bind GtkSettings dark property to GSettings
Now you can switch between dark and light on the fly
2018-07-24 05:05:15 +03:00
Zander Brown
ef2286dca4
Bind refresh/cleanup rate 2018-07-24 05:05:11 +03:00
Zander Brown
a4a012368e
Bind switches to keys 2018-07-24 05:05:08 +03:00
Zander Brown
1b623ef346
Initial dialog 2018-07-24 05:05:00 +03:00
Jordan Petridis
f661d24544 Merge branch 'icons-are-weird' into 'master'
Get the symbolics to work

See merge request World/hammond!45
2018-07-24 01:53:01 +00:00
Zander Brown
cfe10553b2
Stop overriding the images 2018-07-24 04:01:16 +03:00
Jordan Petridis
cf1042f40d
Player: Improve the tooltips of buttons. 2018-07-23 23:36:52 +03:00
Jordan Petridis
e77000076b
Player: Add custom icons for the forward and rewind buttons. 2018-07-23 21:28:29 +03:00
Jordan Petridis
49241664dc Merge branch 'alatiera-master-patch-41773' into 'master'
Add Sam to the artists credits.

See merge request World/hammond!44
2018-07-21 23:19:11 +00:00
Jordan Petridis
ffa3e9ec9a Add Sam to the artists credits. 2018-07-21 23:02:56 +00:00
Jordan Petridis
fbbe0d9ca9
EpisodeWidget: Tweak padding and spacing. 2018-07-21 21:14:07 +03:00
Jordan Petridis
001eeecc09
ShowMenu: Add a separator and set alignment left. 2018-07-21 20:12:02 +03:00
Jordan Petridis
454a9c7076
ShowWidget: Fix description padding. 2018-07-21 19:41:15 +03:00
Jordan Petridis
fc934ce8e1
ShowsView/Stack: Add some assertions. 2018-07-21 10:39:42 +03:00
Jordan Petridis
b9bcc28e0f
ShowMenu: Add debug assertions here too. 2018-07-21 10:30:46 +03:00
Jordan Petridis
b5ddca65f5
ShowWidget: Add some assertions. 2018-07-21 10:24:48 +03:00
Jordan Petridis
536805791e
ShowWidget: Move controls into a headerbar menu.
This fits better the HIG and allows for more flexibility in the way
the ShowWidget is implemented/designed.
2018-07-21 09:47:08 +03:00
Jordan Petridis
5a6c73c4c1
Headerbar: Move/Rename the menus.ui to hamburger.ui 2018-07-21 07:20:48 +03:00
Jordan Petridis
d50f5a0488
Player: Remove no longer relavant FIXME annotations. 2018-07-19 22:14:17 +03:00
Jordan Petridis
671a31a95a
Player: Improver human-facing error message. 2018-07-18 16:16:33 +03:00
Jordan Petridis
5e38f41530 Merge branch 'lazy_drawing' into 'master'
Lazy drawing

See merge request World/hammond!43
2018-07-18 13:14:44 +00:00
Jordan Petridis
7569465a61
App: Remove the imposed delay before refresh_on_startup runs.
The application is even lazier now and this is no longer an issue.
2018-07-17 20:42:57 +03:00
Jordan Petridis
5913166a13
EpisodeWidget: Avoid Refference Cycles.
When passing an Rc into a gtk callback it causes
the Rust struct to be kept in memory even if the gtk+ wiget
was dropped.

Should have been using Weak refferences all along.
2018-07-17 20:42:45 +03:00
Jordan Petridis
6036562af2
HomeEpisode: Do not initialize the Image until it needs to be drawn. 2018-07-17 16:08:20 +03:00
Jordan Petridis
39e6c258d5
ShowsChild: do not initialize the cover until it needs to be drawn. 2018-07-17 16:04:04 +03:00
Jordan Petridis
1ab0291483
EpisodeWidget: Only initialize the episode once it's first drawn. 2018-07-17 15:57:52 +03:00
Jordan Petridis
fe024502d4
EpisodeWidget: Pass the EpisodeModel by value.
This is preparationg for being able to pass the model to
the connect_craw callback directly.
2018-07-16 16:01:32 +03:00
Jordan Petridis
9a76c6428a
Merge branch 'hammond-service-launch'
See merge request !42
2018-07-15 22:21:18 +03:00
Jordan Petridis
2d4053c792
cargo fmt 2018-07-15 22:20:45 +03:00
Zander Brown
a69254612c
Install as a DBus service 2018-07-15 22:20:31 +03:00
Zander Brown
09a14c1270
Delay showing window until ::activate
Bit of a hack as we are still creating the window in ::startup but it's good compromise

Pass the arguments to GApplication so we can be launched as a service
2018-07-15 22:20:28 +03:00
Jordan Petridis
b343068805
cargo fmt 2018-07-15 22:17:00 +03:00
Jordan Petridis
ecf50dde2b
Update .gitignore 2018-07-15 22:16:06 +03:00
200 changed files with 23024 additions and 7781 deletions

19
.gitignore vendored
View File

@ -1,10 +1,23 @@
target/
**/*.rs.bk
Cargo.lock
.vscode
*.ui~
resources.gresource
_build
_build/
build/
vendor/
.criterion
.criterion/
org.gnome.*.json~
podcasts-gtk/po/gnome-podcasts.pot
# scripts/test.sh
target_*/
# flatpak-builder stuff
.flatpak-builder/
app/
repo/
# Files configured by meson
podcasts-gtk/src/config.rs
podcasts-gtk/src/static_resource.rs

View File

@ -1,144 +1,30 @@
stages:
- test
- lint
- review
variables:
BUNDLE: "hammond-dev.flatpak"
.cargo_cache_template: &cargo_cache
cache:
# JOB_NAME - Each job will have it's own cache
# COMMIT_REF_SLUG = Lowercase name of the branch
# ^ Keep diffrerent caches for each branch
key: "$CI_JOB_NAME"
paths:
- target/
- .cargo_cache/
.cargo_test_template: &cargo_test
stage: test
variables:
RUSTFLAGS: "--cfg rayon_unstable"
RUST_BACKTRACE: "FULL"
before_script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends build-essential libgtk-3-dev meson libgstreamer1.0-dev
- mkdir -p .cargo_cache
# Only stuff inside the repo directory can be cached
# Override the CARGO_HOME variable to force it location
- export CARGO_HOME="${PWD}/.cargo_cache"
script:
- rustc -Vv && cargo -Vv
# Force regeneration of gresources regardless of artifacts chage
- cd hammond-gtk/resources/ && glib-compile-resources --generate resources.xml && cd ../../
- cargo build
- cargo test -- --test-threads=1
- cargo test -- --test-threads=1 --ignored
<<: *cargo_cache
.rust:stable:
# https://hub.docker.com/_/rust/
image: "rust"
<<: *cargo_test
.rust:nightly:
# https://hub.docker.com/r/rustlang/rust/
image: "rustlang/rust:nightly"
<<: *cargo_test
only:
- schedule
- web
include:
- project: 'gnome/citemplates'
file: 'flatpak/flatpak-ci-initiative-sdk-extensions.yml'
# ref: ''
flatpak:
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/rust_bundle:3.28
stage: test
script:
- flatpak-builder --stop-at=hammond app org.gnome.Hammond.json
# https://gitlab.gnome.org/World/hammond/issues/55
# Force regeneration of gresources regardless of artifacts chage
- flatpak-builder --run app org.gnome.Hammond.json glib-compile-resources --sourcedir=hammond-gtk/resources/ hammond-gtk/resources/resources.xml
image: 'registry.gitlab.gnome.org/gnome/gnome-runtime-images/rust_bundle:3.36'
variables:
MANIFEST_PATH: "org.gnome.Podcasts.Devel.json"
FLATPAK_MODULE: "gnome-podcasts"
MESON_ARGS: "-Dprofile=development"
APP_ID: "org.gnome.Podcasts.Devel"
RUNTIME_REPO: "https://nightly.gnome.org/gnome-nightly.flatpakrepo"
BUNDLE: "org.gnome.Podcasts.Devel.flatpak"
extends: '.flatpak'
# Build the flatpak repo
- flatpak-builder --run app org.gnome.Hammond.json meson --prefix=/app --libdir=/app/lib _build
- flatpak-builder --run app org.gnome.Hammond.json ninja -C _build install
- flatpak-builder --finish-only app org.gnome.Hammond.json
- flatpak build-export repo app
# Create a flatpak bundle
- flatpak build-bundle repo ${BUNDLE} org.gnome.Hammond
# Run the tests
# - flatpak-builder --run app org.gnome.Hammond.json cargo test -- --test-threads=1
# - flatpak-builder --run app org.gnome.Hammond.json cargo test -- --test-threads=1 --ignored
artifacts:
paths:
- $BUNDLE
expire_in: 30 days
cache:
# JOB_NAME - Each job will have it's own cache
# COMMIT_REF_SLUG = Lowercase name of the branch
# ^ Keep diffrerent caches for each branch
key: "$CI_JOB_NAME"
paths:
- .flatpak-builder/cache/
- target/
review:
stage: review
dependencies:
- flatpak
script:
- echo "Generating flatpak deployment"
artifacts:
paths:
- $BUNDLE
expire_in: 30 days
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://gitlab.gnome.org/$CI_PROJECT_PATH/-/jobs/$CI_JOB_ID/artifacts/raw/${BUNDLE}
on_stop: stop_review
except:
- master@World/hammond
stop_review:
stage: review
script:
- echo "Stopping flatpak deployment"
when: manual
environment:
name: review/$CI_COMMIT_REF_NAME
action: stop
except:
- master@World/hammond
# Configure and run rustfmt on nightly
# Configure and run rustfmt
# Exits and builds fails if on bad format
rustfmt:
image: "registry.gitlab.com/alatiera/rustfmt-oci-image/rustfmt:nightly"
stage: lint
script:
- rustc -Vv && cargo -Vv
- cargo fmt --version
- cargo fmt --all -- --check
# Configure and run clippy on nightly
# Only fails on errors atm.
.clippy:
image: "registry.gitlab.gnome.org/alatiera/hammond-container-images/clippy:nightly"
stage: lint
variables:
RUSTFLAGS: "--cfg rayon_unstable"
CARGO_HOME: ".cargo_cache"
script:
- rustc --version && cargo --version
- cargo clippy --version
# Force regeneration of gresources regardless of artifacts chage
- cd hammond-gtk/resources/ && glib-compile-resources --generate resources.xml && cd ../../
- cargo clippy --all
<<: *cargo_cache
image: "rust:slim"
stage: ".pre"
script:
- rustup component add rustfmt
# Create blank versions of our configured files
# so rustfmt does not yell about non-existent files or completely empty files
- echo -e "" >> podcasts-gtk/src/config.rs
- echo -e "" >> podcasts-gtk/src/static_resource.rs
- rustc -Vv && cargo -Vv
- cargo fmt --version
- cargo fmt --all -- --color=always --check

View File

@ -18,7 +18,7 @@ Some common cases might be:
Steps to reproduce:
1. Open Hammond
1. Open GNOME Podcasts
2. Do an action
3. ...

View File

@ -11,9 +11,7 @@ Reproducible in:
Please test if the issue was already fixed in the unstable version of the app.
For that, follow these steps:
1. Make sure Flatpak is installed or install it following these steps https://flatpak.org/setup
2. Install the unstable version of the app following this link
https://gitlab.gnome.org/GNOME/gnome-apps-nightly/raw/master/nautilus.flatpakref and save
it as a ".flatpakref" file
2. Install the unstable version of the app following, flatpak bundles can be found in the CI artifacts.
If these steps failed, write in 'Other' the distribution youre using and
the version of the app.

View File

@ -0,0 +1 @@
### Please attach a relevant issue to this MR, if this doesn't exist please create one.

View File

@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added:
### Changed:
@ -13,24 +14,180 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Removed:
## [0.4.7] - 2019-10-23
### Added:
- Improved appdata validation and meson tests World/podcasts!89
- The ability to export show subscriptions to opml files World/podcasts!77
- Support for feeds requiring authentication World/podcasts!120
### Changed:
- Episodes now have a checkmark to show whether or not they've been played World/podcasts!106
- Changed to how errors are shown when adding podcasts World/podcasts!108 World/podcasts!109 World/podcasts!110
- Improved integration of cargo and meson World/podcasts!94
- Refactored some macros for error handling World/podcasts!82
- Refactored the handling of styling changes World/podcasts!119
- Updated the icon to better match the HIG guidlines World/podcasts#102
- Made Podcasts use a GtkApplication subclass World/podcasts!113
- Updated the MPRIS permissions in order to remove a sandbox hole World/podcasts!124
- Bumped gtk and libhandy minimum versions
### Fixed:
- Rewind now works regardless if its the start or the end of the episode World/podcasts!83
- Typos in the README and CONTRIBUTING docs World/podcast!97 World/podcast!98 World/podcast!99 World/podcasts!121
- Show cover is reset properly now if there isn't an image World/podcasts#114
- Query pairs are no longer stripped from URLs World/podcasts!111
- Pause MPRIS button now works on KDE Plasma World/podcasts#115
- The playback widget now properly reflects the playback state on episode change World/podcasts!116
### Removed:
- All preferences World/podcast!104
## [0.4.6] - 2018-10-07
### Added:
- Felix, @haecker-felix, wrote an [mpris crate](https://crates.io/crates/mpris-player) and implemented MPRIS2 client side support! !74 #68
### Changed:
- Download Cancel button was changed to an Icon instead of a label !72
- The applciation will no longer scale below 360p in width 1933c79f7a87d8261d91ca4e14eb51c1ddc66624
- Update to the latest HIG 5050dda4d2f75b706842de8507d115dd5a1bd0a9
- Chris, @brainblasted, upgraded hyper to 0.12, this brings openssl 1.1 support !75
- Pipeline backend is now completly migrated to tokio-runtime 0887789f5e653dd92ad397fb39561df6dffcb45c
- Resume playing an episode will attempt to rewind the track only if more than a minute has passed since the last pause !76
### Fixed:
- Fixed a regression where indexing feeds was blocking the `tokio reactor` #88 !70
- Episodeds Listbox no longer resizes when a download starts #89 !72
- The `total_size` label of the `EpisodeWidget` now behaves correctly if the request fails #90 !73
- The Pipeline will no longer log things in stderr for Requests that returned 304 and are expected to be skipped da361d0cb93cd8edd076859b2c607509a96dac8d
- A bug where the HomeView wold get into an invalid state if your only shows had no episodes 32bd2a89a34e8e940b3b260c6be76defe11835ed
### Translations:
**Added**
- Brazilian Portuguese translation 586cf16f
- Swedish translation 2e527250
- Italian translation a23297e5
- Friulian translation 60e09c0d
- Hungarian translation 2751a828
- Croatian translation 0476b67b
- Latvian translation a681b2c9
- Czech translation 3563a964
- Catalan translation 6ea3fc91
**Updated**
- German translation
- Finnish translation
- Polish translation
- Turkish translation
- Croatian translation
- Indonesian translation
- Spanish translation
## [0.4.5] - 2018-08-31
### Added:
- [OARS](https://hughsie.github.io/oars/) Tags where added for compatibility with Store clients b0c94dd9
- Daniel added support for Translations !46
- Svitozar Cherepii(@svito) created a [wiki page](https://wiki.gnome.org/Apps/Podcasts) 70e79e50
- Libhandy was added as a dependancy #70
- Development builds can now be installed in parallel with stable builds !64
### Changed:
- The update indication was moved to an In-App notification #72
- The app icon's accent color was changed from orange to red 0dfb4859
- The stack switcher in the Headerbar is now insesitive on Empty Views !63
### Fixed:
- Improved handling of HTTP redirections #64 !61 !62
- Fixed a major performance regression when loading show covers !67
- More refference cycles have been fixed !59
- OPML import dialog now exits properly and no longer keeps the application from shuting down !65
- Update action is disabled if there isn't something to update #71
### Translations:
- Added Finish 93696026
- Added Polish 1bd6efc0
- Added Turkish 73929f2d
- Added Spanish !46
- Added German 6b6c390c
- Added Galician 0060a634
- Added Indonesian ded0224f
- Added Korean 36f16963
## [0.4.4] - 2018-07-31
### Changed:
- `SendCell` crate was replaced with `Fragile`. (Jorda Petridis) 838320785ebbea94e009698b473495cfec076f54
- Update dependancies (Jorda Petridis) 91bea8551998b16e44e5358fdd43c53422bcc6f3
### Fixed:
- Fix more refference cycles. (Jorda Petridis) 3496df24f8d8bfa8c8a53d8f00262d42ee39b41c
- Actually fix cargo-vendor (Jorda Petridis)
## [0.4.3] - 2018-07-27
### Fixed:
- Fix the cargo vendor config for the tarball releash script. (Jorda Petridis) a2440c19e11ca4dcdbcb67cd85259a41fe3754d6
## [0.4.2] - 2018-07-27
### Changed:
- Minimum size requested by the Views. (Jorda Petridis) 7c96152f3f53f271247230dccf1c9cd5947b685f
### Fixed:
- Screenshot metadata in appstream data. (Jorda Petridis) a2440c19e11ca4dcdbcb67cd85259a41fe3754d6
## [0.4.1] - 2018-07-26
### Added:
- Custom icons for the fast-forward and rewind actions in the Player were added. (Tobias Bernard) e77000076b3d78b8625f4c7ef367376d0130ece6
- Hicolor and symbolic icons for the Application. (Tobias Bernard and Sam Hewitt) edae1b04801dba9d91d5d4145db79b287f0eec2c
- Basic prefferences dialog (Zander Brown). [34](https://gitlab.gnome.org/World/podcasts/merge_requests/34)
- Dbus service preperation. Not used till the MPRIS2 integration has landed. (Zander Brown) [42](https://gitlab.gnome.org/World/podcasts/merge_requests/42)
- Episodes and Images will only get drawn when needed. Big Performance impact. (Jordan Petridis) [43](https://gitlab.gnome.org/World/podcasts/merge_requests/43)
### Changed:
- The `ShowWidget` control button were moved to a secondary menu in the Headerbar. (Jordan Petridis) 536805791e336a3e112799be554706bb804d2bef
- EmptyView layout improvements. (Jorda Petridis) 3c3d6c1e7f15b88308a9054b15a6ca0d8fa233ce 518ea9c8b57885c44bda9c418b19fef26ae0e55d
- Improved the `AddButton` behavior. (Jorda Petridis) 67ab54f8203f19aad198dc49e935127d25432b41
### Fixed:
- A couple reffence cycles where fixed. (Jorda Petridis)
### Removed:
- The delay between the application startup and the `update_on_startup` action. (Jorda Petridis) 7569465a612ee5ef84d0e58f4e1010c8d14080d4
## [0.4.0] - 2018-07-04
### Added:
- Keyboard Shortcuts and a Shortcuts dialog were implemented. (ZanderBrown)
[!33](https://gitlab.gnome.org/World/hammond/merge_requests/33)
[!33](https://gitlab.gnome.org/World/podcasts/merge_requests/33)
### Changed:
- The `FileChooser` of the OPML import was changed to use the `FileChooserNative` widget/API. (ZanderBrown)
[!33](https://gitlab.gnome.org/World/hammond/merge_requests/33)
[!33](https://gitlab.gnome.org/World/podcasts/merge_requests/33)
- The `EpisdeWidget` was refactored.
[!38](https://gitlab.gnome.org/World/hammond/merge_requests/38)
[!38](https://gitlab.gnome.org/World/podcasts/merge_requests/38)
- `EpisdeWidget`'s progressbar was changed to be non-blocking and should feel way more responsive now. 9b0ac5b83dadecdff51cd398293afdf0d5276012
- An embeded audio player was implemented!
[!40](https://gitlab.gnome.org/World/hammond/merge_requests/40)
[!40](https://gitlab.gnome.org/World/podcasts/merge_requests/40)
- Various Database changes.
[!41](https://gitlab.gnome.org/World/hammond/merge_requests/41)
[!41](https://gitlab.gnome.org/World/podcasts/merge_requests/41)
### Fixed:
- Fixed a bug whre the about dialog would be unclosable. (ZanderBrown) [!37](https://gitlab.gnome.org/World/hammond/merge_requests/37)
- Fixed a bug whre the about dialog would be unclosable. (ZanderBrown) [!37](https://gitlab.gnome.org/World/podcasts/merge_requests/37)
## [0.3.4] - 2018-05-20
### Fixed:
@ -56,9 +213,9 @@ not being able to access any file.
### Changed:
- Downlaoding and loading images now is done asynchronously and is not blocking programs execution.
[#7](https://gitlab.gnome.org/World/hammond/issues/7)
[#7](https://gitlab.gnome.org/World/podcasts/issues/7)
- Bold, italics links and some other `html` tags can now be rendered in the Show Description.
[#25](https://gitlab.gnome.org/World/hammond/issues/25)
[#25](https://gitlab.gnome.org/World/podcasts/issues/25)
- `Rayon` Threadpools are now used instead of unlimited one-off threads.
- `EpisdeWidget`s are now loaded asynchronously accross views.
- `EpisodeWidget`s no longer trigger a `View` refresh for trivial stuff 03bd95184808ccab3e0ea0e3713a52ee6b7c9ab4
@ -66,7 +223,7 @@ not being able to access any file.
- `ShowWidget` Description is inside a scrolled window now
### Fixed:
- `EpisodeWidget` Height now is consistent accros views [#57](https://gitlab.gnome.org/World/hammond/issues/57)
- `EpisodeWidget` Height now is consistent accros views [#57](https://gitlab.gnome.org/World/podcasts/issues/57)
- Implemented a tail-recursion loop to follow-up when a feed redirects to another url. c6a24e839a8ba77d09673f299cfc1e64ba7078f3
### Removed:
@ -75,27 +232,27 @@ not being able to access any file.
## [0.3.1] - 2018-03-28
### Added:
- Ability to mark all episodes of a Show as watched.
[#47](https://gitlab.gnome.org/World/hammond/issues/47)
[#47](https://gitlab.gnome.org/World/podcasts/issues/47)
- Now you are able to subscribe to itunes™ podcasts by using the itunes link of the show.
[#49](https://gitlab.gnome.org/World/hammond/issues/49)
[#49](https://gitlab.gnome.org/World/podcasts/issues/49)
- Hammond now remembers the window size and position. (Rowan Lewis)
[#50](https://gitlab.gnome.org/World/hammond/issues/50)
[#50](https://gitlab.gnome.org/World/podcasts/issues/50)
- Implemnted the initial work for integrating with GSettings and storing preferences. (Rowan Lewis)
[!22](https://gitlab.gnome.org/World/hammond/merge_requests/22) [!23](https://gitlab.gnome.org/World/hammond/merge_requests/23)
[!22](https://gitlab.gnome.org/World/podcasts/merge_requests/22) [!23](https://gitlab.gnome.org/World/podcasts/merge_requests/23)
- Shows without episodes now display an empty message similar to EmptyView.
[#44](https://gitlab.gnome.org/World/hammond/issues/44)
[#44](https://gitlab.gnome.org/World/podcasts/issues/44)
### Changed:
- EpisdeWidget has been reimplemented as a compile time state machine.
[!18](https://gitlab.gnome.org/World/hammond/merge_requests/18)
[!18](https://gitlab.gnome.org/World/podcasts/merge_requests/18)
- Content Views no longer scroll horizontally when shrunk bellow their minimum size.
[#35](https://gitlab.gnome.org/World/hammond/issues/35)
[#35](https://gitlab.gnome.org/World/podcasts/issues/35)
- Some requests now use the Tor Browser's user agent. (Rowan Lewis)
[#53](https://gitlab.gnome.org/World/hammond/issues/53)
[#53](https://gitlab.gnome.org/World/podcasts/issues/53)
### Fixed:
- Double border aroun the main window was fixed. (Rowan Lewis)
[#52](https://gitlab.gnome.org/World/hammond/issues/52)
[#52](https://gitlab.gnome.org/World/podcasts/issues/52)
## [0.3.0] - 2018-02-11
- Tobias Bernard Redesigned the whole Gtk+ client.
@ -115,4 +272,4 @@ not being able to access any file.
- Added appdata.xml file
## [0.1.0] - 2017-11-13
- Initial Release
- Initial Release

View File

@ -1,18 +1,18 @@
## Contributing to Hammond
## Contributing to GNOME Podcasts
Thank you for looking in this file!
When contributing to the development of Hammond, please first discuss the change you wish to make via issue, email, or any other method with the maintainers before making a change.
When contributing to the development of GNOME Podcasts, please first discuss the change you wish to make via issue, email, or any other method with the maintainers before making a change.
If you have any questions regarding the use or development of Hammond,
want to discuss design or simply hang out, please join us in [#hammond on irc.gnome.org.](irc://irc.gnome.org/#hammond)
If you have any questions regarding the use or development of GNOME Podcasts,
want to discuss design or simply hang out, please join us in [#gnome-podcasts:matrix.org](https://matrix.to/#/#gnome-podcasts:matrix.org) or [#hammond on irc.gnome.org.](irc://irc.gnome.org/#hammond)
Please note we have a [code of conduct](https://wiki.gnome.org/Foundation/CodeOfConduc), please follow it in all your interactions with the project.
Please note we have a [code of conduct](/code-of-conduct.md), please follow it in all your interactions with the project.
## Source repository
Hammond's main source repository is at gitlab.gnome.org. You can view
the web interface [here](https://gitlab.gnome.org/World/hammond)
GNOME Podcasts's main source repository is at gitlab.gnome.org. You can view
the web interface [here](https://gitlab.gnome.org/World/podcasts)
Development happens in the master branch.
@ -26,9 +26,12 @@ makes things easier for the maintainers.
We use [rustfmt](https://github.com/rust-lang-nursery/rustfmt) for code formatting and we enforce it on the gitlab-CI server.
Quick setup
***Installing rustfmt*** As of 2019/Jan, our continuous integration
pipeline assumes the version of rustfmt that is distributed through the
stable channel of [rustup](rustup.rs). You can install it with
```
cargo install rustfmt-nightly
rustup component add rustfmt
cargo fmt --all
```
@ -36,7 +39,7 @@ It is recommended to add a pre-commit hook to run cargo test and `cargo fmt`.
Don't forget to `git add` again after `cargo fmt`.
```
#!/bin/sh
cargo test -- --test-threads=1 && cargo fmt --all -- --write-mode=diff
cargo test -- --test-threads=1 && cargo fmt --all -- --check
```
## Running the test suite
@ -44,14 +47,14 @@ cargo test -- --test-threads=1 && cargo fmt --all -- --write-mode=diff
Running the tests requires an internet connection and it it will download some files from the [Internet Archive](archive.org)
The test suite sets a temporary sqlite database in the `/tmp` folder.
Due to that it's not possible to run them in parrallel.
Due to that it's not possible to run them in parallel.
In order to run the test suite use the following: `cargo test -- --test-threads=1`
# Issues, issues and more issues!
There are many ways you can contribute to Hammond, and all of them involve creating issues
in [Hammond issue tracker](https://gitlab.gnome.org/World/hammond/issues). This is the entry point for your contribution.
There are many ways you can contribute to GNOME Podcasts, and all of them involve creating issues
in [GNOME Podcasts issue tracker](https://gitlab.gnome.org/World/podcasts/issues). This is the entry point for your contribution.
To create an effective and high quality ticket, try to put the following information on your
ticket:
@ -74,7 +77,7 @@ If it's an issue, add the steps to reproduce like this:
Steps to reproduce:
1. Open Hammond
1. Open GNOME Podcasts
2. Do an Action
3. ...
@ -91,13 +94,13 @@ Steps to reproduce:
* [ ] qa (quality assurance) tasks
```
## Pull Request Process
## Merge Request Process
1. Ensure your code compiles. Run `make` before creating the pull request.
1. Ensure your code compiles. Run `meson` & `ninja` before creating the merge request.
2. Ensure the test suit passes. Run `cargo test -- --test-threads=1`.
3. Ensure your code is properly formated. Run `cargo fmt --all`.
3. Ensure your code is properly formatted. Run `cargo fmt --all`.
4. If you're adding new API, it must be properly documented.
5. The commit message is formatted as follows:
5. The commit message has to be formatted as follows:
```
component: <summary>
@ -107,8 +110,8 @@ Steps to reproduce:
<link to the bug ticket>
```
6. You may merge the pull request in once you have the sign-off of the maintainers, or if you
6. You may merge the merge request once you have the sign-off of the maintainers, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.
## Code of Conduct
We follow the Gnome [Code of Conduct.](https://wiki.gnome.org/Foundation/CodeOfConduct)
We follow the [GNOME Foundation Code of Conduct](/code-of-conduct.md).

3523
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
[workspace]
members = [
"hammond-data",
"hammond-downloader",
"hammond-gtk"
"podcasts-data",
"podcasts-downloader",
"podcasts-gtk"
]
[profile.release]
debug = false
debug = true

View File

@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Hammond
GNOME Podcasts
Copyright (C) 2017 Jordan Petridis
This program is free software: you can redistribute it and/or modify
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Hammond Copyright (C) 2017 Jordan Petridis
GNOME Podcasts Copyright (C) 2017 Jordan Petridis
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

133
README.md
View File

@ -1,66 +1,63 @@
# Hammond
# GNOME Podcasts
### A Podcast Client for GNOME written in Rust.
### A Podcast application for GNOME.
Listen to your favorite podcasts, right from your desktop.
![episdes_view](./screenshots/episodes_view.png)
![episdes_view](./screenshots/home_view.png)
![shows_view](./screenshots/shows_view.png)
![show_widget](./screenshots/show_widget.png)
## Available on Flathub
[![Get it from Flathub!](https://flathub.org/assets/badges/flathub-badge-en.svg)](https://flathub.org/apps/details/org.gnome.Podcasts)
## Quick start
Hammond can be built and run with [Gnome Builder](https://wiki.gnome.org/Apps/Builder) >= 3.28.
GNOME Podcasts can be built and run with [Gnome Builder][builder] >= 3.28.
Just clone the repo and hit the run button!
Get Builder [here](https://wiki.gnome.org/Apps/Builder/Downloads)
You can get Builder from [here][get_builder].
## Broken Feeds
Found a feed that does not work in Hammond?
Please [open an issue](https://gitlab.gnome.org/World/hammond/issues/new) and choose the `BrokenFeed` template so we will know and fix it!
Found a feed that does not work in GNOME Podcasts?
Please [open an issue][new_issue] and choose the `BrokenFeed` template so we will know and fix it!
## Getting in Touch
If you have any questions regarding the use or development of Hammond,
want to discuss design or simply hang out, please join us in `#hammond` on
[irc.gnome.org.][irc] or [matrix][matrix].
Note:
There isn't much documentation yet, so you will probably have question about parts of the Code.
If you have any questions regarding the use or development of GNOME Podcasts,
want to discuss design or simply hang out, please join us on our [irc][irc] or [matrix][matrix] channel.
## Building
### Flatpak
Flatpak is the reccomended way of building and installing Hammond.
Flatpak is the recommended way of building and installing GNOME Podcasts.
Here are the dependencies you will need.
#### Building a Flatpak
```sh
# Add flathub and the gnome-nightly repo
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --user --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
Download the `org.gnome.Hammond.json` flatpak manifest from this repo.
# Install the gnome-nightly Sdk and Platform runtime
flatpak install --user gnome-nightly org.gnome.Sdk org.gnome.Platform
```bash
# Add flathub repo
flatpak --user remote-add flathub --if-not-exists https://dl.flathub.org/repo/flathub.flatpakrepo
# Add the gnome-nightly repo
flatpak --user remote-add gnome-nightly --if-not-exists https://sdk.gnome.org/gnome-nightly.flatpakrepo
# Install the gnome-nightly Sdk and Platform runtim
flatpak --user install gnome-nightly org.gnome.Sdk org.gnome.Platform
# Install the required rust-stable extension from flathub
flatpak --user install flathub org.freedesktop.Sdk.Extension.rust-stable
flatpak-builder --user --repo=repo hammond org.gnome.Hammond.json --force-clean
flatpak install --user flathub org.freedesktop.Sdk.Extension.rust-stable//19.08
```
To install the resulting flatpak you can do:
```bash
flatpak build-bundle repo hammond.flatpak org.gnome.Hammond
flatpak install --user --bundle hammond.flatpak
flatpak-builder --user --install --force-clean --repo=repo podcasts org.gnome.Podcasts.json
```
### Building from soure
### Building from source
```sh
git clone https://gitlab.gnome.org/World/hammond.git
cd hammond/
git clone https://gitlab.gnome.org/World/podcasts.git
cd gnome-podcasts/
meson --prefix=/usr build
ninja -C build
sudo ninja -C build install
@ -68,50 +65,33 @@ sudo ninja -C build install
#### Dependencies
* Rust stable 1.27 or later along with cargo.
* Gtk+ 3.22 or later
* Gstreamer 1.12 or later
* Rust stable 1.34 or later along with cargo.
* Gtk+ 3.24.11 or later
* Gstreamer 1.16 or later
* libhandy 0.0.11 or later
* Meson
* A network connection
Offline build are possible too, but [`cargo-vendor`][vendor] would have to be setup first
**Debian/Ubuntu**
```sh
apt-get install -yqq cargo rustc libsqlite3-dev libssl-dev libgtk-3-dev meson \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
gstreamer1.0-libav libgstrtspserver-1.0-dev ibgstreamer-plugins-bad1.0-dev
```
**Fedora**
```sh
dnf install -y rust cargo gtk3-devel glib2-devel openssl-devel sqlite-devel meson \
gstreamer1-devel gstreamer1-plugins-base-tools gstreamer1-devel-docs \
gstreamer1-plugins-base-devel gstreamer1-plugins-base-devel-docs \
gstreamer1-plugins-good gstreamer1-plugins-good-extras \
gstreamer1-plugins-bad-free gstreamer1-plugins-bad-free-devel \
gstreamer1-plugins-bad-free-extras
```
If you happen to build it on other distributions please let me know the names
of the corresponding libraries. Feel free to open a MR or an Issue to note it.
## Contributing
There alot of thins yet to be done.
There are a lot of things yet to be done.
If you want to contribute, please check the [Contributions Guidelines][contribution-guidelines].
You can start by taking a look at [Issues](https://gitlab.gnome.org/World/hammond/issues) or by opening a [New issue](https://gitlab.gnome.org/World/hammond/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=).
You can start by taking a look at [Issues][issues] or by opening a [New issue][new_issue].
There are also some minor tasks tagged with `TODO:` and `FIXME:` in the source code.
[contribution-guidelines]: https://gitlab.gnome.org/World/hammond/blob/master/CONTRIBUTING.md
[contribution-guidelines]: https://gitlab.gnome.org/World/podcasts/blob/master/CONTRIBUTING.md
### Translations
Translation of this project takes place on the GNOME translation platform,
[Damned Lies](https://l10n.gnome.org/module/podcasts). For further
information on how to join a language team, or even to create one, please see
[GNOME Translation Project wiki page](https://wiki.gnome.org/TranslationProject).
## Overview
@ -119,15 +99,15 @@ There are also some minor tasks tagged with `TODO:` and `FIXME:` in the source c
```sh
$ tree -d
├── screenshots # png's used in the README.md
├── hammond-data # Storate related stuff, SQLite, XDG setup, RSS Parser.
├── podcasts-data # Storate related stuff, SQLite, XDG setup, RSS Parser.
│   ├── migrations # Diesel SQL migrations.
│   │   └── ...
│   ├── src
│   └── tests
│   └── feeds # Raw RSS Feeds used for tests.
├── hammond-downloader # Really basic, Really crappy downloader.
├── podcasts-downloader # Really basic, Really crappy downloader.
│   └── src
├── hammond-gtk # The Gtk+ Client
├── podcasts-gtk # The Gtk+ Client
│   ├── resources # GResources folder
│   │   └── gtk # Contains the glade.ui files.
│   └── src
@ -137,18 +117,27 @@ $ tree -d
## A note about the project's name
The project was named after Allan Moore's character [Evey Hammond](https://en.wikipedia.org/wiki/Evey_Hammond) from the graphic novel V for Vendetta.
It has nothing to do with the horrible headlines on the news.
The project used to be called Hammond, after Allan Moore's character [Evey Hammond][hammond] from the graphic novel V for Vendetta.
It was renamed to GNOME Podcasts on 2018/07/24 shortly before its first public release.
## Acknowledgments
Hammond's design is heavily insired by [GNOME Music](https://wiki.gnome.org/Design/Apps/Music) and [Vocal](http://vocalproject.net/).
GNOME Podcasts's design is heavily inspired by [GNOME Music][music] and [Vocal][vocal].
We also copied some elements from [GNOME News](https://wiki.gnome.org/Design/Apps/Potential/News).
We also copied some elements from [GNOME News][news].
And almost the entirety of the build system is copied from the [Fractal](https://gitlab.gnome.org/danigm/fractal) project.
And almost the entirety of the build system is copied from the [Fractal][fractal] project.
[vendor]: https://github.com/alexcrichton/cargo-vendor
[irc]: irc://irc.gnome.org/#hammond
[matrix]: https://matrix.to/#/#hammond:matrix.org
[matrix]: https://matrix.to/#/#gnome-podcasts:matrix.org
[flatpak_setup]: https://flatpak.org/setup/
[music]: https://wiki.gnome.org/Design/Apps/Music
[vocal]: http://vocalproject.net/
[news]: https://wiki.gnome.org/Design/Apps/Potential/News
[fractal]: https://gitlab.gnome.org/World/fractal
[hammond]: https://en.wikipedia.org/wiki/Evey_Hammond
[issues]: https://gitlab.gnome.org/World/podcasts/issues
[new_issue]: https://gitlab.gnome.org/World/podcasts/issues/new
[builder]: https://wiki.gnome.org/Apps/Builder
[get_builder]: https://wiki.gnome.org/Apps/Builder/Downloads

126
code-of-conduct.md Normal file
View File

@ -0,0 +1,126 @@
# GNOME Code of Conduct
Thank you for being a part of the GNOME project. We value your participation and want everyone to have an enjoyable and fulfilling experience. Accordingly, all participants are expected to follow this Code of Conduct, and to show respect, understanding, and consideration to one another. Thank you for helping make this a welcoming, friendly community for everyone.
## Scope
This Code of Conduct applies to all online GNOME community spaces, including, but not limited to:
* Issue tracking systems - bugzilla.gnome.org
* Documentation and tutorials - developer.gnome.org
* Code repositories - git.gnome.org and gitlab.gnome.org
* Mailing lists - mail.gnome.org
* Wikis - wiki.gnome.org
* Chat and forums - irc.gnome.org, discourse.gnome.org, GNOME Telegram channels, and GNOME groups and channels on Matrix.org (including bridges to GNOME IRC channels)
* Community spaces hosted on gnome.org infrastructure
* Any other channels or groups which exist in order to discuss GNOME project activities
Communication channels and private conversations that are normally out of scope may be considered in scope if a GNOME participant is being stalked or harassed. Social media conversations may be considered in-scope if the incident occurred under a GNOME event hashtag, or when an official GNOME account on social media is tagged, or within any other discussion about GNOME. The GNOME Foundation reserves the right to take actions against behaviors that happen in any context, if they are deemed to be relevant to the GNOME project and its participants.
All participants in GNOME online community spaces are subject to the Code of Conduct. This includes GNOME Foundation board members, corporate sponsors, and paid employees. This also includes volunteers, maintainers, leaders, contributors, contribution reviewers, issue reporters, GNOME users, and anyone participating in discussion in GNOME online spaces.
## Reporting an Incident
If you believe that someone is violating the Code of Conduct, or have
any other concerns, please [contact the Code of Conduct committee](https://wiki.gnome.org/Foundation/CodeOfConduct/ReporterGuide).
## Our Standards
The GNOME online community is dedicated to providing a positive experience for everyone, regardless of:
* age
* body size
* caste
* citizenship
* disability
* education
* ethnicity
* familial status
* gender expression
* gender identity
* genetic information
* immigration status
* level of experience
* nationality
* personal appearance
* pregnancy
* race
* religion
* sex characteristics
* sexual orientation
* sexual identity
* socio-economic status
* tribe
* veteran status
### Community Guidelines
Examples of behavior that contributes to creating a positive environment include:
* **Be friendly.** Use welcoming and inclusive language.
* **Be empathetic.** Be respectful of differing viewpoints and experiences.
* **Be respectful.** When we disagree, we do so in a polite and constructive manner.
* **Be considerate.** Remember that decisions are often a difficult choice between competing priorities. Focus on what is best for the community. Keep discussions around technology choices constructive and respectful.
* **Be patient and generous.** If someone asks for help it is because they need it. When documentation is available that answers the question, politely point them to it. If the question is off-topic, suggest a more appropriate online space to seek help.
* **Try to be concise.** Read the discussion before commenting in order to not repeat a point that has been made.
### Inappropriate Behavior
Community members asked to stop any inappropriate behavior are expected to comply immediately.
We want all participants in the GNOME community have the best possible experience they can. In order to be clear what that means, we've provided a list of examples of behaviors that are inappropriate for GNOME community spaces:
* **Deliberate intimidation, stalking, or following.**
* **Sustained disruption of online discussion, talks, or other events.** Sustained disruption of events, online discussions, or meetings, including talks and presentations, will not be tolerated. This includes 'Talking over' or 'heckling' event speakers or influencing crowd actions that cause hostility in event sessions. Sustained disruption also includes drinking alcohol to excess or using recreational drugs to excess, or pushing others to do so.
* **Harassment of people who don't drink alcohol.** We do not tolerate derogatory comments about those who abstain from alcohol or other substances. We do not tolerate pushing people to drink, talking about their abstinence or preferences to others, or pressuring them to drink - physically or through jeering.
* **Sexist, racist, homophobic, transphobic, ableist language or otherwise exclusionary language.** This includes deliberately referring to someone by a gender that they do not identify with, and/or questioning the legitimacy of an individual's gender identity. If you're unsure if a word is derogatory, don't use it. This also includes repeated subtle and/or indirect discrimination.
* **Unwelcome sexual attention or behavior that contributes to a sexualized environment.** This includes sexualized comments, jokes or imagery in interactions, communications or presentation materials, as well as inappropriate touching, groping, or sexual advances. Sponsors should not use sexualized images, activities, or other material. Meetup organizing staff and other volunteer organizers should not use sexualized clothing/uniforms/costumes, or otherwise create a sexualized environment.
* **Unwelcome physical contact.** This includes touching a person without permission, including sensitive areas such as their hair, pregnant stomach, mobility device (wheelchair, scooter, etc) or tattoos. This also includes physically blocking or intimidating another person. Physical contact or simulated physical contact (such as emojis like "kiss") without affirmative consent is not acceptable. This includes sharing or distribution of sexualized images or text.
* **Violence or threats of violence.** Violence and threats of violence are not acceptable - online or offline. This includes incitement of violence toward any individual, including encouraging a person to commit self-harm. This also includes posting or threatening to post other people's personally identifying information ("doxxing") online.
* **Influencing or encouraging inappropriate behavior.** If you influence or encourage another person to violate the Code of Conduct, you may face the same consequences as if you had violated the Code of Conduct.
* **Possession of an offensive weapon at a GNOME event.** This includes anything deemed to be a weapon by the event organizers.
The GNOME community prioritizes marginalized people's safety over privileged people's comfort. The committee will not act on complaints regarding:
* "Reverse"-isms, including "reverse racism," "reverse sexism," and "cisphobia"
* Reasonable communication of boundaries, such as "leave me alone," "go away," or "I'm not discussing this with you."
* Criticizing racist, sexist, cissexist, or otherwise oppressive behavior or assumptions
* Communicating boundaries or criticizing oppressive behavior in a "tone" you don't find congenial
The examples listed above are not against the Code of Conduct. If you have questions about the above statements, please [read this document](https://github.com/sagesharp/code-of-conduct-template/blob/master/code-of-conduct/example-reversisms.md#supporting-diversity).
If a participant engages in behavior that violates this code of conduct, the GNOME Code of Conduct committee may take any action they deem appropriate. Examples of consequences are outlined in the [Committee Procedures Guide](https://wiki.gnome.org/Foundation/CodeOfConduct/CommitteeProcedures).
## Procedure for Handling Incidents
* [Reporter Guide](https://wiki.gnome.org/Foundation/CodeOfConduct/ReporterGuide)
* [Moderator Procedures](https://wiki.gnome.org/Foundation/CodeOfConduct/ModeratorProcedures)
* [Committee Procedures Guide](https://wiki.gnome.org/Foundation/CodeOfConduct/CommitteeProcedures)
## License
The GNOME Online Code of Conduct is licensed under a [Creative Commons Attribution Share-Alike 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/)
![Creative Commons License](http://i.creativecommons.org/l/by-sa/3.0/88x31.png)
## Attribution
The GNOME Online Code of Conduct was forked from the example policy from the [Geek Feminism wiki, created by the Ada Initiative and other volunteers](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy), which is under a Creative Commons Zero license.
Additional language was incorporated and modified from the following Codes of Conduct:
* [Citizen Code of Conduct](http://citizencodeofconduct.org/) is licensed [Creative Commons Attribution Share-Alike 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/).
* [Code of Conduct template](https://github.com/sagesharp/code-of-conduct-template/) is licensed [Creative Commons Attribution Share-Alike 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/) by [Otter Tech](https://otter.technology/code-of-conduct-training)
* [Contributor Covenant version 1.4](https://www.contributor-covenant.org/version/1/4/code-of-conduct) (licensed [CC BY 4.0](https://github.com/ContributorCovenant/contributor_covenant/blob/master/LICENSE.md))
* [Data Carpentry Code of Conduct](https://docs.carpentries.org/topic_folders/policies/index_coc.html) is licensed [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/)
* [Django Project Code of Conduct](https://www.djangoproject.com/conduct/) is licensed under a [Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/)
* [Fedora Code of Conduct](http://fedoraproject.org/code-of-conduct)
* [Geek Feminism Anti-harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy) which is under a [Creative Commons Zero license](https://creativecommons.org/publicdomain/zero/1.0/)
* [Previous GNOME Foundation Code of Conduct](https://wiki.gnome.org/action/recall/Foundation/CodeOfConduct/Old)
* [LGBTQ in Technology Slack Code of Conduct](https://lgbtq.technology/coc.html) licensed [Creative Commons Zero](https://creativecommons.org/publicdomain/zero/1.0/)
* [Mozilla Community Participation Guidelines](https://www.mozilla.org/en-US/about/governance/policies/participation/) is licensed [Creative Commons Attribution-ShareAlike 3.0 Unported License](https://creativecommons.org/licenses/by-sa/3.0/).
* [Python Mentors Code of Conduct](http://pythonmentors.com/)
* [Speak Up! Community Code of Conduct](http://web.archive.org/web/20141109123859/http://speakup.io/coc.html), licensed under a [Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/)

View File

@ -1,46 +0,0 @@
[package]
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
name = "hammond-data"
version = "0.1.0"
workspace = "../"
[dependencies]
ammonia = "1.1.0"
chrono = "0.4.4"
derive_builder = "0.5.1"
lazy_static = "1.0.1"
log = "0.4.2"
rayon = "1.0.1"
rayon-futures = "0.1.0"
rfc822_sanitizer = "0.3.3"
rss = "1.5.0"
url = "1.7.0"
xdg = "2.1.0"
xml-rs = "0.8.0"
futures = "0.1.21"
hyper = "0.11.27"
tokio-core = "0.1.17"
hyper-tls = "0.1.3"
native-tls = "0.1.5"
num_cpus = "1.8.0"
failure = "0.1.1"
failure_derive = "0.1.1"
[dependencies.diesel]
features = ["sqlite", "r2d2"]
version = "1.3.2"
[dependencies.diesel_migrations]
features = ["sqlite"]
version = "1.3.0"
[dev-dependencies]
rand = "0.5.2"
tempdir = "0.3.7"
criterion = "0.2.3"
pretty_assertions = "0.5.1"
maplit = "1.0.1"
[[bench]]
name = "bench"
harness = false

View File

@ -1,104 +0,0 @@
#![allow(unused)]
#[macro_use]
extern crate criterion;
use criterion::Criterion;
// extern crate futures;
extern crate hammond_data;
extern crate hyper;
extern crate hyper_tls;
extern crate rand;
extern crate tokio_core;
// extern crate rayon;
extern crate rss;
// use rayon::prelude::*;
// use futures::future::*;
use tokio_core::reactor::Core;
use hammond_data::database::truncate_db;
use hammond_data::pipeline;
use hammond_data::FeedBuilder;
use hammond_data::Source;
// use hammond_data::errors::*;
use std::io::BufReader;
// RSS feeds
const INTERCEPTED: &[u8] = include_bytes!("../tests/feeds/2018-01-20-Intercepted.xml");
const INTERCEPTED_URL: &str = "https://web.archive.org/web/20180120083840if_/https://feeds.\
feedburner.com/InterceptedWithJeremyScahill";
const UNPLUGGED: &[u8] = include_bytes!("../tests/feeds/2018-01-20-LinuxUnplugged.xml");
const UNPLUGGED_URL: &str =
"https://web.archive.org/web/20180120110314if_/https://feeds.feedburner.com/linuxunplugged";
const TIPOFF: &[u8] = include_bytes!("../tests/feeds/2018-01-20-TheTipOff.xml");
const TIPOFF_URL: &str =
"https://web.archive.org/web/20180120110727if_/https://rss.acast.com/thetipoff";
// This feed has HUGE descripion and summary fields which can be very
// very expensive to parse.
const CODE: &[u8] = include_bytes!("../tests/feeds/2018-01-20-GreaterThanCode.xml");
const CODE_URL: &str =
"https://web.archive.org/web/20180120104741if_/https://www.greaterthancode.com/feed/podcast";
// Relative small feed
const STARS: &[u8] = include_bytes!("../tests/feeds/2018-01-20-StealTheStars.xml");
const STARS_URL: &str =
"https://web.archive.org/web/20180120104957if_/https://rss.art19.com/steal-the-stars";
static FEEDS: &[(&[u8], &str)] = &[
(INTERCEPTED, INTERCEPTED_URL),
(UNPLUGGED, UNPLUGGED_URL),
(TIPOFF, TIPOFF_URL),
(CODE, CODE_URL),
(STARS, STARS_URL),
];
fn bench_index_large_feed(c: &mut Criterion) {
truncate_db().unwrap();
let url = "https://www.greaterthancode.com/feed/podcast";
let mut core = Core::new().unwrap();
c.bench_function("index_large_feed", move |b| {
b.iter(|| {
let s = Source::from_url(url).unwrap();
// parse it into a channel
let chan = rss::Channel::read_from(BufReader::new(CODE)).unwrap();
let feed = FeedBuilder::default()
.channel(chan)
.source_id(s.id())
.build()
.unwrap();
core.run(feed.index()).unwrap();
})
});
truncate_db().unwrap();
}
fn bench_index_small_feed(c: &mut Criterion) {
truncate_db().unwrap();
let url = "https://rss.art19.com/steal-the-stars";
let mut core = Core::new().unwrap();
c.bench_function("index_small_feed", move |b| {
b.iter(|| {
let s = Source::from_url(url).unwrap();
// parse it into a channel
let chan = rss::Channel::read_from(BufReader::new(STARS)).unwrap();
let feed = FeedBuilder::default()
.channel(chan)
.source_id(s.id())
.build()
.unwrap();
core.run(feed.index()).unwrap();
})
});
truncate_db().unwrap();
}
criterion_group!(benches, bench_index_large_feed, bench_index_small_feed);
criterion_main!(benches);

View File

@ -1,131 +0,0 @@
use diesel;
use diesel::r2d2;
use diesel_migrations::RunMigrationsError;
use hyper;
use native_tls;
use rss;
use url;
use xml;
use std::io;
use models::Source;
#[fail(display = "Request to {} returned {}. Context: {}", url, status_code, context)]
#[derive(Fail, Debug)]
pub struct HttpStatusError {
url: String,
status_code: hyper::StatusCode,
context: String,
}
impl HttpStatusError {
pub fn new(url: String, code: hyper::StatusCode, context: String) -> Self {
HttpStatusError {
url,
status_code: code,
context,
}
}
}
#[derive(Fail, Debug)]
pub enum DataError {
#[fail(display = "SQL Query failed: {}", _0)]
DieselResultError(#[cause] diesel::result::Error),
#[fail(display = "Database Migration error: {}", _0)]
DieselMigrationError(#[cause] RunMigrationsError),
#[fail(display = "R2D2 error: {}", _0)]
R2D2Error(#[cause] r2d2::Error),
#[fail(display = "R2D2 Pool error: {}", _0)]
R2D2PoolError(#[cause] r2d2::PoolError),
#[fail(display = "Hyper Error: {}", _0)]
HyperError(#[cause] hyper::Error),
#[fail(display = "Failed to parse a url: {}", _0)]
// TODO: print the url too
UrlError(#[cause] url::ParseError),
#[fail(display = "TLS Error: {}", _0)]
TLSError(#[cause] native_tls::Error),
#[fail(display = "IO Error: {}", _0)]
IOError(#[cause] io::Error),
#[fail(display = "RSS Error: {}", _0)]
RssError(#[cause] rss::Error),
#[fail(display = "XML Reader Error: {}", _0)]
XmlReaderError(#[cause] xml::reader::Error),
#[fail(display = "Error: {}", _0)]
Bail(String),
#[fail(display = "{}", _0)]
HttpStatusGeneral(HttpStatusError),
#[fail(display = "FIXME: This should be better")]
F301(Source),
#[fail(display = "Error occured while Parsing an Episode. Reason: {}", reason)]
ParseEpisodeError { reason: String, parent_id: i32 },
#[fail(display = "Episode was not changed and thus skipped.")]
EpisodeNotChanged,
}
impl From<RunMigrationsError> for DataError {
fn from(err: RunMigrationsError) -> Self {
DataError::DieselMigrationError(err)
}
}
impl From<diesel::result::Error> for DataError {
fn from(err: diesel::result::Error) -> Self {
DataError::DieselResultError(err)
}
}
impl From<r2d2::Error> for DataError {
fn from(err: r2d2::Error) -> Self {
DataError::R2D2Error(err)
}
}
impl From<r2d2::PoolError> for DataError {
fn from(err: r2d2::PoolError) -> Self {
DataError::R2D2PoolError(err)
}
}
impl From<hyper::Error> for DataError {
fn from(err: hyper::Error) -> Self {
DataError::HyperError(err)
}
}
impl From<url::ParseError> for DataError {
fn from(err: url::ParseError) -> Self {
DataError::UrlError(err)
}
}
impl From<native_tls::Error> for DataError {
fn from(err: native_tls::Error) -> Self {
DataError::TLSError(err)
}
}
impl From<io::Error> for DataError {
fn from(err: io::Error) -> Self {
DataError::IOError(err)
}
}
impl From<rss::Error> for DataError {
fn from(err: rss::Error) -> Self {
DataError::RssError(err)
}
}
impl From<xml::reader::Error> for DataError {
fn from(err: xml::reader::Error) -> Self {
DataError::XmlReaderError(err)
}
}
impl From<String> for DataError {
fn from(err: String) -> Self {
DataError::Bail(err)
}
}

View File

@ -1,123 +0,0 @@
#![recursion_limit = "1024"]
#![allow(unknown_lints)]
#![cfg_attr(all(test, feature = "clippy"), allow(option_unwrap_used, result_unwrap_used))]
#![cfg_attr(feature = "cargo-clippy", allow(option_map_unit_fn))]
#![cfg_attr(
feature = "clippy",
warn(
option_unwrap_used, result_unwrap_used, print_stdout, wrong_pub_self_convention, mut_mut,
non_ascii_literal, similar_names, unicode_not_nfc, enum_glob_use, if_not_else,
items_after_statements, used_underscore_binding
)
)]
// Enable lint group collections
#![warn(nonstandard_style, edition_2018, rust_2018_idioms, bad_style, unused)]
// standalone lints
#![warn(
const_err, improper_ctypes, non_shorthand_field_patterns, no_mangle_generic_items,
overflowing_literals, plugin_as_library, private_no_mangle_fns, private_no_mangle_statics,
unconditional_recursion, unions_with_drop_fields, while_true, missing_debug_implementations,
missing_docs, trivial_casts, trivial_numeric_casts, elided_lifetime_in_paths,
missing_copy_implementations
)]
#![deny(warnings)]
// warn when code is not using dyn Trait syntax. req rustc 1.27
// #![deny(bare_trait_object)]
//! FIXME: Docs
#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;
#[cfg(test)]
#[macro_use]
extern crate maplit;
#[macro_use]
extern crate derive_builder;
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate diesel_migrations;
// #[macro_use]
extern crate failure;
#[macro_use]
extern crate failure_derive;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
extern crate ammonia;
extern crate chrono;
extern crate futures;
extern crate hyper;
extern crate hyper_tls;
extern crate native_tls;
extern crate num_cpus;
extern crate rayon;
extern crate rayon_futures;
extern crate rfc822_sanitizer;
extern crate rss;
extern crate tokio_core;
extern crate url;
extern crate xdg;
extern crate xml;
pub mod database;
#[allow(missing_docs)]
pub mod dbqueries;
#[allow(missing_docs)]
pub mod errors;
mod feed;
pub(crate) mod models;
pub mod opml;
mod parser;
pub mod pipeline;
mod schema;
pub mod utils;
pub use feed::{Feed, FeedBuilder};
pub use models::Save;
pub use models::{Episode, EpisodeWidgetModel, Show, ShowCoverModel, Source};
// Set the user agent, See #53 for more
// Keep this in sync with Tor-browser releases
/// The user-agent to be used for all the requests.
/// It originates from the Tor-browser UA.
pub const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0";
/// [XDG Base Direcotory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) Paths.
#[allow(missing_debug_implementations)]
pub mod xdg_dirs {
use std::path::PathBuf;
use xdg;
lazy_static!{
pub(crate) static ref HAMMOND_XDG: xdg::BaseDirectories = {
xdg::BaseDirectories::with_prefix("hammond").unwrap()
};
/// XDG_DATA Directory `Pathbuf`.
pub static ref HAMMOND_DATA: PathBuf = {
HAMMOND_XDG.create_data_directory(HAMMOND_XDG.get_data_home()).unwrap()
};
/// XDG_CONFIG Directory `Pathbuf`.
pub static ref HAMMOND_CONFIG: PathBuf = {
HAMMOND_XDG.create_config_directory(HAMMOND_XDG.get_config_home()).unwrap()
};
/// XDG_CACHE Directory `Pathbuf`.
pub static ref HAMMOND_CACHE: PathBuf = {
HAMMOND_XDG.create_cache_directory(HAMMOND_XDG.get_cache_home()).unwrap()
};
/// Hammond Download Direcotry `PathBuf`.
pub static ref DL_DIR: PathBuf = {
HAMMOND_XDG.create_data_directory("Downloads").unwrap()
};
}
}

View File

@ -1,282 +0,0 @@
use diesel::SaveChangesDsl;
// use failure::ResultExt;
use rss::Channel;
use url::Url;
use hyper::client::HttpConnector;
use hyper::header::{
ETag, EntityTag, HttpDate, IfModifiedSince, IfNoneMatch, LastModified, Location, UserAgent,
};
use hyper::{Client, Method, Request, Response, StatusCode, Uri};
use hyper_tls::HttpsConnector;
// use futures::future::ok;
use futures::future::{loop_fn, Future, Loop};
use futures::prelude::*;
use database::connection;
use errors::*;
use feed::{Feed, FeedBuilder};
use models::{NewSource, Save};
use schema::source;
use USER_AGENT;
use std::str::FromStr;
#[derive(Queryable, Identifiable, AsChangeset, PartialEq)]
#[table_name = "source"]
#[changeset_options(treat_none_as_null = "true")]
#[derive(Debug, Clone)]
/// Diesel Model of the source table.
pub struct Source {
id: i32,
uri: String,
last_modified: Option<String>,
http_etag: Option<String>,
}
impl Save<Source> for Source {
type Error = DataError;
/// Helper method to easily save/"sync" current state of self to the
/// Database.
fn save(&self) -> Result<Source, Self::Error> {
let db = connection();
let con = db.get()?;
self.save_changes::<Source>(&con).map_err(From::from)
}
}
impl Source {
/// Get the source `id` column.
pub fn id(&self) -> i32 {
self.id
}
/// Represents the location(usually url) of the Feed xml file.
pub fn uri(&self) -> &str {
&self.uri
}
/// Set the `uri` field value.
pub fn set_uri(&mut self, uri: String) {
self.uri = uri;
}
/// Represents the Http Last-Modified Header field.
///
/// See [RFC 7231](https://tools.ietf.org/html/rfc7231#section-7.2) for more.
pub fn last_modified(&self) -> Option<&str> {
self.last_modified.as_ref().map(|s| s.as_str())
}
/// Set `last_modified` value.
pub fn set_last_modified(&mut self, value: Option<String>) {
// self.last_modified = value.map(|x| x.to_string());
self.last_modified = value;
}
/// Represents the Http Etag Header field.
///
/// See [RFC 7231](https://tools.ietf.org/html/rfc7231#section-7.2) for more.
pub fn http_etag(&self) -> Option<&str> {
self.http_etag.as_ref().map(|s| s.as_str())
}
/// Set `http_etag` value.
pub fn set_http_etag(&mut self, value: Option<&str>) {
self.http_etag = value.map(|x| x.to_string());
}
/// Extract Etag and LastModifier from res, and update self and the
/// corresponding db row.
fn update_etag(&mut self, res: &Response) -> Result<(), DataError> {
let headers = res.headers();
let etag = headers.get::<ETag>().map(|x| x.tag());
let lmod = headers.get::<LastModified>().map(|x| format!("{}", x));
if (self.http_etag() != etag) || (self.last_modified != lmod) {
self.set_http_etag(etag);
self.set_last_modified(lmod);
self.save()?;
}
Ok(())
}
fn make_err(self, context: &str, code: StatusCode) -> DataError {
DataError::HttpStatusGeneral(HttpStatusError::new(self.uri, code, context.into()))
}
// TODO match on more stuff
// 301: Moved Permanently
// 304: Up to date Feed, checked with the Etag
// 307: Temporary redirect of the url
// 308: Permanent redirect of the url
// 401: Unathorized
// 403: Forbidden
// 408: Timeout
// 410: Feed deleted
// TODO: Rething this api,
fn match_status(mut self, res: Response) -> Result<Response, DataError> {
self.update_etag(&res)?;
let code = res.status();
match code {
StatusCode::NotModified => return Err(self.make_err("304: skipping..", code)),
StatusCode::MovedPermanently => {
error!("Feed was moved permanently.");
self.handle_301(&res)?;
return Err(DataError::F301(self));
}
StatusCode::TemporaryRedirect => debug!("307: Temporary Redirect."),
StatusCode::PermanentRedirect => warn!("308: Permanent Redirect."),
StatusCode::Unauthorized => return Err(self.make_err("401: Unauthorized.", code)),
StatusCode::Forbidden => return Err(self.make_err("403: Forbidden.", code)),
StatusCode::NotFound => return Err(self.make_err("404: Not found.", code)),
StatusCode::RequestTimeout => return Err(self.make_err("408: Request Timeout.", code)),
StatusCode::Gone => return Err(self.make_err("410: Feed was deleted..", code)),
_ => info!("HTTP StatusCode: {}", code),
};
Ok(res)
}
fn handle_301(&mut self, res: &Response) -> Result<(), DataError> {
let headers = res.headers();
if let Some(url) = headers.get::<Location>() {
self.set_uri(url.to_string());
self.http_etag = None;
self.last_modified = None;
self.save()?;
info!("Feed url was updated succesfully.");
}
Ok(())
}
/// Construct a new `Source` with the given `uri` and index it.
///
/// This only indexes the `Source` struct, not the Podcast Feed.
pub fn from_url(uri: &str) -> Result<Source, DataError> {
let url = Url::parse(uri)?;
NewSource::new(&url).to_source()
}
/// `Feed` constructor.
///
/// Fetches the latest xml Feed.
///
/// Updates the validator Http Headers.
///
/// Consumes `self` and Returns the corresponding `Feed` Object.
// Refactor into TryInto once it lands on stable.
pub fn into_feed(
self,
client: Client<HttpsConnector<HttpConnector>>,
ignore_etags: bool,
) -> impl Future<Item = Feed, Error = DataError> {
let id = self.id();
let response = loop_fn(self, move |source| {
source
.request_constructor(&client.clone(), ignore_etags)
.then(|res| match res {
Ok(response) => Ok(Loop::Break(response)),
Err(err) => match err {
DataError::F301(s) => {
info!("Following redirect...");
Ok(Loop::Continue(s))
}
e => Err(e),
},
})
});
response
.and_then(response_to_channel)
.and_then(move |chan| {
FeedBuilder::default()
.channel(chan)
.source_id(id)
.build()
.map_err(From::from)
})
}
// TODO: make ignore_etags an Enum for better ergonomics.
// #bools_are_just_2variant_enmus
fn request_constructor(
self,
client: &Client<HttpsConnector<HttpConnector>>,
ignore_etags: bool,
) -> impl Future<Item = Response, Error = DataError> {
// FIXME: remove unwrap somehow
let uri = Uri::from_str(self.uri()).unwrap();
let mut req = Request::new(Method::Get, uri);
// Set the UserAgent cause ppl still seem to check it for some reason...
req.headers_mut().set(UserAgent::new(USER_AGENT));
if !ignore_etags {
if let Some(etag) = self.http_etag() {
let tag = vec![EntityTag::new(true, etag.to_owned())];
req.headers_mut().set(IfNoneMatch::Items(tag));
}
if let Some(lmod) = self.last_modified() {
if let Ok(date) = lmod.parse::<HttpDate>() {
req.headers_mut().set(IfModifiedSince(date));
}
}
}
client
.request(req)
.map_err(From::from)
.and_then(move |res| self.match_status(res))
}
}
#[allow(needless_pass_by_value)]
fn response_to_channel(res: Response) -> impl Future<Item = Channel, Error = DataError> + Send {
res.body()
.concat2()
.map(|x| x.into_iter())
.map_err(From::from)
.map(|iter| iter.collect::<Vec<u8>>())
.map(|utf_8_bytes| String::from_utf8_lossy(&utf_8_bytes).into_owned())
.and_then(|buf| Channel::from_str(&buf).map_err(From::from))
}
#[cfg(test)]
mod tests {
use super::*;
use tokio_core::reactor::Core;
use database::truncate_db;
use utils::get_feed;
#[test]
fn test_into_feed() {
truncate_db().unwrap();
let mut core = Core::new().unwrap();
let client = Client::configure()
.connector(HttpsConnector::new(4, &core.handle()).unwrap())
.build(&core.handle());
let url = "https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\
com/InterceptedWithJeremyScahill";
let source = Source::from_url(url).unwrap();
let id = source.id();
let feed = source.into_feed(client, true);
let feed = core.run(feed).unwrap();
let expected = get_feed("tests/feeds/2018-01-20-Intercepted.xml", id);
assert_eq!(expected, feed);
}
}

View File

@ -1,167 +0,0 @@
//! FIXME: Docs
// #![allow(unused)]
use errors::DataError;
use models::Source;
use xml::reader;
use std::collections::HashSet;
use std::fs;
use std::io::Read;
use std::path::Path;
// use std::fs::{File, OpenOptions};
// use std::io::BufReader;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
// FIXME: Make it a Diesel model
/// Represents an `outline` xml element as per the `OPML` [specification][spec]
/// not `RSS` related sub-elements are ommited.
///
/// [spec]: http://dev.opml.org/spec2.html
pub struct Opml {
title: String,
description: String,
url: String,
}
/// Import feed url's from a `R` into the `Source` table.
// TODO: Write test
pub fn import_to_db<R: Read>(reader: R) -> Result<Vec<Source>, reader::Error> {
let feeds = extract_sources(reader)?
.iter()
.map(|opml| Source::from_url(&opml.url))
.filter_map(|s| {
if let Err(ref err) = s {
let txt = "If you think this might be a bug please consider filling a report over \
at https://gitlab.gnome.org/World/hammond/issues/new";
error!("Failed to import a Show: {}", err);
error!("{}", txt);
}
s.ok()
})
.collect();
Ok(feeds)
}
/// Open a File from `P`, try to parse the OPML then insert the Feeds in the database and
/// return the new `Source`s
// TODO: Write test
pub fn import_from_file<P: AsRef<Path>>(path: P) -> Result<Vec<Source>, DataError> {
let content = fs::read(path)?;
import_to_db(content.as_slice()).map_err(From::from)
}
/// Extracts the `outline` elemnts from a reader `R` and returns a `HashSet` of `Opml` structs.
pub fn extract_sources<R: Read>(reader: R) -> Result<HashSet<Opml>, reader::Error> {
let mut list = HashSet::new();
let parser = reader::EventReader::new(reader);
parser
.into_iter()
.map(|e| match e {
Ok(reader::XmlEvent::StartElement {
name, attributes, ..
}) => {
if name.local_name == "outline" {
let mut title = String::new();
let mut url = String::new();
let mut description = String::new();
attributes.into_iter().for_each(|attribute| {
match attribute.name.local_name.as_str() {
"title" => title = attribute.value,
"xmlUrl" => url = attribute.value,
"description" => description = attribute.value,
_ => {}
}
});
let feed = Opml {
title,
description,
url,
};
list.insert(feed);
}
Ok(())
}
Err(err) => Err(err),
_ => Ok(()),
})
.collect::<Result<Vec<_>, reader::Error>>()?;
Ok(list)
}
#[cfg(test)]
mod tests {
use super::*;
use chrono::Local;
#[test]
fn test_extract() {
let int_title = String::from("Intercepted with Jeremy Scahill");
let int_url = String::from("https://feeds.feedburner.com/InterceptedWithJeremyScahill");
let int_desc =
String::from(
"The people behind The Intercepts fearless reporting and incisive \
commentaryJeremy Scahill, Glenn Greenwald, Betsy Reed and othersdiscuss the \
crucial issues of our time: national security, civil liberties, foreign policy, \
and criminal justice. Plus interviews with artists, thinkers, and newsmakers \
who challenge our preconceptions about the world we live in.",
);
let dec_title = String::from("Deconstructed with Mehdi Hasan");
let dec_url = String::from("https://rss.prod.firstlook.media/deconstructed/podcast.rss");
let dec_desc = String::from(
"Journalist Mehdi Hasan is known around the world for his televised takedowns of \
presidents and prime ministers. In this new podcast from The Intercept, Mehdi \
unpacks a game-changing news event of the week while challenging the conventional \
wisdom. As a Brit, a Muslim and an immigrant based in Donald Trump's Washington \
D.C., Mehdi gives a refreshingly provocative perspective on the ups and downs of \
Americanand globalpolitics.",
);
#[cfg_attr(rustfmt, rustfmt_skip)]
let sample1 = format!(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?> \
<opml version=\"2.0\"> \
<head> \
<title>Test OPML File</title> \
<dateCreated>{}</dateCreated> \
<docs>http://www.opml.org/spec2</docs> \
</head> \
<body> \
<outline type=\"rss\" title=\"{}\" description=\"{}\" xmlUrl=\"{}\"/> \
<outline type=\"rss\" title=\"{}\" description=\"{}\" xmlUrl=\"{}\"/> \
</body> \
</opml>",
Local::now().format("%a, %d %b %Y %T %Z"),
int_title,
int_desc,
int_url,
dec_title,
dec_desc,
dec_url,
);
let map = hashset![
Opml {
title: int_title,
description: int_desc,
url: int_url
},
Opml {
title: dec_title,
description: dec_desc,
url: dec_url
},
];
assert_eq!(extract_sources(sample1.as_bytes()).unwrap(), map);
}
}

View File

@ -1,128 +0,0 @@
// FIXME:
//! Docs.
use futures::future::*;
use futures::prelude::*;
use futures::stream::*;
use hyper::client::HttpConnector;
use hyper::Client;
use hyper_tls::HttpsConnector;
use tokio_core::reactor::Core;
use num_cpus;
use rayon;
use rayon_futures::ScopeFutureExt;
use errors::DataError;
use Source;
// use std::sync::{Arc, Mutex};
// http://gtk-rs.org/tuto/closures
#[macro_export]
macro_rules! clone {
(@param _) => ( _ );
(@param $x:ident) => ( $x );
($($n:ident),+ => move || $body:expr) => (
{
$( let $n = $n.clone(); )+
move || $body
}
);
($($n:ident),+ => move |$($p:tt),+| $body:expr) => (
{
$( let $n = $n.clone(); )+
move |$(clone!(@param $p),)+| $body
}
);
}
type HttpsClient = Client<HttpsConnector<HttpConnector>>;
/// The pipline to be run for indexing and updating a Podcast feed that originates from
/// `Source.uri`.
///
/// Messy temp diagram:
/// Source -> GET Request -> Update Etags -> Check Status -> Parse `xml/Rss` ->
/// Convert `rss::Channel` into `Feed` -> Index Podcast -> Index Episodes.
pub fn pipeline<'a, S>(
sources: S,
ignore_etags: bool,
client: &HttpsClient,
) -> impl Future<Item = Vec<()>, Error = DataError> + 'a
where
S: Stream<Item = Source, Error = DataError> + 'a,
{
sources
.and_then(clone!(client => move |s| s.into_feed(client.clone(), ignore_etags)))
.and_then(|feed| rayon::scope(|s| s.spawn_future(feed.index())))
// the stream will stop at the first error so
// we ensure that everything will succeded regardless.
.map_err(|err| error!("Error: {}", err))
.then(|_| ok::<(), DataError>(()))
.collect()
}
/// Creates a tokio `reactor::Core`, and a `hyper::Client` and
/// runs the pipeline to completion. The `reactor::Core` is dropped afterwards.
pub fn run<S>(sources: S, ignore_etags: bool) -> Result<(), DataError>
where
S: IntoIterator<Item = Source>,
{
let mut core = Core::new()?;
let handle = core.handle();
let client = Client::configure()
.connector(HttpsConnector::new(num_cpus::get(), &handle)?)
.build(&handle);
let stream = iter_ok::<_, DataError>(sources);
let p = pipeline(stream, ignore_etags, &client);
core.run(p).map(|_| ())
}
#[cfg(test)]
mod tests {
use super::*;
use database::truncate_db;
use dbqueries;
use Source;
// (path, url) tuples.
const URLS: &[&str] = &[
"https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\
com/InterceptedWithJeremyScahill",
"https://web.archive.org/web/20180120110314if_/https://feeds.feedburner.com/linuxunplugged",
"https://web.archive.org/web/20180120110727if_/https://rss.acast.com/thetipoff",
"https://web.archive.org/web/20180120104957if_/https://rss.art19.com/steal-the-stars",
"https://web.archive.org/web/20180120104741if_/https://www.greaterthancode.\
com/feed/podcast",
];
#[test]
/// Insert feeds and update/index them.
fn test_pipeline() {
truncate_db().unwrap();
let bad_url = "https://gitlab.gnome.org/World/hammond.atom";
// if a stream returns error/None it stops
// bad we want to parse all feeds regardless if one fails
Source::from_url(bad_url).unwrap();
URLS.iter().for_each(|url| {
// Index the urls into the source table.
Source::from_url(url).unwrap();
});
let sources = dbqueries::get_sources().unwrap();
run(sources, true).unwrap();
let sources = dbqueries::get_sources().unwrap();
// Run again to cover Unique constrains erros.
run(sources, true).unwrap();
// Assert the index rows equal the controlled results
assert_eq!(dbqueries::get_sources().unwrap().len(), 6);
assert_eq!(dbqueries::get_podcasts().unwrap().len(), 5);
assert_eq!(dbqueries::get_episodes().unwrap().len(), 354);
}
}

View File

@ -1,22 +0,0 @@
[package]
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
name = "hammond-downloader"
version = "0.1.0"
workspace = "../"
[dependencies]
error-chain = "0.12.0"
hyper = "0.11.27"
log = "0.4.2"
mime_guess = "1.8.4"
reqwest = "0.8.6"
tempdir = "0.3.7"
glob = "0.2.11"
failure = "0.1.1"
failure_derive = "0.1.1"
[dependencies.hammond-data]
path = "../hammond-data"
[dev-dependencies]
pretty_assertions = "0.5.1"

View File

@ -1,41 +0,0 @@
use hammond_data::errors::DataError;
use reqwest;
use std::io;
#[derive(Fail, Debug)]
pub enum DownloadError {
#[fail(display = "Reqwest error: {}", _0)]
RequestError(#[cause] reqwest::Error),
#[fail(display = "Data error: {}", _0)]
DataError(#[cause] DataError),
#[fail(display = "Io error: {}", _0)]
IoError(#[cause] io::Error),
#[fail(display = "Unexpected server response: {}", _0)]
UnexpectedResponse(reqwest::StatusCode),
#[fail(display = "The Download was cancelled.")]
DownloadCancelled,
#[fail(display = "Remote Image location not found.")]
NoImageLocation,
#[fail(display = "Failed to parse CacheLocation.")]
InvalidCacheLocation,
#[fail(display = "Failed to parse Cached Image Location.")]
InvalidCachedImageLocation,
}
impl From<reqwest::Error> for DownloadError {
fn from(err: reqwest::Error) -> Self {
DownloadError::RequestError(err)
}
}
impl From<io::Error> for DownloadError {
fn from(err: io::Error) -> Self {
DownloadError::IoError(err)
}
}
impl From<DataError> for DownloadError {
fn from(err: DataError) -> Self {
DownloadError::DataError(err)
}
}

View File

@ -1,33 +0,0 @@
#![recursion_limit = "1024"]
#![allow(unknown_lints)]
#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name, option_map_unit_fn))]
// Enable lint group collections
#![warn(nonstandard_style, edition_2018, rust_2018_idioms, bad_style, unused)]
// standalone lints
#![warn(
const_err, improper_ctypes, non_shorthand_field_patterns, no_mangle_generic_items,
overflowing_literals, plugin_as_library, private_no_mangle_fns, private_no_mangle_statics,
unconditional_recursion, unions_with_drop_fields, while_true, missing_debug_implementations,
trivial_casts, trivial_numeric_casts, elided_lifetime_in_paths, missing_copy_implementations
)]
#![deny(warnings)]
extern crate failure;
#[macro_use]
extern crate failure_derive;
#[macro_use]
extern crate log;
#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;
extern crate glob;
extern crate hammond_data;
extern crate hyper;
extern crate mime_guess;
extern crate reqwest;
extern crate tempdir;
pub mod downloader;
pub mod errors;

View File

@ -1,46 +0,0 @@
[package]
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
build = "build.rs"
name = "hammond-gtk"
version = "0.1.0"
workspace = "../"
[dependencies]
chrono = "0.4.4"
crossbeam-channel = "0.2.1"
gdk = "0.8.0"
gdk-pixbuf = "0.4.0"
glib = "0.5.0"
gstreamer = "0.11.3"
gstreamer-player = "0.11.3"
humansize = "1.1.0"
lazy_static = "1.0.1"
log = "0.4.2"
loggerv = "0.7.1"
open = "1.2.1"
rayon = "1.0.1"
send-cell = "0.1.3"
url = "1.7.0"
failure = "0.1.1"
failure_derive = "0.1.1"
regex = "1.0.1"
reqwest = "0.8.6"
serde_json = "1.0.22"
html2text = "0.1.7"
[dependencies.gtk]
features = ["v3_22"]
version = "0.4.1"
[dependencies.gio]
features = ["v2_50"]
version = "0.4.1"
[dependencies.hammond-data]
path = "../hammond-data"
[dependencies.hammond-downloader]
path = "../hammond-downloader"
[dev-dependencies]
pretty_assertions = "0.5.1"

View File

@ -1,13 +0,0 @@
use std::process::Command;
fn main() {
// Rerun the build script when files in the resources folder are changed.
println!("cargo:rerun-if-changed=resources");
println!("cargo:rerun-if-changed=resources/*");
Command::new("glib-compile-resources")
.args(&["--generate", "resources.xml"])
.current_dir("resources")
.status()
.unwrap();
}

View File

@ -1,63 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkBox" id="empty_show">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">128</property>
<property name="icon_name">application-rss+xml-symbolic</property>
<property name="use_fallback">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">This show does not have any episodes</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.4399999999999999"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">If you think this is an Error, Plese consider opening a bug report.</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>

View File

@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.21.0
Copyright (C) 2017 - 2018
This file is part of Hammond.
Hammond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hammond is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Hammond. If not, see <http://www.gnu.org/licenses/>.
Authors:
Jordan Petridis
Tobias Bernard
-->
<interface>
<requires lib="gtk+" version="3.20"/>
<!-- interface-license-type gplv3 -->
<!-- interface-name Hammond -->
<!-- interface-description A podcast client for the GNOME Desktop -->
<!-- interface-copyright 2017 - 2018 -->
<!-- interface-authors Jordan Petridis\nTobias Bernard -->
<object class="GtkBox" id="empty_view">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">128</property>
<property name="icon_name">application-rss+xml-symbolic</property>
<property name="use_fallback">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">No Feed Subscription Found</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.4399999999999999"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">You can subscribe to feeds using the "+" button</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>

View File

@ -1,399 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0
Copyright (C) 2017 - 2018
This file is part of Hammond.
Hammond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hammond is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Hammond. If not, see <http://www.gnu.org/licenses/>.
Authors:
Jordan Petridis
Tobias Bernard
-->
<interface>
<requires lib="gtk+" version="3.20"/>
<!-- interface-license-type gplv3 -->
<!-- interface-name Hammond -->
<!-- interface-description A podcast client for the GNOME Desktop -->
<!-- interface-copyright 2017 - 2018 -->
<!-- interface-authors Jordan Petridis\nTobias Bernard -->
<object class="GtkBox" id="container">
<property name="name">container</property>
<property name="width_request">400</property>
<property name="height_request">600</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="name">scrolled_window</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="frame_parent">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">32</property>
<property name="margin_right">32</property>
<property name="margin_top">32</property>
<property name="margin_bottom">32</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">24</property>
<child>
<object class="GtkBox" id="today_box">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Today</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.5"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox" id="today_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="selection_mode">none</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="yday_box">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Yesterday</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.5"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox" id="yday_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="selection_mode">none</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="week_box">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">This Week</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.5"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox" id="week_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="selection_mode">none</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="month_box">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">This Month</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.5"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox" id="month_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="selection_mode">none</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox" id="rest_box">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Older</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.5"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox" id="rest_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="selection_mode">none</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</interface>

View File

@ -1,372 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="ff_image">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="margin_top">1</property>
<property name="icon_name">media-seek-forward-symbolic</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="pause_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">1</property>
<property name="icon_name">media-playback-pause-symbolic</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="play_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">1</property>
<property name="icon_name">media-playback-start-symbolic</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="previous_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">1</property>
<property name="icon_name">media-seek-backward-symbolic</property>
<property name="icon_size">1</property>
</object>
<object class="GtkActionBar" id="action_bar">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="valign">center</property>
<child>
<object class="GtkBox" id="buttons">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<child>
<object class="GtkButton" id="rewind_button">
<property name="width_request">42</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Previous</property>
<property name="image">previous_image</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="play_button">
<property name="width_request">60</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Play</property>
<property name="image">play_image</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="pause_button">
<property name="width_request">60</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Play</property>
<property name="image">pause_image</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ff_button">
<property name="width_request">42</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Next</property>
<property name="image">ff_image</property>
<property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="info">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="show_cover">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="pixel_size">34</property>
<property name="icon_name">image-x-generic-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="show_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Show Title</property>
<property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">20</property>
<style>
<class name="player-show-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="episode_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Episode Title</property>
<property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">20</property>
<style>
<class name="player-episode-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScale" id="seek">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="round_digits">1</property>
<property name="draw_value">False</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="timer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="progress_time_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="label">0:00</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="separator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="label">/</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="total_duration_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="label">0:00</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="rate_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_left">6</property>
<property name="direction">up</property>
<property name="popover">rate_popover</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="rate_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">1.00x</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-down-symbolic</property>
<property name="icon_size">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
</object>
<object class="GtkPopover" id="rate_popover">
<property name="can_focus">False</property>
<property name="relative_to">rate_button</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkRadioButton" id="rate_1_50">
<property name="label" translatable="yes">1.50x</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="draw_indicator">True</property>
<property name="group">normal_rate</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="rate_1_25">
<property name="label" translatable="yes">1.25x</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="draw_indicator">True</property>
<property name="group">normal_rate</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="normal_rate">
<property name="label" translatable="yes">1.00x</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1,300 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0
Copyright (C) 2017 - 2018
This file is part of Hammond.
Hammond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hammond is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Hammond. If not, see <http://www.gnu.org/licenses/>.
Authors:
Jordan Petridis
Tobias Bernard
-->
<interface domain="">
<requires lib="gtk+" version="3.20"/>
<!-- interface-license-type gplv3 -->
<!-- interface-name Hammond -->
<!-- interface-description A podcast client for the GNOME Desktop -->
<!-- interface-copyright 2017 - 2018 -->
<!-- interface-authors Jordan Petridis\nTobias Bernard -->
<object class="GtkBox" id="container">
<property name="width_request">400</property>
<property name="height_request">600</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="name">scrolled_window</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="hscrollbar_policy">never</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_default">True</property>
<property name="hexpand">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">32</property>
<property name="margin_right">32</property>
<property name="margin_top">32</property>
<property name="margin_bottom">32</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">24</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="cover">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">256</property>
<property name="icon_name">image-x-generic-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="min_content_height">80</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkLabel" id="description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="label">This is embarrasing!
Sorry, we could not find a description for this Show.</property>
<property name="use_markup">True</property>
<property name="justify">center</property>
<property name="wrap">True</property>
<property name="max_width_chars">70</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkMenuButton" id="settings_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon_name">emblem-system-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="link_button">
<property name="label" translatable="yes">Website</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="unsub_button">
<property name="label" translatable="yes">Unsubscribe</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<style>
<class name="destructive-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox" id="episodes">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<object class="GtkPopover" id="show_menu">
<property name="can_focus">False</property>
<property name="position">bottom</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton" id="mark_all_watched">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="text" translatable="yes">Mark all episodes as listened</property>
<property name="centered">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0
Copyright (C) 2017 - 2018
This file is part of Hammond.
Hammond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hammond is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Hammond. If not, see <http://www.gnu.org/licenses/>.
Authors:
Jordan Petridis
Tobias Bernard
-->
<interface>
<requires lib="gtk+" version="3.20"/>
<!-- interface-license-type gplv3 -->
<!-- interface-name Hammond -->
<!-- interface-description A podcast client for the GNOME Desktop -->
<!-- interface-copyright 2017 - 2018 -->
<!-- interface-authors Jordan Petridis\nTobias Bernard -->
<object class="GtkBox" id="fb_child">
<property name="width_request">256</property>
<property name="height_request">256</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="pd_cover">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="pixel_size">256</property>
<property name="icon_name">image-x-generic-symbolic</property>
<property name="icon_size">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</interface>

View File

@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.21.0
Copyright (C) 2017 - 2018
This file is part of Hammond.
Hammond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hammond is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Hammond. If not, see <http://www.gnu.org/licenses/>.
Authors:
Jordan Petridis
Tobias Bernard
-->
<interface>
<requires lib="gtk+" version="3.20"/>
<!-- interface-license-type gplv3 -->
<!-- interface-name Hammond -->
<!-- interface-description A podcast client for the GNOME Desktop -->
<!-- interface-copyright 2017 - 2018 -->
<!-- interface-authors Jordan Petridis\nTobias Bernard -->
<object class="GtkBox" id="fb_parent">
<property name="name">fb_parent</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="name">scrolled_window</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkFlowBox" id="flowbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">start</property>
<property name="margin_top">24</property>
<property name="margin_bottom">24</property>
<property name="homogeneous">True</property>
<property name="column_spacing">12</property>
<property name="row_spacing">12</property>
<property name="max_children_per_line">20</property>
<property name="selection_mode">none</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</interface>

View File

@ -1,20 +0,0 @@
row {
border-bottom: solid 1px rgba(0,0,0, 0.1);
}
row:last-child {
border-bottom: none;
}
list, border {
border-radius: 4px;
}
.player-episode-label {
font-weight: bold;
font-size: smaller;
}
.player-show-label {
font-size: smaller;
}

View File

@ -1,6 +0,0 @@
# subdir('icons')
install_data('org.gnome.Hammond.desktop', install_dir : datadir + '/applications')
install_data('org.gnome.Hammond.appdata.xml', install_dir : datadir + '/appdata')
install_data('org.gnome.Hammond.gschema.xml', install_dir: join_paths(datadir, 'glib-2.0', 'schemas'))
meson.add_install_script('../../scripts/compile-gschema.py')

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.gnome.Hammond</id>
<name>Hammond</name>
<project_license>GPL-3.0</project_license>
<metadata_license>CC0-1.0</metadata_license>
<developer_name>Jordan Petridis</developer_name>
<summary>Modern Podcast application for the GNOME desktop</summary>
<description xml:lang="en">
<p>
Hammond is a modern, reliable, and fast Podcast application for the GNOME
desktop written in Rust.
</p>
</description>
<url type="homepage">https://gitlab.gnome.org/World/hammond</url>
<screenshots>
<screenshot>
<image>https://gitlab.gnome.org/World/hammond/raw/master/screenshots/episodes_view.png</image>
<caption>Page 1</caption>
</screenshot>
<screenshot>
<image>https://gitlab.gnome.org/World/hammond/raw/master/screenshots/shows_view.png</image>
<caption>Page 2</caption>
</screenshot>
<screenshot>
<image>https://gitlab.gnome.org/World/hammond/raw/master/screenshots/show_widget.png</image>
<caption>Page 3</caption>
</screenshot>
</screenshots>
<releases>
<release version="0.4.0" date="2018-07-04"/>
</releases>
<url type="homepage">https://gitlab.gnome.org/World/hammond</url>
<update_contact>jpetridis@gnome.org</update_contact>
<developer_name>Jordan Petridis and others</developer_name>
</component>

View File

@ -1,11 +0,0 @@
[Desktop Entry]
Name=Hammond
GenericName=Podcast Client
Comment=Play, Subscribe and Manage Podcast Feeds.
Icon=multimedia-player
Exec=hammond
Terminal=false
Type=Application
StartupNotify=true
Categories=AudioVideo;Audio;Video;
Keywords=Podcast

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/Hammond/">
<file compressed="true" preprocess="xml-stripblanks">gtk/episode_widget.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/show_widget.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/empty_view.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/empty_show.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/episodes_view.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/episodes_view_widget.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/shows_view.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/shows_child.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/headerbar.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/inapp_notif.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/menus.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file compressed="true" preprocess="xml-stripblanks">gtk/player_toolbar.ui</file>
<file compressed="true">gtk/style.css</file>
</gresource>
</gresources>

View File

@ -1,299 +0,0 @@
#![allow(new_without_default)]
use gio::{
self, ActionMapExt, ApplicationExt, ApplicationExtManual, ApplicationFlags, SettingsExt,
SimpleAction, SimpleActionExt,
};
use glib;
use gtk;
use gtk::prelude::*;
use gtk::SettingsExt as GtkSettingsExt;
use crossbeam_channel::{unbounded, Receiver, Sender};
use hammond_data::Show;
use headerbar::Header;
use settings::{self, WindowGeometry};
use stacks::{Content, PopulatedState};
use utils;
use widgets::appnotif::{InAppNotification, UndoState};
use widgets::player;
use widgets::{about_dialog, mark_all_notif, remove_show_notif};
use std::rc::Rc;
use std::sync::Arc;
/// Creates an action named $called in the action map $on with the handler $handle
macro_rules! action {
($on:expr, $called:expr, $handle:expr) => {{
// Create a stateless, parameterless action
let act = SimpleAction::new($called, None);
// Connect the handler
act.connect_activate($handle);
// Add it to the map
$on.add_action(&act);
// Return the action
act
}};
}
#[derive(Debug, Clone)]
pub enum Action {
RefreshAllViews,
RefreshEpisodesView,
RefreshEpisodesViewBGR,
RefreshShowsView,
ReplaceWidget(Arc<Show>),
RefreshWidgetIfSame(i32),
ShowWidgetAnimated,
ShowShowsAnimated,
HeaderBarShowTile(String),
HeaderBarNormal,
HeaderBarShowUpdateIndicator,
HeaderBarHideUpdateIndicator,
MarkAllPlayerNotification(Arc<Show>),
RemoveShow(Arc<Show>),
ErrorNotification(String),
InitEpisode(i32),
}
#[derive(Debug, Clone)]
pub struct App {
instance: gtk::Application,
window: gtk::ApplicationWindow,
overlay: gtk::Overlay,
settings: gio::Settings,
content: Rc<Content>,
headerbar: Rc<Header>,
player: Rc<player::PlayerWidget>,
sender: Sender<Action>,
receiver: Receiver<Action>,
}
impl App {
pub fn new(application: &gtk::Application) -> Rc<Self> {
let settings = gio::Settings::new("org.gnome.Hammond");
let (sender, receiver) = unbounded();
let window = gtk::ApplicationWindow::new(application);
window.set_title("Hammond");
window.connect_delete_event(clone!(application, settings => move |window, _| {
WindowGeometry::from_window(&window).write(&settings);
application.quit();
Inhibit(false)
}));
// Create a content instance
let content = Content::new(&sender).expect("Content Initialization failed.");
// Create the headerbar
let header = Header::new(&content, &sender);
// Add the Headerbar to the window.
window.set_titlebar(&header.container);
// Add the content main stack to the overlay.
let overlay = gtk::Overlay::new();
overlay.add(&content.get_stack());
let wrap = gtk::Box::new(gtk::Orientation::Vertical, 0);
// Add the overlay to the main Box
wrap.add(&overlay);
let player = player::PlayerWidget::new(&sender);
// Add the player to the main Box
wrap.add(&player.action_bar);
window.add(&wrap);
let app = App {
instance: application.clone(),
window,
settings,
overlay,
headerbar: header,
content,
player,
sender,
receiver,
};
Rc::new(app)
}
fn init(app: &Rc<Self>) {
let cleanup_date = settings::get_cleanup_date(&app.settings);
// Garbage collect watched episodes from the disk
utils::cleanup(cleanup_date);
app.setup_gactions();
app.setup_timed_callbacks();
app.instance.connect_activate(move |_| ());
// Retrieve the previous window position and size.
WindowGeometry::from_settings(&app.settings).apply(&app.window);
// Setup the Action channel
gtk::timeout_add(25, clone!(app => move || app.setup_action_channel()));
}
fn setup_timed_callbacks(&self) {
self.setup_dark_theme();
self.setup_refresh_on_startup();
self.setup_auto_refresh();
}
fn setup_dark_theme(&self) {
let gtk_settings = gtk::Settings::get_default().unwrap();
let enabled = self.settings.get_boolean("dark-theme");
gtk_settings.set_property_gtk_application_prefer_dark_theme(enabled);
}
fn setup_refresh_on_startup(&self) {
// Update the feeds right after the Application is initialized.
let sender = self.sender.clone();
if self.settings.get_boolean("refresh-on-startup") {
info!("Refresh on startup.");
// The ui loads async, after initialization
// so we need to delay this a bit so it won't block
// requests that will come from loading the gui on startup.
gtk::timeout_add(1500, move || {
let s: Option<Vec<_>> = None;
utils::refresh(s, sender.clone());
glib::Continue(false)
});
}
}
fn setup_auto_refresh(&self) {
let refresh_interval = settings::get_refresh_interval(&self.settings).num_seconds() as u32;
info!("Auto-refresh every {:?} seconds.", refresh_interval);
let sender = self.sender.clone();
gtk::timeout_add_seconds(refresh_interval, move || {
let s: Option<Vec<_>> = None;
utils::refresh(s, sender.clone());
glib::Continue(true)
});
}
/// Define the `GAction`s.
///
/// Used in menus and the keyboard shortcuts dialog.
#[cfg_attr(rustfmt, rustfmt_skip)]
fn setup_gactions(&self) {
let sender = &self.sender;
let win = &self.window;
let instance = &self.instance;
let header = &self.headerbar;
// Create the `refresh` action.
//
// This will trigger a refresh of all the shows in the database.
action!(win, "refresh", clone!(sender => move |_, _| {
gtk::idle_add(clone!(sender => move || {
let s: Option<Vec<_>> = None;
utils::refresh(s, sender.clone());
glib::Continue(false)
}));
}));
self.instance.set_accels_for_action("win.refresh", &["<primary>r"]);
// Create the `OPML` import action
action!(win, "import", clone!(sender, win => move |_, _| {
utils::on_import_clicked(&win, &sender)
}));
// Create the action that shows a `gtk::AboutDialog`
action!(win, "about", clone!(win => move |_, _| about_dialog(&win)));
// Create the quit action
action!(win, "quit", clone!(instance => move |_, _| instance.quit()));
self.instance.set_accels_for_action("win.quit", &["<primary>q"]);
// Create the menu action
action!(win, "menu",clone!(header => move |_, _| header.open_menu()));
// Bind the hamburger menu button to `F10`
self.instance.set_accels_for_action("win.menu", &["F10"]);
}
fn setup_action_channel(&self) -> glib::Continue {
if let Some(action) = self.receiver.try_recv() {
trace!("Incoming channel action: {:?}", action);
match action {
Action::RefreshAllViews => self.content.update(),
Action::RefreshShowsView => self.content.update_shows_view(),
Action::RefreshWidgetIfSame(id) => self.content.update_widget_if_same(id),
Action::RefreshEpisodesView => self.content.update_home(),
Action::RefreshEpisodesViewBGR => self.content.update_home_if_background(),
Action::ReplaceWidget(pd) => {
let shows = self.content.get_shows();
let mut pop = shows.borrow().populated();
pop.borrow_mut()
.replace_widget(pd.clone())
.map_err(|err| error!("Failed to update ShowWidget: {}", err))
.map_err(|_| error!("Failed ot update ShowWidget {}", pd.title()))
.ok();
}
Action::ShowWidgetAnimated => {
let shows = self.content.get_shows();
let mut pop = shows.borrow().populated();
pop.borrow_mut().switch_visible(
PopulatedState::Widget,
gtk::StackTransitionType::SlideLeft,
);
}
Action::ShowShowsAnimated => {
let shows = self.content.get_shows();
let mut pop = shows.borrow().populated();
pop.borrow_mut()
.switch_visible(PopulatedState::View, gtk::StackTransitionType::SlideRight);
}
Action::HeaderBarShowTile(title) => self.headerbar.switch_to_back(&title),
Action::HeaderBarNormal => self.headerbar.switch_to_normal(),
Action::HeaderBarShowUpdateIndicator => self.headerbar.show_update_notification(),
Action::HeaderBarHideUpdateIndicator => self.headerbar.hide_update_notification(),
Action::MarkAllPlayerNotification(pd) => {
let notif = mark_all_notif(pd, &self.sender);
notif.show(&self.overlay);
}
Action::RemoveShow(pd) => {
let notif = remove_show_notif(pd, self.sender.clone());
notif.show(&self.overlay);
}
Action::ErrorNotification(err) => {
error!("An error notification was triggered: {}", err);
let callback = || glib::Continue(false);
let notif = InAppNotification::new(&err, callback, || {}, UndoState::Hidden);
notif.show(&self.overlay);
}
Action::InitEpisode(rowid) => self.player.initialize_episode(rowid).unwrap(),
}
}
glib::Continue(true)
}
pub fn run() {
let application = gtk::Application::new("org.gnome.Hammond", ApplicationFlags::empty())
.expect("Application Initialization failed...");
application.connect_startup(clone!(application => move |_| {
info!("CONNECT STARTUP RUN");
let app = Self::new(&application);
Self::init(&app);
app.window.show_all();
app.window.activate();
}));
// Weird magic I copy-pasted that sets the Application Name in the Shell.
glib::set_application_name("Hammond");
glib::set_prgname(Some("Hammond"));
// We need out own org.gnome.Hammon icon
gtk::Window::set_default_icon_name("multimedia-player");
ApplicationExtManual::run(&application, &[]);
}
}

View File

@ -1,258 +0,0 @@
use gio::MenuModel;
use gtk;
use gtk::prelude::*;
use crossbeam_channel::Sender;
use failure::Error;
use rayon;
use url::Url;
use hammond_data::{dbqueries, Source};
use app::Action;
use stacks::Content;
use utils::{itunes_to_rss, refresh};
use std::rc::Rc;
#[derive(Debug, Clone)]
// TODO: Factor out the hamburger menu
// TODO: Make a proper state machine for the headerbar states
pub struct Header {
pub container: gtk::HeaderBar,
switch: gtk::StackSwitcher,
back: gtk::Button,
show_title: gtk::Label,
menu_button: gtk::MenuButton,
app_menu: MenuModel,
updater: UpdateIndicator,
add: AddPopover,
}
#[derive(Debug, Clone)]
struct UpdateIndicator {
container: gtk::Box,
text: gtk::Label,
spinner: gtk::Spinner,
}
impl UpdateIndicator {
fn show(&self) {
self.spinner.start();
self.spinner.show();
self.container.show();
self.text.show();
}
fn hide(&self) {
self.spinner.stop();
self.spinner.hide();
self.container.hide();
self.text.hide();
}
}
#[derive(Debug, Clone)]
struct AddPopover {
container: gtk::Popover,
result: gtk::Label,
entry: gtk::Entry,
add: gtk::Button,
toggle: gtk::MenuButton,
}
impl AddPopover {
// FIXME: THIS ALSO SUCKS!
fn on_add_clicked(&self, sender: &Sender<Action>) -> Result<(), Error> {
let url = self
.entry
.get_text()
.ok_or_else(|| format_err!("GtkEntry blew up somehow."))?;
debug!("Url: {}", url);
let url = if url.contains("itunes.com") || url.contains("apple.com") {
info!("Detected itunes url.");
let foo = itunes_to_rss(&url)?;
info!("Resolved to {}", foo);
foo
} else {
url.to_owned()
};
self.entry.set_text("");
rayon::spawn(clone!(sender => move || {
if let Ok(source) = Source::from_url(&url) {
refresh(Some(vec![source]), sender.clone());
} else {
error!("Failed to convert, url: {}, to a source entry", url);
}
}));
self.container.hide();
Ok(())
}
// FIXME: THIS SUCKS! REFACTOR ME.
fn on_entry_changed(&self) -> Result<(), Error> {
let uri = self
.entry
.get_text()
.ok_or_else(|| format_err!("GtkEntry blew up somehow."))?;
debug!("Url: {}", uri);
let url = Url::parse(&uri);
// TODO: refactor to avoid duplication
match url {
Ok(u) => {
if !dbqueries::source_exists(u.as_str())? {
self.add.set_sensitive(true);
self.result.hide();
self.result.set_label("");
} else {
self.add.set_sensitive(false);
self.result.set_label("Show already exists.");
self.result.show();
}
Ok(())
}
Err(err) => {
self.add.set_sensitive(false);
if !uri.is_empty() {
self.result.set_label("Invalid url.");
self.result.show();
error!("Error: {}", err);
} else {
self.result.hide();
}
Ok(())
}
}
}
}
impl Default for Header {
fn default() -> Header {
let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/headerbar.ui");
let menus = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/menus.ui");
let header = builder.get_object("headerbar").unwrap();
let switch = builder.get_object("switch").unwrap();
let back = builder.get_object("back").unwrap();
let show_title = builder.get_object("show_title").unwrap();
let menu_button = builder.get_object("menu_button").unwrap();
let app_menu = menus.get_object("menu").unwrap();
let update_box = builder.get_object("update_notification").unwrap();
let update_label = builder.get_object("update_label").unwrap();
let update_spinner = builder.get_object("update_spinner").unwrap();
let updater = UpdateIndicator {
container: update_box,
text: update_label,
spinner: update_spinner,
};
let add_toggle = builder.get_object("add_toggle").unwrap();
let add_popover = builder.get_object("add_popover").unwrap();
let new_url = builder.get_object("new_url").unwrap();
let add_button = builder.get_object("add_button").unwrap();
let result = builder.get_object("result_label").unwrap();
let add = AddPopover {
container: add_popover,
entry: new_url,
toggle: add_toggle,
add: add_button,
result,
};
Header {
container: header,
switch,
back,
show_title,
menu_button,
app_menu,
updater,
add,
}
}
}
// TODO: Factor out the hamburger menu
// TODO: Make a proper state machine for the headerbar states
impl Header {
pub fn new(content: &Content, sender: &Sender<Action>) -> Rc<Self> {
let h = Rc::new(Header::default());
Self::init(&h, content, &sender);
h
}
pub fn init(s: &Rc<Self>, content: &Content, sender: &Sender<Action>) {
let weak = Rc::downgrade(s);
s.switch.set_stack(&content.get_stack());
s.add.entry.connect_changed(clone!(weak => move |_| {
weak.upgrade().map(|h| {
h.add.on_entry_changed()
.map_err(|err| error!("Error: {}", err))
.ok();
});
}));
s.add.add.connect_clicked(clone!(weak, sender => move |_| {
weak.upgrade().map(|h| h.add.on_add_clicked(&sender));
}));
let switch = &s.switch;
let add_toggle = &s.add.toggle;
let show_title = &s.show_title;
let menu = &s.menu_button;
s.back.connect_clicked(
clone!(switch, add_toggle, show_title, sender, menu => move |back| {
switch.show();
add_toggle.show();
back.hide();
show_title.hide();
menu.show();
sender.send(Action::ShowShowsAnimated);
}),
);
s.menu_button.set_menu_model(Some(&s.app_menu));
}
pub fn switch_to_back(&self, title: &str) {
self.switch.hide();
self.add.toggle.hide();
self.back.show();
self.set_show_title(title);
self.show_title.show();
self.menu_button.hide();
}
pub fn switch_to_normal(&self) {
self.switch.show();
self.add.toggle.show();
self.back.hide();
self.show_title.hide();
self.menu_button.show();
}
pub fn set_show_title(&self, title: &str) {
self.show_title.set_text(title)
}
pub fn show_update_notification(&self) {
self.updater.show();
}
pub fn hide_update_notification(&self) {
self.updater.hide();
}
pub fn open_menu(&self) {
self.menu_button.clicked();
}
}

View File

@ -1,106 +0,0 @@
#![cfg_attr(
feature = "cargo-clippy",
allow(clone_on_ref_ptr, blacklisted_name, match_same_arms, option_map_unit_fn)
)]
#![allow(unknown_lints)]
// Enable lint group collections
#![warn(nonstandard_style, edition_2018, rust_2018_idioms, bad_style, unused)]
// standalone lints
#![warn(
const_err, improper_ctypes, non_shorthand_field_patterns, no_mangle_generic_items,
overflowing_literals, plugin_as_library, private_no_mangle_fns, private_no_mangle_statics,
unconditional_recursion, unions_with_drop_fields, while_true, missing_debug_implementations,
trivial_casts, trivial_numeric_casts, elided_lifetime_in_paths, missing_copy_implementations
)]
#![deny(warnings)]
extern crate gdk;
extern crate gdk_pixbuf;
extern crate gio;
extern crate glib;
extern crate gstreamer as gst;
extern crate gstreamer_player as gst_player;
extern crate gtk;
#[macro_use]
extern crate failure;
// #[macro_use]
// extern crate failure_derive;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;
extern crate chrono;
extern crate crossbeam_channel;
extern crate hammond_data;
extern crate hammond_downloader;
extern crate html2text;
extern crate humansize;
extern crate loggerv;
extern crate open;
extern crate rayon;
extern crate regex;
extern crate reqwest;
extern crate send_cell;
extern crate serde_json;
extern crate url;
use log::Level;
use gtk::prelude::*;
// http://gtk-rs.org/tuto/closures
#[macro_export]
macro_rules! clone {
(@param _) => ( _ );
(@param $x:ident) => ( $x );
($($n:ident),+ => move || $body:expr) => (
{
$( let $n = $n.clone(); )+
move || $body
}
);
($($n:ident),+ => move |$($p:tt),+| $body:expr) => (
{
$( let $n = $n.clone(); )+
move |$(clone!(@param $p),)+| $body
}
);
}
mod stacks;
mod widgets;
mod app;
mod headerbar;
mod manager;
mod settings;
mod static_resource;
mod utils;
use app::App;
fn main() {
// TODO: make the the logger a cli -vv option
loggerv::init_with_level(Level::Info).expect("Error initializing loggerv.");
gtk::init().expect("Error initializing gtk.");
gst::init().expect("Error initializing gstreamer");
static_resource::init().expect("Something went wrong with the resource file initialization.");
// Add custom style
let provider = gtk::CssProvider::new();
gtk::CssProvider::load_from_resource(&provider, "/org/gnome/Hammond/gtk/style.css");
gtk::StyleContext::add_provider_for_screen(
&gdk::Screen::get_default().expect("Error initializing gtk css provider."),
&provider,
600,
);
App::run();
}

View File

@ -1,89 +0,0 @@
use gtk;
use gtk::prelude::*;
use crossbeam_channel::Sender;
use failure::Error;
use app::Action;
use stacks::{HomeStack, ShowStack};
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Debug, Clone)]
pub struct Content {
stack: gtk::Stack,
shows: Rc<RefCell<ShowStack>>,
home: Rc<RefCell<HomeStack>>,
sender: Sender<Action>,
}
impl Content {
pub fn new(sender: &Sender<Action>) -> Result<Rc<Content>, Error> {
let stack = gtk::Stack::new();
let home = Rc::new(RefCell::new(HomeStack::new(sender.clone())?));
let shows = Rc::new(RefCell::new(ShowStack::new(sender.clone())?));
stack.add_titled(&home.borrow().get_stack(), "home", "New");
stack.add_titled(&shows.borrow().get_stack(), "shows", "Shows");
let con = Content {
stack,
shows,
home,
sender: sender.clone(),
};
Ok(Rc::new(con))
}
pub fn update(&self) {
self.update_home();
self.update_shows();
}
pub fn update_home(&self) {
self.home
.borrow_mut()
.update()
.map_err(|err| error!("Failed to update HomeView: {}", err))
.ok();
}
pub fn update_home_if_background(&self) {
if self.stack.get_visible_child_name() != Some("home".into()) {
self.update_home();
}
}
fn update_shows(&self) {
self.shows
.borrow_mut()
.update()
.map_err(|err| error!("Failed to update ShowsView: {}", err))
.ok();
}
pub fn update_shows_view(&self) {
self.shows
.borrow_mut()
.update()
.map_err(|err| error!("Failed to update ShowsView: {}", err))
.ok();
}
pub fn update_widget_if_same(&self, pid: i32) {
let pop = self.shows.borrow().populated();
pop.borrow_mut()
.update_widget_if_same(pid)
.map_err(|err| error!("Failed to update ShowsWidget: {}", err))
.ok();
}
pub fn get_stack(&self) -> gtk::Stack {
self.stack.clone()
}
pub fn get_shows(&self) -> Rc<RefCell<ShowStack>> {
self.shows.clone()
}
}

View File

@ -1,117 +0,0 @@
use gtk;
use gtk::prelude::*;
use gtk::StackTransitionType;
use crossbeam_channel::Sender;
use failure::Error;
use hammond_data::dbqueries::is_episodes_populated;
use hammond_data::errors::DataError;
use app::Action;
use widgets::{EmptyView, HomeView};
use std::rc::Rc;
#[derive(Debug, Clone, Copy)]
enum State {
Home,
Empty,
}
#[derive(Debug, Clone)]
pub struct HomeStack {
empty: EmptyView,
episodes: Rc<HomeView>,
stack: gtk::Stack,
state: State,
sender: Sender<Action>,
}
impl HomeStack {
pub fn new(sender: Sender<Action>) -> Result<HomeStack, Error> {
let episodes = HomeView::new(sender.clone())?;
let empty = EmptyView::new();
let stack = gtk::Stack::new();
let state = State::Empty;
stack.add_named(&episodes.container, "home");
stack.add_named(&empty.container, "empty");
let mut home = HomeStack {
empty,
episodes,
stack,
state,
sender,
};
home.determine_state()?;
Ok(home)
}
pub fn get_stack(&self) -> gtk::Stack {
self.stack.clone()
}
pub fn update(&mut self) -> Result<(), Error> {
// Copy the vertical scrollbar adjustment from the old view.
self.episodes
.save_alignment()
.map_err(|err| error!("Failed to set episodes_view allignment: {}", err))
.ok();
self.replace_view()?;
// Determine the actuall state.
self.determine_state().map_err(From::from)
}
fn replace_view(&mut self) -> Result<(), Error> {
// Get the container of the view
let old = &self.episodes.container.clone();
let eps = HomeView::new(self.sender.clone())?;
// Remove the old widget and add the new one
// during this the previous view is removed,
// and the visibile child fallsback to empty view.
self.stack.remove(old);
self.stack.add_named(&eps.container, "home");
// Keep the previous state.
let s = self.state;
// Set the visible child back to the previous one to avoid
// the stack transition animation to show the empty view
self.switch_visible(s, StackTransitionType::None);
// replace view in the struct too
self.episodes = eps;
// This might not be needed
old.destroy();
Ok(())
}
fn switch_visible(&mut self, s: State, animation: StackTransitionType) {
use self::State::*;
match s {
Home => {
self.stack.set_visible_child_full("home", animation);
self.state = Home;
}
Empty => {
self.stack.set_visible_child_full("empty", animation);
self.state = Empty;
}
}
}
fn determine_state(&mut self) -> Result<(), DataError> {
if is_episodes_populated()? {
self.switch_visible(State::Home, StackTransitionType::Crossfade);
} else {
self.switch_visible(State::Empty, StackTransitionType::Crossfade);
};
Ok(())
}
}

View File

@ -1,9 +0,0 @@
mod content;
mod home;
mod populated;
mod show;
pub use self::content::Content;
pub use self::home::HomeStack;
pub use self::populated::{PopulatedStack, PopulatedState};
pub use self::show::{ShowStack, ShowState};

View File

@ -1,94 +0,0 @@
use gtk;
use gtk::prelude::*;
use crossbeam_channel::Sender;
use failure::Error;
use hammond_data::dbqueries::is_podcasts_populated;
use app::Action;
use stacks::PopulatedStack;
use utils::get_ignored_shows;
use widgets::EmptyView;
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Debug, Clone, Copy)]
pub enum ShowState {
Populated,
Empty,
}
#[derive(Debug, Clone)]
pub struct ShowStack {
empty: EmptyView,
populated: Rc<RefCell<PopulatedStack>>,
stack: gtk::Stack,
state: ShowState,
sender: Sender<Action>,
}
impl ShowStack {
pub fn new(sender: Sender<Action>) -> Result<Self, Error> {
let populated = Rc::new(RefCell::new(PopulatedStack::new(sender.clone())?));
let empty = EmptyView::new();
let stack = gtk::Stack::new();
let state = ShowState::Empty;
stack.add_named(&populated.borrow().container(), "populated");
stack.add_named(&empty.container, "empty");
let mut show = ShowStack {
empty,
populated,
stack,
state,
sender,
};
show.determine_state()?;
Ok(show)
}
pub fn get_stack(&self) -> gtk::Stack {
self.stack.clone()
}
pub fn populated(&self) -> Rc<RefCell<PopulatedStack>> {
self.populated.clone()
}
pub fn update(&mut self) -> Result<(), Error> {
self.populated.borrow_mut().update();
self.determine_state()
}
fn switch_visible(&mut self, s: ShowState) {
use self::ShowState::*;
match s {
Populated => {
self.stack.set_visible_child_name("populated");
self.state = Populated;
}
Empty => {
self.stack.set_visible_child_name("empty");
self.state = Empty;
}
};
}
fn determine_state(&mut self) -> Result<(), Error> {
use self::ShowState::*;
let ign = get_ignored_shows()?;
debug!("IGNORED SHOWS {:?}", ign);
if is_podcasts_populated(&ign)? {
self.switch_visible(Populated);
} else {
self.switch_visible(Empty);
};
Ok(())
}
}

View File

@ -1,18 +0,0 @@
use gio::{resources_register, Error, Resource};
use glib::Bytes;
pub fn init() -> Result<(), Error> {
// load the gresource binary at build time and include/link it into the final
// binary.
let res_bytes = include_bytes!("../resources/resources.gresource");
// Create Resource it will live as long the value lives.
let gbytes = Bytes::from_static(res_bytes.as_ref());
let resource = Resource::new_from_data(&gbytes)?;
// Register the resource so It wont be dropped and will continue to live in
// memory.
resources_register(&resource);
Ok(())
}

View File

@ -1,42 +0,0 @@
use gtk;
use gtk::prelude::*;
// Totally copied it from fractal.
// https://gitlab.gnome.org/danigm/fractal/blob/503e311e22b9d7540089d735b92af8e8f93560c5/fractal-gtk/src/app.rs#L1883-1912
/// Given a `window` create and attach an `gtk::AboutDialog` to it.
pub fn about_dialog(window: &gtk::ApplicationWindow) {
// Feel free to add yourself if you contribured.
let authors = &[
"Constantin Nickel",
"Gabriele Musco",
"James Wykeham-Martin",
"Jordan Petridis",
"Julian Sparber",
"Rowan Lewis",
"Zander Brown",
];
let dialog = gtk::AboutDialog::new();
// Waiting for a logo.
// dialog.set_logo_icon_name("org.gnome.Hammond");
dialog.set_logo_icon_name("multimedia-player");
dialog.set_comments("Podcast Client for the GNOME Desktop.");
dialog.set_copyright("© 2017, 2018 Jordan Petridis");
dialog.set_license_type(gtk::License::Gpl30);
dialog.set_modal(true);
// TODO: make it show it fetches the commit hash from which it was built
// and the version number is kept in sync automaticly
dialog.set_version("0.4.0");
dialog.set_program_name("Hammond");
// TODO: Need a wiki page first.
// dialog.set_website("https://wiki.gnome.org/Design/Apps/Potential/Podcasts");
// dialog.set_website_label("Learn more about Hammond");
dialog.set_transient_for(window);
dialog.set_artists(&["Tobias Bernard"]);
dialog.set_authors(authors);
dialog.connect_response(|dlg, _| dlg.destroy());
dialog.show();
}

View File

@ -1,94 +0,0 @@
use glib;
use gtk;
use gtk::prelude::*;
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Debug, Clone, Copy)]
pub enum UndoState {
Shown,
Hidden,
}
#[derive(Debug, Clone)]
pub struct InAppNotification {
revealer: gtk::Revealer,
text: gtk::Label,
undo: gtk::Button,
close: gtk::Button,
}
impl Default for InAppNotification {
fn default() -> Self {
let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/inapp_notif.ui");
let revealer: gtk::Revealer = builder.get_object("revealer").unwrap();
let text: gtk::Label = builder.get_object("text").unwrap();
let undo: gtk::Button = builder.get_object("undo").unwrap();
let close: gtk::Button = builder.get_object("close").unwrap();
InAppNotification {
revealer,
text,
undo,
close,
}
}
}
impl InAppNotification {
pub fn new<F, U>(text: &str, mut callback: F, undo_callback: U, show_undo: UndoState) -> Self
where
F: FnMut() -> glib::Continue + 'static,
U: Fn() + 'static,
{
let notif = InAppNotification::default();
notif.text.set_text(&text);
let revealer = notif.revealer.clone();
let id = timeout_add_seconds(6, move || {
revealer.set_reveal_child(false);
callback()
});
let id = Rc::new(RefCell::new(Some(id)));
// Cancel the callback
let revealer = notif.revealer.clone();
notif.undo.connect_clicked(move |_| {
let foo = id.borrow_mut().take();
if let Some(id) = foo {
glib::source::source_remove(id);
}
undo_callback();
// Hide the notification
revealer.set_reveal_child(false);
});
// Hide the revealer when the close button is clicked
let revealer = notif.revealer.clone();
notif.close.connect_clicked(move |_| {
revealer.set_reveal_child(false);
});
match show_undo {
UndoState::Shown => (),
UndoState::Hidden => notif.undo.hide(),
}
notif
}
// This is a seperate method cause in order to get a nice animation
// the revealer should be attached to something that displays it.
// Previously we where doing it in the constructor, which had the result
// of the animation being skipped cause there was no parent widget to display it.
pub fn show(&self, overlay: &gtk::Overlay) {
overlay.add_overlay(&self.revealer);
// We need to display the notification after the widget is added to the overlay
// so there will be a nice animation.
self.revealer.set_reveal_child(true);
}
}

View File

@ -1,21 +0,0 @@
use gtk;
#[derive(Debug, Clone)]
pub struct EmptyView {
pub container: gtk::Box,
}
impl Default for EmptyView {
fn default() -> Self {
let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/empty_view.ui");
let view: gtk::Box = builder.get_object("empty_view").unwrap();
EmptyView { container: view }
}
}
impl EmptyView {
pub fn new() -> EmptyView {
EmptyView::default()
}
}

View File

@ -1,16 +0,0 @@
mod aboutdialog;
pub mod appnotif;
mod empty;
mod episode;
mod home_view;
pub mod player;
mod show;
mod shows_view;
pub use self::aboutdialog::about_dialog;
pub use self::empty::EmptyView;
pub use self::episode::EpisodeWidget;
pub use self::home_view::HomeView;
pub use self::show::ShowWidget;
pub use self::show::{mark_all_notif, remove_show_notif};
pub use self::shows_view::ShowsView;

View File

@ -1,460 +0,0 @@
use gst::prelude::*;
use gst::ClockTime;
use gst_player;
use gtk;
use gtk::prelude::*;
use gio::{File, FileExt};
use glib::SignalHandlerId;
use chrono::NaiveTime;
use crossbeam_channel::Sender;
use failure::Error;
use send_cell::SendCell;
use hammond_data::{dbqueries, USER_AGENT};
use hammond_data::{EpisodeWidgetModel, ShowCoverModel};
use app::Action;
use utils::set_image_from_path;
use std::ops::Deref;
use std::path::Path;
use std::rc::Rc;
#[derive(Debug, Clone, Copy)]
enum SeekDirection {
Backwards,
Forward,
}
trait PlayerExt {
fn play(&self);
fn pause(&self);
fn stop(&self);
fn seek(&self, offset: ClockTime, direction: SeekDirection);
fn fast_forward(&self);
fn rewind(&self);
fn set_playback_rate(&self, f64);
}
#[derive(Debug, Clone)]
struct PlayerInfo {
container: gtk::Box,
show: gtk::Label,
episode: gtk::Label,
cover: gtk::Image,
}
impl PlayerInfo {
// FIXME: create a Diesel Model of the joined episode and podcast query instead
fn init(&self, episode: &EpisodeWidgetModel, podcast: &ShowCoverModel) {
self.set_cover_image(podcast);
self.set_show_title(podcast);
self.set_episode_title(episode);
}
fn set_episode_title(&self, episode: &EpisodeWidgetModel) {
self.episode.set_text(episode.title());
self.episode.set_tooltip_text(episode.title());
}
fn set_show_title(&self, show: &ShowCoverModel) {
self.show.set_text(show.title());
self.show.set_tooltip_text(show.title());
}
fn set_cover_image(&self, show: &ShowCoverModel) {
set_image_from_path(&self.cover, show.id(), 34)
.map_err(|err| error!("Player Cover: {}", err))
.ok();
}
}
#[derive(Debug, Clone)]
struct PlayerTimes {
container: gtk::Box,
progressed: gtk::Label,
duration: gtk::Label,
separator: gtk::Label,
slider: gtk::Scale,
slider_update: Rc<SignalHandlerId>,
}
#[derive(Debug, Clone, Copy)]
struct Duration(ClockTime);
impl Deref for Duration {
type Target = ClockTime;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[derive(Debug, Clone, Copy)]
struct Position(ClockTime);
impl Deref for Position {
type Target = ClockTime;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl PlayerTimes {
/// Update the duration `gtk::Label` and the max range of the `gtk::SclaeBar`.
pub fn on_duration_changed(&self, duration: Duration) {
let seconds = duration.seconds().map(|v| v as f64).unwrap_or(0.0);
self.slider.block_signal(&self.slider_update);
self.slider.set_range(0.0, seconds);
self.slider.unblock_signal(&self.slider_update);
self.duration.set_text(&format_duration(seconds as u32));
}
/// Update the `gtk::SclaeBar` when the pipeline position is changed.
pub fn on_position_updated(&self, position: Position) {
let seconds = position.seconds().map(|v| v as f64).unwrap_or(0.0);
self.slider.block_signal(&self.slider_update);
self.slider.set_value(seconds);
self.slider.unblock_signal(&self.slider_update);
self.progressed.set_text(&format_duration(seconds as u32));
}
}
fn format_duration(seconds: u32) -> String {
let time = NaiveTime::from_num_seconds_from_midnight(seconds, 0);
if seconds >= 3600 {
time.format("%T").to_string()
} else {
time.format("%M:%S").to_string()
}
}
#[derive(Debug, Clone)]
struct PlayerRate {
radio150: gtk::RadioButton,
radio125: gtk::RadioButton,
radio_normal: gtk::RadioButton,
popover: gtk::Popover,
btn: gtk::MenuButton,
label: gtk::Label,
}
#[derive(Debug, Clone)]
struct PlayerControls {
container: gtk::Box,
play: gtk::Button,
pause: gtk::Button,
forward: gtk::Button,
rewind: gtk::Button,
}
#[derive(Debug, Clone)]
pub struct PlayerWidget {
pub action_bar: gtk::ActionBar,
player: gst_player::Player,
controls: PlayerControls,
timer: PlayerTimes,
info: PlayerInfo,
rate: PlayerRate,
}
impl Default for PlayerWidget {
fn default() -> Self {
let dispatcher = gst_player::PlayerGMainContextSignalDispatcher::new(None);
let player = gst_player::Player::new(
None,
// Use the gtk main thread
Some(&dispatcher.upcast::<gst_player::PlayerSignalDispatcher>()),
);
let mut config = player.get_config();
config.set_user_agent(USER_AGENT);
config.set_position_update_interval(250);
player.set_config(config).unwrap();
let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/player_toolbar.ui");
let action_bar = builder.get_object("action_bar").unwrap();
let buttons = builder.get_object("buttons").unwrap();
let play = builder.get_object("play_button").unwrap();
let pause = builder.get_object("pause_button").unwrap();
let forward = builder.get_object("ff_button").unwrap();
let rewind = builder.get_object("rewind_button").unwrap();
let controls = PlayerControls {
container: buttons,
play,
pause,
forward,
rewind,
};
let timer_container = builder.get_object("timer").unwrap();
let progressed = builder.get_object("progress_time_label").unwrap();
let duration = builder.get_object("total_duration_label").unwrap();
let separator = builder.get_object("separator").unwrap();
let slider: gtk::Scale = builder.get_object("seek").unwrap();
slider.set_range(0.0, 1.0);
let slider_update = Rc::new(Self::connect_update_slider(&slider, &player));
let timer = PlayerTimes {
container: timer_container,
progressed,
duration,
separator,
slider,
slider_update,
};
let labels = builder.get_object("info").unwrap();
let show = builder.get_object("show_label").unwrap();
let episode = builder.get_object("episode_label").unwrap();
let cover = builder.get_object("show_cover").unwrap();
let info = PlayerInfo {
container: labels,
show,
episode,
cover,
};
let radio150 = builder.get_object("rate_1_50").unwrap();
let radio125 = builder.get_object("rate_1_25").unwrap();
let radio_normal = builder.get_object("normal_rate").unwrap();
let popover = builder.get_object("rate_popover").unwrap();
let btn = builder.get_object("rate_button").unwrap();
let label = builder.get_object("rate_label").unwrap();
let rate = PlayerRate {
radio150,
radio125,
radio_normal,
popover,
label,
btn,
};
PlayerWidget {
player,
action_bar,
controls,
timer,
info,
rate,
}
}
}
impl PlayerWidget {
pub fn new(sender: &Sender<Action>) -> Rc<Self> {
let w = Rc::new(Self::default());
Self::init(&w, sender);
w
}
fn init(s: &Rc<Self>, sender: &Sender<Action>) {
Self::connect_control_buttons(s);
Self::connect_rate_buttons(s);
Self::connect_gst_signals(s, sender);
}
/// Connect the `PlayerControls` buttons to the `PlayerExt` methods.
fn connect_control_buttons(s: &Rc<Self>) {
let weak = Rc::downgrade(s);
// Connect the play button to the gst Player.
s.controls.play.connect_clicked(clone!(weak => move |_| {
weak.upgrade().map(|p| p.play());
}));
// Connect the pause button to the gst Player.
s.controls.pause.connect_clicked(clone!(weak => move |_| {
weak.upgrade().map(|p| p.pause());
}));
// Connect the rewind button to the gst Player.
s.controls.rewind.connect_clicked(clone!(weak => move |_| {
weak.upgrade().map(|p| p.rewind());
}));
// Connect the fast-forward button to the gst Player.
s.controls.forward.connect_clicked(clone!(weak => move |_| {
weak.upgrade().map(|p| p.fast_forward());
}));
}
#[cfg_attr(rustfmt, rustfmt_skip)]
fn connect_gst_signals(s: &Rc<Self>, sender: &Sender<Action>) {
// Log gst warnings.
s.player.connect_warning(move |_, warn| warn!("gst warning: {}", warn));
// Log gst errors.
s.player.connect_error(clone!(sender => move |_, error| {
// FIXME: should never occur and should not be user facing.
sender.send(Action::ErrorNotification(format!("Player Error: {}", error)));
}));
// The followign callbacks require `Send` but are handled by the gtk main loop
let weak = SendCell::new(Rc::downgrade(s));
// Update the duration label and the slider
s.player.connect_duration_changed(clone!(weak => move |_, clock| {
weak.borrow()
.upgrade()
.map(|p| p.timer.on_duration_changed(Duration(clock)));
}));
// Update the position label and the slider
s.player.connect_position_updated(clone!(weak => move |_, clock| {
weak.borrow()
.upgrade()
.map(|p| p.timer.on_position_updated(Position(clock)));
}));
// Reset the slider to 0 and show a play button
s.player.connect_end_of_stream(clone!(weak => move |_| {
weak.borrow()
.upgrade()
.map(|p| p.stop());
}));
}
#[cfg_attr(rustfmt, rustfmt_skip)]
fn connect_rate_buttons(s: &Rc<Self>) {
let weak = Rc::downgrade(s);
s.rate
.radio_normal
.connect_toggled(clone!(weak => move |_| {
weak.upgrade().map(|p| p.on_rate_changed(1.00));
}));
s.rate
.radio125
.connect_toggled(clone!(weak => move |_| {
weak.upgrade().map(|p| p.on_rate_changed(1.25));
}));
s.rate
.radio150
.connect_toggled(clone!(weak => move |_| {
weak.upgrade().map(|p| p.on_rate_changed(1.50));
}));
}
fn on_rate_changed(&self, rate: f64) {
self.set_playback_rate(rate);
self.rate.label.set_text(&format!("{:.2}x", rate));
}
fn reveal(&self) {
self.action_bar.show();
}
pub fn initialize_episode(&self, rowid: i32) -> Result<(), Error> {
let ep = dbqueries::get_episode_widget_from_rowid(rowid)?;
let pd = dbqueries::get_podcast_cover_from_id(ep.show_id())?;
self.info.init(&ep, &pd);
// Currently that will always be the case since the play button is
// only shown if the file is downloaded
if let Some(ref path) = ep.local_uri() {
if Path::new(path).exists() {
// path is an absolute fs path ex. "foo/bar/baz".
// Convert it so it will have a "file:///"
// FIXME: convert it properly
if let Some(uri) = File::new_for_path(path).get_uri() {
// play the file
self.player.set_uri(&uri);
self.play();
return Ok(());
}
}
// TODO: log an error
}
// FIXME: Stream stuff
// unimplemented!()
Ok(())
}
fn connect_update_slider(slider: &gtk::Scale, player: &gst_player::Player) -> SignalHandlerId {
slider.connect_value_changed(clone!(player => move |slider| {
let value = slider.get_value() as u64;
player.seek(ClockTime::from_seconds(value));
}))
}
}
impl PlayerExt for PlayerWidget {
fn play(&self) {
self.reveal();
self.controls.pause.show();
self.controls.play.hide();
self.player.play();
}
fn pause(&self) {
self.controls.pause.hide();
self.controls.play.show();
self.player.pause();
// Only rewind on pause if the stream position is passed a certain point.
if let Some(sec) = self.player.get_position().seconds() {
if sec >= 90 {
self.seek(ClockTime::from_seconds(5), SeekDirection::Backwards);
}
}
}
#[cfg_attr(rustfmt, rustfmt_skip)]
fn stop(&self) {
self.controls.pause.hide();
self.controls.play.show();
self.player.stop();
// Reset the slider bar to the start
self.timer.on_position_updated(Position(ClockTime::from_seconds(0)));
}
// Adapted from https://github.com/philn/glide/blob/b52a65d99daeab0b487f79a0e1ccfad0cd433e22/src/player_context.rs#L219-L245
fn seek(&self, offset: ClockTime, direction: SeekDirection) {
let position = self.player.get_position();
if position.is_none() || offset.is_none() {
return;
}
let duration = self.player.get_duration();
let destination = match direction {
SeekDirection::Backwards if position >= offset => Some(position - offset),
SeekDirection::Forward if !duration.is_none() && position + offset <= duration => {
Some(position + offset)
}
_ => None,
};
destination.map(|d| self.player.seek(d));
}
// FIXME: make the interval a GSetting
fn rewind(&self) {
self.seek(ClockTime::from_seconds(10), SeekDirection::Backwards)
}
// FIXME: make the interval a GSetting
fn fast_forward(&self) {
self.seek(ClockTime::from_seconds(10), SeekDirection::Forward)
}
fn set_playback_rate(&self, rate: f64) {
self.player.set_rate(rate);
}
}

View File

@ -1,332 +0,0 @@
use glib;
use gtk;
use gtk::prelude::*;
use crossbeam_channel::Sender;
use failure::Error;
use html2text;
use open;
use rayon;
use send_cell::SendCell;
use hammond_data::dbqueries;
use hammond_data::utils::delete_show;
use hammond_data::Show;
use app::Action;
use utils::{self, lazy_load};
use widgets::appnotif::{InAppNotification, UndoState};
use widgets::EpisodeWidget;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
lazy_static! {
static ref SHOW_WIDGET_VALIGNMENT: Mutex<Option<(i32, SendCell<gtk::Adjustment>)>> =
Mutex::new(None);
}
#[derive(Debug, Clone)]
pub struct ShowWidget {
pub container: gtk::Box,
scrolled_window: gtk::ScrolledWindow,
cover: gtk::Image,
description: gtk::Label,
link: gtk::Button,
settings: gtk::MenuButton,
unsub: gtk::Button,
episodes: gtk::ListBox,
show_id: Option<i32>,
}
impl Default for ShowWidget {
fn default() -> Self {
let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/show_widget.ui");
let container: gtk::Box = builder.get_object("container").unwrap();
let scrolled_window: gtk::ScrolledWindow = builder.get_object("scrolled_window").unwrap();
let episodes = builder.get_object("episodes").unwrap();
let cover: gtk::Image = builder.get_object("cover").unwrap();
let description: gtk::Label = builder.get_object("description").unwrap();
let unsub: gtk::Button = builder.get_object("unsub_button").unwrap();
let link: gtk::Button = builder.get_object("link_button").unwrap();
let settings: gtk::MenuButton = builder.get_object("settings_button").unwrap();
ShowWidget {
container,
scrolled_window,
cover,
description,
unsub,
link,
settings,
episodes,
show_id: None,
}
}
}
impl ShowWidget {
pub fn new(pd: Arc<Show>, sender: Sender<Action>) -> Rc<ShowWidget> {
let mut pdw = ShowWidget::default();
pdw.init(&pd, &sender);
let pdw = Rc::new(pdw);
populate_listbox(&pdw, pd, sender)
.map_err(|err| error!("Failed to populate the listbox: {}", err))
.ok();
pdw
}
pub fn init(&mut self, pd: &Arc<Show>, sender: &Sender<Action>) {
let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/show_widget.ui");
self.unsub
.connect_clicked(clone!(pd, sender => move |bttn| {
on_unsub_button_clicked(pd.clone(), bttn, &sender);
}));
self.set_description(pd.description());
self.show_id = Some(pd.id());
self.set_cover(&pd)
.map_err(|err| error!("Failed to set a cover: {}", err))
.ok();
let link = pd.link().to_owned();
self.link.set_tooltip_text(Some(link.as_str()));
self.link.connect_clicked(move |_| {
info!("Opening link: {}", &link);
open::that(&link)
.map_err(|err| error!("Error: {}", err))
.map_err(|_| error!("Failed open link: {}", &link))
.ok();
});
let show_menu: gtk::Popover = builder.get_object("show_menu").unwrap();
let mark_all: gtk::ModelButton = builder.get_object("mark_all_watched").unwrap();
let episodes = self.episodes.clone();
mark_all.connect_clicked(clone!(pd, sender => move |_| {
on_played_button_clicked(
pd.clone(),
&episodes,
&sender
)
}));
self.settings.set_popover(&show_menu);
}
/// Set the show cover.
fn set_cover(&self, pd: &Arc<Show>) -> Result<(), Error> {
utils::set_image_from_path(&self.cover, pd.id(), 256)
}
/// Set the descripton text.
fn set_description(&self, text: &str) {
self.description
.set_markup(&html2text::from_read(text.as_bytes(), 70));
}
/// Save the scrollabar vajustment to the cache.
pub fn save_vadjustment(&self, oldid: i32) -> Result<(), Error> {
if let Ok(mut guard) = SHOW_WIDGET_VALIGNMENT.lock() {
let adj = self
.scrolled_window
.get_vadjustment()
.ok_or_else(|| format_err!("Could not get the adjustment"))?;
*guard = Some((oldid, SendCell::new(adj)));
debug!("Widget Alignment was saved with ID: {}.", oldid);
}
Ok(())
}
/// Set scrolled window vertical adjustment.
fn set_vadjustment(&self, pd: &Arc<Show>) -> Result<(), Error> {
let guard = SHOW_WIDGET_VALIGNMENT
.lock()
.map_err(|err| format_err!("Failed to lock widget align mutex: {}", err))?;
if let Some((oldid, ref sendcell)) = *guard {
// Only copy the old scrollbar if both widget's represent the same podcast.
debug!("PID: {}", pd.id());
debug!("OLDID: {}", oldid);
if pd.id() != oldid {
debug!("Early return");
return Ok(());
};
// Copy the vertical scrollbar adjustment from the old view into the new one.
sendcell
.try_get()
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x));
}
Ok(())
}
pub fn show_id(&self) -> Option<i32> {
self.show_id
}
}
/// Populate the listbox with the shows episodes.
fn populate_listbox(
show: &Rc<ShowWidget>,
pd: Arc<Show>,
sender: Sender<Action>,
) -> Result<(), Error> {
use crossbeam_channel::bounded;
let count = dbqueries::get_pd_episodes_count(&pd)?;
let (sender_, receiver) = bounded(1);
rayon::spawn(clone!(pd => move || {
let episodes = dbqueries::get_pd_episodeswidgets(&pd).unwrap();
// The receiver can be dropped if there's an early return
// like on show without episodes for example.
sender_.send(episodes);
}));
if count == 0 {
let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/empty_show.ui");
let container: gtk::Box = builder.get_object("empty_show").unwrap();
show.episodes.add(&container);
return Ok(());
}
let show_ = show.clone();
gtk::idle_add(move || {
let episodes = match receiver.try_recv() {
Some(e) => e,
None => return glib::Continue(true),
};
let list = show_.episodes.clone();
let constructor = clone!(sender => move |ep| {
EpisodeWidget::new(&ep, &sender).container.clone()
});
let callback = clone!(pd, show_ => move || {
show_.set_vadjustment(&pd)
.map_err(|err| error!("Failed to set ShowWidget Alignment: {}", err))
.ok();
});
lazy_load(episodes, list.clone(), constructor, callback);
glib::Continue(false)
});
Ok(())
}
fn on_unsub_button_clicked(pd: Arc<Show>, unsub_button: &gtk::Button, sender: &Sender<Action>) {
// hack to get away without properly checking for none.
// if pressed twice would panic.
unsub_button.set_sensitive(false);
sender.send(Action::RemoveShow(pd));
sender.send(Action::HeaderBarNormal);
sender.send(Action::ShowShowsAnimated);
// Queue a refresh after the switch to avoid blocking the db.
sender.send(Action::RefreshShowsView);
sender.send(Action::RefreshEpisodesView);
unsub_button.set_sensitive(true);
}
fn on_played_button_clicked(pd: Arc<Show>, episodes: &gtk::ListBox, sender: &Sender<Action>) {
if dim_titles(episodes).is_none() {
error!("Something went horribly wrong when dimming the titles.");
warn!("RUN WHILE YOU STILL CAN!");
}
sender.send(Action::MarkAllPlayerNotification(pd))
}
fn mark_all_watched(pd: &Show, sender: &Sender<Action>) -> Result<(), Error> {
dbqueries::update_none_to_played_now(pd)?;
// Not all widgets migth have been loaded when the mark_all is hit
// So we will need to refresh again after it's done.
sender.send(Action::RefreshWidgetIfSame(pd.id()));
sender.send(Action::RefreshEpisodesView);
Ok(())
}
pub fn mark_all_notif(pd: Arc<Show>, sender: &Sender<Action>) -> InAppNotification {
let id = pd.id();
let callback = clone!(sender => move || {
mark_all_watched(&pd, &sender)
.map_err(|err| error!("Notif Callback Error: {}", err))
.ok();
glib::Continue(false)
});
let undo_callback = clone!(sender => move || sender.send(Action::RefreshWidgetIfSame(id)));
let text = "Marked all episodes as listened";
InAppNotification::new(text, callback, undo_callback, UndoState::Shown)
}
pub fn remove_show_notif(pd: Arc<Show>, sender: Sender<Action>) -> InAppNotification {
let text = format!("Unsubscribed from {}", pd.title());
utils::ignore_show(pd.id())
.map_err(|err| error!("Error: {}", err))
.map_err(|_| error!("Could not insert {} to the ignore list.", pd.title()))
.ok();
let callback = clone!(pd, sender => move || {
utils::uningore_show(pd.id())
.map_err(|err| error!("Error: {}", err))
.map_err(|_| error!("Could not remove {} from the ignore list.", pd.title()))
.ok();
// Spawn a thread so it won't block the ui.
rayon::spawn(clone!(pd, sender => move || {
delete_show(&pd)
.map_err(|err| error!("Error: {}", err))
.map_err(|_| error!("Failed to delete {}", pd.title()))
.ok();
sender.send(Action::RefreshEpisodesView);
}));
glib::Continue(false)
});
let undo_callback = move || {
utils::uningore_show(pd.id())
.map_err(|err| error!("{}", err))
.ok();
sender.send(Action::RefreshShowsView);
sender.send(Action::RefreshEpisodesView);
};
InAppNotification::new(&text, callback, undo_callback, UndoState::Shown)
}
// Ideally if we had a custom widget this would have been as simple as:
// `for row in listbox { ep = row.get_episode(); ep.dim_title(); }`
// But now I can't think of a better way to do it than hardcoding the title
// position relative to the EpisodeWidget container gtk::Box.
fn dim_titles(episodes: &gtk::ListBox) -> Option<()> {
let children = episodes.get_children();
for row in children {
let row = row.downcast::<gtk::ListBoxRow>().ok()?;
let container = row.get_children().remove(0).downcast::<gtk::Box>().ok()?;
let foo = container
.get_children()
.remove(0)
.downcast::<gtk::Box>()
.ok()?;
let bar = foo.get_children().remove(0).downcast::<gtk::Box>().ok()?;
let title = bar.get_children().remove(0).downcast::<gtk::Label>().ok()?;
title.get_style_context().map(|c| c.add_class("dim-label"));
}
Some(())
}

View File

@ -1,168 +0,0 @@
use gtk;
use gtk::prelude::*;
use crossbeam_channel::Sender;
use failure::Error;
use send_cell::SendCell;
use hammond_data::dbqueries;
use hammond_data::Show;
use app::Action;
use utils::{self, get_ignored_shows, lazy_load, set_image_from_path};
use std::rc::Rc;
use std::sync::Arc;
use std::sync::Mutex;
lazy_static! {
static ref SHOWS_VIEW_VALIGNMENT: Mutex<Option<SendCell<gtk::Adjustment>>> = Mutex::new(None);
}
#[derive(Debug, Clone)]
pub struct ShowsView {
pub container: gtk::Box,
scrolled_window: gtk::ScrolledWindow,
flowbox: gtk::FlowBox,
}
impl Default for ShowsView {
fn default() -> Self {
let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/shows_view.ui");
let container: gtk::Box = builder.get_object("fb_parent").unwrap();
let scrolled_window: gtk::ScrolledWindow = builder.get_object("scrolled_window").unwrap();
let flowbox: gtk::FlowBox = builder.get_object("flowbox").unwrap();
ShowsView {
container,
scrolled_window,
flowbox,
}
}
}
impl ShowsView {
pub fn new(sender: Sender<Action>) -> Result<Rc<Self>, Error> {
let pop = Rc::new(ShowsView::default());
pop.init(sender);
// Populate the flowbox with the Shows.
populate_flowbox(&pop)?;
Ok(pop)
}
pub fn init(&self, sender: Sender<Action>) {
self.flowbox.connect_child_activated(move |_, child| {
on_child_activate(child, &sender)
.map_err(|err| error!("Error along flowbox child activation: {}", err))
.ok();
});
}
/// Set scrolled window vertical adjustment.
#[allow(unused)]
fn set_vadjustment(&self) -> Result<(), Error> {
let guard = SHOWS_VIEW_VALIGNMENT
.lock()
.map_err(|err| format_err!("Failed to lock widget align mutex: {}", err))?;
if let Some(ref sendcell) = *guard {
// Copy the vertical scrollbar adjustment from the old view into the new one.
sendcell
.try_get()
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x));
}
Ok(())
}
/// Save the vertical scrollbar position.
pub fn save_alignment(&self) -> Result<(), Error> {
if let Ok(mut guard) = SHOWS_VIEW_VALIGNMENT.lock() {
let adj = self
.scrolled_window
.get_vadjustment()
.ok_or_else(|| format_err!("Could not get the adjustment"))?;
*guard = Some(SendCell::new(adj));
info!("Saved episodes_view alignment.");
}
Ok(())
}
}
fn populate_flowbox(shows: &Rc<ShowsView>) -> Result<(), Error> {
let ignore = get_ignored_shows()?;
let podcasts = dbqueries::get_podcasts_filter(&ignore)?;
let constructor = move |parent| ShowsChild::new(&parent).child;
let callback = clone!(shows => move || {
shows.set_vadjustment()
.map_err(|err| error!("Failed to set ShowsView Alignment: {}", err))
.ok();
});
let flowbox = shows.flowbox.clone();
lazy_load(podcasts, flowbox, constructor, callback);
Ok(())
}
fn on_child_activate(child: &gtk::FlowBoxChild, sender: &Sender<Action>) -> Result<(), Error> {
use gtk::WidgetExt;
// This is such an ugly hack...
let id = WidgetExt::get_name(child)
.ok_or_else(|| format_err!("Faild to get \"episodes\" child from the stack."))?
.parse::<i32>()?;
let pd = Arc::new(dbqueries::get_podcast_from_id(id)?);
sender.send(Action::HeaderBarShowTile(pd.title().into()));
sender.send(Action::ReplaceWidget(pd));
sender.send(Action::ShowWidgetAnimated);
Ok(())
}
#[derive(Debug)]
struct ShowsChild {
container: gtk::Box,
cover: gtk::Image,
child: gtk::FlowBoxChild,
}
impl Default for ShowsChild {
fn default() -> Self {
let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/shows_child.ui");
let container: gtk::Box = builder.get_object("fb_child").unwrap();
let cover: gtk::Image = builder.get_object("pd_cover").unwrap();
let child = gtk::FlowBoxChild::new();
child.add(&container);
ShowsChild {
container,
cover,
child,
}
}
}
impl ShowsChild {
pub fn new(pd: &Show) -> ShowsChild {
let child = ShowsChild::default();
child.init(pd);
child
}
fn init(&self, pd: &Show) {
self.container.set_tooltip_text(pd.title());
WidgetExt::set_name(&self.child, &pd.id().to_string());
self.set_cover(pd.id())
.map_err(|err| error!("Failed to set a cover: {}", err))
.ok();
}
fn set_cover(&self, show_id: i32) -> Result<(), Error> {
set_image_from_path(&self.cover, show_id, 256)
}
}

View File

@ -1,38 +1,90 @@
# Adatped from:
# https://gitlab.gnome.org/danigm/fractal/blob/6e2911f9d2353c99a18a6c19fab7f903c4bbb431/meson.build
project(
'hammond', 'rust',
version: '0.4.0',
'gnome-podcasts', 'rust',
version: '0.4.7',
license: 'GPLv3',
)
hammond_version = meson.project_version()
version_array = hammond_version.split('.')
hammond_major_version = version_array[0].to_int()
hammond_minor_version = version_array[1].to_int()
hammond_version_micro = version_array[2].to_int()
dependency('sqlite3', version: '>= 3.20')
dependency('openssl', version: '>= 1.0')
dependency('dbus-1')
hammond_prefix = get_option('prefix')
hammond_bindir = join_paths(hammond_prefix, get_option('bindir'))
dependency('glib-2.0', version: '>= 2.56')
dependency('gio-2.0', version: '>= 2.56')
dependency('gdk-pixbuf-2.0')
dependency('gtk+-3.0', version: '>= 3.24.11')
dependency('libhandy-0.0', version: '>= 0.0.13')
dependency('gstreamer-1.0', version: '>= 1.16')
dependency('gstreamer-base-1.0', version: '>= 1.16')
dependency('gstreamer-audio-1.0', version: '>= 1.16')
dependency('gstreamer-video-1.0', version: '>= 1.16')
dependency('gstreamer-player-1.0', version: '>= 1.16')
dependency('gstreamer-plugins-base-1.0', version: '>= 1.16')
dependency('gstreamer-plugins-bad-1.0', version: '>= 1.16')
dependency('gstreamer-bad-audio-1.0', version: '>= 1.16')
cargo = find_program('cargo', required: true)
gresource = find_program('glib-compile-resources', required: true)
gschemas = find_program('glib-compile-schemas', required: true)
if get_option('profile') == 'development'
profile = '.Devel'
vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
if vcs_tag == ''
version_suffix = '-devel'
else
version_suffix = '-@0@'.format (vcs_tag)
endif
else
profile = ''
version_suffix = ''
endif
podcast_toml = files(
'Cargo.toml',
'Cargo.lock',
'podcasts-data/Cargo.toml',
'podcasts-downloader/Cargo.toml',
'podcasts-gtk/Cargo.toml',
)
application_id = 'org.gnome.Podcasts@0@'.format(profile)
i18n = import('i18n')
gnome = import('gnome')
subdir('podcasts-gtk/po')
podir = join_paths (meson.source_root (), 'podcasts-gtk', 'po')
podcasts_version = meson.project_version()
podcasts_prefix = get_option('prefix')
podcasts_bindir = join_paths(podcasts_prefix, get_option('bindir'))
podcasts_localedir = join_paths(podcasts_prefix, get_option('localedir'))
podcasts_conf = configuration_data()
podcasts_conf.set('appid', application_id)
podcasts_conf.set('bindir', podcasts_bindir)
datadir = get_option('datadir')
icondir = join_paths(datadir, 'icons')
subdir('hammond-gtk/resources')
subdir('podcasts-gtk/resources')
cargo = find_program('cargo', required: false)
gresource = find_program('glib-compile-resources', required: false)
cargo_vendor = find_program('cargo-vendor', required: false)
cargo_script = find_program('scripts/cargo.sh')
test_script = find_program('scripts/test.sh')
cargo_release = custom_target('cargo-build',
build_by_default: true,
build_always: true,
output: ['hammond'],
install: true,
install_dir: hammond_bindir,
command: [cargo_script, '@CURRENT_SOURCE_DIR@', '@OUTPUT@'])
subdir('podcasts-data/src')
subdir('podcasts-downloader/src')
subdir('podcasts-gtk/src')
run_target('release', command: ['scripts/release.sh',
meson.project_name() + '-' + hammond_version
])
meson.add_dist_script(
'scripts/dist-vendor.sh',
meson.source_root(),
join_paths(meson.build_root(), 'meson-dist', meson.project_name() + '-' + podcasts_version)
)
test(
'cargo-test',
test_script,
args: meson.build_root(),
workdir: meson.source_root(),
timeout: 3000
)

9
meson_options.txt Normal file
View File

@ -0,0 +1,9 @@
option (
'profile',
type: 'combo',
choices: [
'default',
'development'
],
value: 'default'
)

View File

@ -1,50 +0,0 @@
{
"app-id" : "org.gnome.Hammond",
"runtime" : "org.gnome.Platform",
"runtime-version" : "3.28",
"sdk" : "org.gnome.Sdk",
"sdk-extensions" : [
"org.freedesktop.Sdk.Extension.rust-stable"
],
"command" : "hammond",
"tags" : [
"nightly"
],
"desktop-file-name-prefix" : "(Nightly) ",
"finish-args" : [
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf",
"--share=network",
"--share=ipc",
"--socket=x11",
"--socket=wayland",
"--socket=pulseaudio",
"--talk-name=org.freedesktop.Desktop"
],
"build-options" : {
"append-path" : "/usr/lib/sdk/rust-stable/bin",
"build-args" : [
"--share=network"
],
"env" : {
"CARGO_HOME" : "/run/build/Hammond/cargo",
"RUST_BACKTRACE" : "1",
"DEBUG" : "true"
}
},
"modules" : [
{
"name" : "hammond",
"buildsystem" : "meson",
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/World/hammond.git",
"branch" : "master"
}
]
}
]
}

View File

@ -0,0 +1,72 @@
{
"app-id" : "org.gnome.Podcasts.Devel",
"runtime" : "org.gnome.Platform",
"runtime-version" : "3.36",
"sdk" : "org.gnome.Sdk",
"sdk-extensions" : [
"org.freedesktop.Sdk.Extension.rust-stable"
],
"command" : "gnome-podcasts",
"tags" : [
"nightly"
],
"finish-args" : [
"--share=network",
"--share=ipc",
"--socket=x11",
"--socket=fallback-x11",
"--socket=wayland",
"--socket=pulseaudio",
"--env=USE_PLAYBING3=1"
],
"build-options" : {
"append-path" : "/usr/lib/sdk/rust-stable/bin",
"build-args" : [
"--share=network"
],
"env" : {
"CARGO_HOME" : "/run/build/Podcasts/cargo",
"RUSTFLAGS" : "",
"RUST_BACKTRACE" : "1"
}
},
"modules" : [
{
"name" : "libhandy",
"buildsystem" : "meson",
"config-opts" : [
"-Dintrospection=disabled",
"-Dgtk_doc=false",
"-Dtests=false",
"-Dexamples=false",
"-Dvapi=false",
"-Dglade_catalog=disabled"
],
"cleanup" : [
"/include",
"/lib/pkgconfig"
],
"sources" : [
{
"type" : "git",
"url" : "https://source.puri.sm/Librem5/libhandy.git",
"tag" : "v0.0.13"
}
]
},
{
"name" : "gnome-podcasts",
"buildsystem" : "meson",
"builddir" : "true",
"config-opts" : [
"-Dprofile=development"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/World/podcasts.git"
}
]
}
]
}

69
org.gnome.Podcasts.json Normal file
View File

@ -0,0 +1,69 @@
{
"app-id" : "org.gnome.Podcasts",
"runtime" : "org.gnome.Platform",
"runtime-version" : "3.36",
"sdk" : "org.gnome.Sdk",
"sdk-extensions" : [
"org.freedesktop.Sdk.Extension.rust-stable"
],
"command" : "gnome-podcasts",
"tags" : [
"nightly"
],
"desktop-file-name-suffix" : " ☢️",
"finish-args" : [
"--share=network",
"--share=ipc",
"--socket=x11",
"--socket=fallback-x11",
"--socket=wayland",
"--socket=pulseaudio",
"--env=USE_PLAYBING3=1"
],
"build-options" : {
"append-path" : "/usr/lib/sdk/rust-stable/bin",
"build-args" : [
"--share=network"
],
"env" : {
"CARGO_HOME" : "/run/build/Podcasts/cargo",
"RUST_BACKTRACE" : "1"
}
},
"modules" : [
{
"name" : "libhandy",
"buildsystem" : "meson",
"config-opts" : [
"-Dintrospection=disabled",
"-Dgtk_doc=false",
"-Dtests=false",
"-Dexamples=false",
"-Dvapi=false",
"-Dglade_catalog=disabled"
],
"cleanup" : [
"/include",
"/lib/pkgconfig"
],
"sources" : [
{
"type" : "git",
"url" : "https://source.puri.sm/Librem5/libhandy.git",
"tag" : "v0.0.13"
}
]
},
{
"name" : "gnome-podcasts",
"builddir" : "true",
"buildsystem" : "meson",
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/World/podcasts.git"
}
]
}
]
}

42
podcasts-data/Cargo.toml Normal file
View File

@ -0,0 +1,42 @@
[package]
authors = ["Jordan Petridis <jpetridis@gnome.org>"]
name = "podcasts-data"
version = "0.1.0"
edition = "2018"
[dependencies]
ammonia = "3.1.0"
chrono = "0.4.11"
derive_builder = "0.9.0"
lazy_static = "1.4.0"
log = "0.4.8"
rayon = "1.3.1"
rfc822_sanitizer = "0.3.3"
rss = "1.9.0"
url = "2.1.1"
xdg = "2.2.0"
xml-rs = "0.8.3"
futures = "0.1.29"
hyper = "0.12.35"
http = "0.1.19"
tokio = "0.1.22"
hyper-tls = "0.3.2"
native-tls = "0.2.3"
num_cpus = "1.13.0"
failure = "0.1.8"
failure_derive = "0.1.8"
base64 = "0.12.2"
[dependencies.diesel]
features = ["sqlite", "r2d2"]
version = "1.4.5"
[dependencies.diesel_migrations]
features = ["sqlite"]
version = "1.4.0"
[dev-dependencies]
rand = "0.7.2"
tempdir = "0.3.7"
pretty_assertions = "0.6.1"
maplit = "1.0.2"

View File

@ -1,3 +1,22 @@
// database.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//! Database Setup. This is only public to help with some unit tests.
// Diesel embed_migrations! triggers the lint
#![allow(unused_imports)]
@ -9,10 +28,10 @@ use diesel::r2d2::ConnectionManager;
use std::io;
use std::path::PathBuf;
use errors::DataError;
use crate::errors::DataError;
#[cfg(not(test))]
use xdg_dirs;
use crate::xdg_dirs;
type Pool = r2d2::Pool<ConnectionManager<SqliteConnection>>;
@ -24,16 +43,16 @@ lazy_static! {
#[cfg(not(test))]
lazy_static! {
static ref DB_PATH: PathBuf = xdg_dirs::HAMMOND_XDG.place_data_file("hammond.db").unwrap();
static ref DB_PATH: PathBuf = xdg_dirs::PODCASTS_XDG
.place_data_file("podcasts.db")
.unwrap();
}
#[cfg(test)]
extern crate tempdir;
#[cfg(test)]
lazy_static! {
static ref TEMPDIR: tempdir::TempDir = { tempdir::TempDir::new("hammond_unit_test").unwrap() };
static ref DB_PATH: PathBuf = TEMPDIR.path().join("hammond.db");
pub(crate) static ref TEMPDIR: tempdir::TempDir =
{ tempdir::TempDir::new("podcasts_unit_test").unwrap() };
static ref DB_PATH: PathBuf = TEMPDIR.path().join("podcasts.db");
}
/// Get an r2d2 `SqliteConnection`.
@ -64,7 +83,7 @@ fn run_migration_on(connection: &SqliteConnection) -> Result<(), DataError> {
/// Reset the database into a clean state.
// Test share a Temp file db.
#[allow(dead_code)]
#[cfg(test)]
pub fn truncate_db() -> Result<(), DataError> {
let db = connection();
let con = db.get()?;

View File

@ -1,3 +1,22 @@
// dbqueries.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//! Random CRUD helper functions.
use chrono::prelude::*;
@ -5,15 +24,14 @@ use diesel::prelude::*;
use diesel;
use diesel::dsl::exists;
use diesel::query_builder::AsQuery;
use diesel::select;
use database::connection;
use errors::DataError;
use models::*;
use crate::database::connection;
use crate::errors::DataError;
use crate::models::*;
pub fn get_sources() -> Result<Vec<Source>, DataError> {
use schema::source::dsl::*;
use crate::schema::source::dsl::*;
let db = connection();
let con = db.get()?;
@ -24,7 +42,7 @@ pub fn get_sources() -> Result<Vec<Source>, DataError> {
}
pub fn get_podcasts() -> Result<Vec<Show>, DataError> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
let db = connection();
let con = db.get()?;
@ -35,7 +53,7 @@ pub fn get_podcasts() -> Result<Vec<Show>, DataError> {
}
pub fn get_podcasts_filter(filter_ids: &[i32]) -> Result<Vec<Show>, DataError> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
let db = connection();
let con = db.get()?;
@ -47,7 +65,7 @@ pub fn get_podcasts_filter(filter_ids: &[i32]) -> Result<Vec<Show>, DataError> {
}
pub fn get_episodes() -> Result<Vec<Episode>, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -58,7 +76,7 @@ pub fn get_episodes() -> Result<Vec<Episode>, DataError> {
}
pub(crate) fn get_downloaded_episodes() -> Result<Vec<EpisodeCleanerModel>, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -81,7 +99,7 @@ pub(crate) fn get_downloaded_episodes() -> Result<Vec<EpisodeCleanerModel>, Data
// }
pub(crate) fn get_played_cleaner_episodes() -> Result<Vec<EpisodeCleanerModel>, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -93,7 +111,7 @@ pub(crate) fn get_played_cleaner_episodes() -> Result<Vec<EpisodeCleanerModel>,
}
pub fn get_episode_from_rowid(ep_id: i32) -> Result<Episode, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -104,7 +122,7 @@ pub fn get_episode_from_rowid(ep_id: i32) -> Result<Episode, DataError> {
}
pub fn get_episode_widget_from_rowid(ep_id: i32) -> Result<EpisodeWidgetModel, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -118,7 +136,7 @@ pub fn get_episode_widget_from_rowid(ep_id: i32) -> Result<EpisodeWidgetModel, D
}
pub fn get_episode_local_uri_from_id(ep_id: i32) -> Result<Option<String>, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -133,7 +151,7 @@ pub fn get_episodes_widgets_filter_limit(
filter_ids: &[i32],
limit: u32,
) -> Result<Vec<EpisodeWidgetModel>, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
let columns = (
@ -150,7 +168,7 @@ pub fn get_episodes_widgets_filter_limit(
}
pub fn get_podcast_from_id(pid: i32) -> Result<Show, DataError> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
let db = connection();
let con = db.get()?;
@ -161,7 +179,7 @@ pub fn get_podcast_from_id(pid: i32) -> Result<Show, DataError> {
}
pub fn get_podcast_cover_from_id(pid: i32) -> Result<ShowCoverModel, DataError> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
let db = connection();
let con = db.get()?;
@ -173,7 +191,7 @@ pub fn get_podcast_cover_from_id(pid: i32) -> Result<ShowCoverModel, DataError>
}
pub fn get_pd_episodes(parent: &Show) -> Result<Vec<Episode>, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -194,7 +212,7 @@ pub fn get_pd_episodes_count(parent: &Show) -> Result<i64, DataError> {
}
pub fn get_pd_episodeswidgets(parent: &Show) -> Result<Vec<EpisodeWidgetModel>, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
let columns = (
@ -210,7 +228,7 @@ pub fn get_pd_episodeswidgets(parent: &Show) -> Result<Vec<EpisodeWidgetModel>,
}
pub fn get_pd_unplayed_episodes(parent: &Show) -> Result<Vec<Episode>, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -235,7 +253,7 @@ pub fn get_pd_unplayed_episodes(parent: &Show) -> Result<Vec<Episode>, DataError
// }
pub fn get_source_from_uri(uri_: &str) -> Result<Source, DataError> {
use schema::source::dsl::*;
use crate::schema::source::dsl::*;
let db = connection();
let con = db.get()?;
@ -246,7 +264,7 @@ pub fn get_source_from_uri(uri_: &str) -> Result<Source, DataError> {
}
pub fn get_source_from_id(id_: i32) -> Result<Source, DataError> {
use schema::source::dsl::*;
use crate::schema::source::dsl::*;
let db = connection();
let con = db.get()?;
@ -257,7 +275,7 @@ pub fn get_source_from_id(id_: i32) -> Result<Source, DataError> {
}
pub fn get_podcast_from_source_id(sid: i32) -> Result<Show, DataError> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
let db = connection();
let con = db.get()?;
@ -268,7 +286,7 @@ pub fn get_podcast_from_source_id(sid: i32) -> Result<Show, DataError> {
}
pub fn get_episode_from_pk(title_: &str, pid: i32) -> Result<Episode, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -283,7 +301,7 @@ pub(crate) fn get_episode_minimal_from_pk(
title_: &str,
pid: i32,
) -> Result<EpisodeMinimal, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -295,6 +313,23 @@ pub(crate) fn get_episode_minimal_from_pk(
.map_err(From::from)
}
#[cfg(test)]
pub(crate) fn get_episode_cleaner_from_pk(
title_: &str,
pid: i32,
) -> Result<EpisodeCleanerModel, DataError> {
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
episodes
.select((rowid, local_uri, played))
.filter(title.eq(title_))
.filter(show_id.eq(pid))
.get_result::<EpisodeCleanerModel>(&con)
.map_err(From::from)
}
pub(crate) fn remove_feed(pd: &Show) -> Result<(), DataError> {
let db = connection();
let con = db.get()?;
@ -309,25 +344,25 @@ pub(crate) fn remove_feed(pd: &Show) -> Result<(), DataError> {
}
fn delete_source(con: &SqliteConnection, source_id: i32) -> QueryResult<usize> {
use schema::source::dsl::*;
use crate::schema::source::dsl::*;
diesel::delete(source.filter(id.eq(source_id))).execute(con)
}
fn delete_podcast(con: &SqliteConnection, show_id: i32) -> QueryResult<usize> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
diesel::delete(shows.filter(id.eq(show_id))).execute(con)
}
fn delete_podcast_episodes(con: &SqliteConnection, parent_id: i32) -> QueryResult<usize> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
diesel::delete(episodes.filter(show_id.eq(parent_id))).execute(con)
}
pub fn source_exists(url: &str) -> Result<bool, DataError> {
use schema::source::dsl::*;
use crate::schema::source::dsl::*;
let db = connection();
let con = db.get()?;
@ -338,7 +373,7 @@ pub fn source_exists(url: &str) -> Result<bool, DataError> {
}
pub(crate) fn podcast_exists(source_id_: i32) -> Result<bool, DataError> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
let db = connection();
let con = db.get()?;
@ -350,7 +385,7 @@ pub(crate) fn podcast_exists(source_id_: i32) -> Result<bool, DataError> {
#[cfg_attr(rustfmt, rustfmt_skip)]
pub(crate) fn episode_exists(title_: &str, show_id_: i32) -> Result<bool, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -363,22 +398,22 @@ pub(crate) fn episode_exists(title_: &str, show_id_: i32) -> Result<bool, DataEr
/// Check if the `episodes table contains any rows
///
/// Return true if `episodes` table is populated.
pub fn is_episodes_populated() -> Result<bool, DataError> {
use schema::episodes::dsl::*;
pub fn is_episodes_populated(filter_show_ids: &[i32]) -> Result<bool, DataError> {
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
select(exists(episodes.as_query()))
select(exists(episodes.filter(show_id.ne_all(filter_show_ids))))
.get_result(&con)
.map_err(From::from)
}
/// Check if the `shows` table contains any rows
///
/// Return true if `shows table is populated.
/// Return true if `shows` table is populated.
pub fn is_podcasts_populated(filter_ids: &[i32]) -> Result<bool, DataError> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
let db = connection();
let con = db.get()?;
@ -388,8 +423,22 @@ pub fn is_podcasts_populated(filter_ids: &[i32]) -> Result<bool, DataError> {
.map_err(From::from)
}
/// Check if the `source` table contains any rows
///
/// Return true if `source` table is populated.
pub fn is_source_populated(filter_ids: &[i32]) -> Result<bool, DataError> {
use crate::schema::source::dsl::*;
let db = connection();
let con = db.get()?;
select(exists(source.filter(id.ne_all(filter_ids))))
.get_result(&con)
.map_err(From::from)
}
pub(crate) fn index_new_episodes(eps: &[NewEpisode]) -> Result<(), DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -401,7 +450,7 @@ pub(crate) fn index_new_episodes(eps: &[NewEpisode]) -> Result<(), DataError> {
}
pub fn update_none_to_played_now(parent: &Show) -> Result<usize, DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -417,25 +466,27 @@ pub fn update_none_to_played_now(parent: &Show) -> Result<usize, DataError> {
#[cfg(test)]
mod tests {
use super::*;
use database::*;
use pipeline;
use crate::database::*;
use crate::pipeline;
use failure::Error;
#[test]
fn test_update_none_to_played_now() {
truncate_db().unwrap();
fn test_update_none_to_played_now() -> Result<(), Error> {
truncate_db()?;
let url = "https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\
com/InterceptedWithJeremyScahill";
let source = Source::from_url(url).unwrap();
let source = Source::from_url(url)?;
let id = source.id();
pipeline::run(vec![source], true).unwrap();
let pd = get_podcast_from_source_id(id).unwrap();
pipeline::run(vec![source])?;
let pd = get_podcast_from_source_id(id)?;
let eps_num = get_pd_unplayed_episodes(&pd).unwrap().len();
let eps_num = get_pd_unplayed_episodes(&pd)?.len();
assert_ne!(eps_num, 0);
update_none_to_played_now(&pd).unwrap();
let eps_num2 = get_pd_unplayed_episodes(&pd).unwrap().len();
update_none_to_played_now(&pd)?;
let eps_num2 = get_pd_unplayed_episodes(&pd)?.len();
assert_eq!(eps_num2, 0);
Ok(())
}
}

125
podcasts-data/src/errors.rs Normal file
View File

@ -0,0 +1,125 @@
// errors.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
use diesel;
use diesel::r2d2;
use diesel_migrations::RunMigrationsError;
use http;
use hyper;
use native_tls;
use rss;
use url;
use xml;
use std::io;
use crate::models::Source;
#[fail(
display = "Request to {} returned {}. Context: {}",
url, status_code, context
)]
#[derive(Fail, Debug)]
pub struct HttpStatusError {
url: String,
status_code: hyper::StatusCode,
context: String,
}
impl HttpStatusError {
pub fn new(url: String, code: hyper::StatusCode, context: String) -> Self {
HttpStatusError {
url,
status_code: code,
context,
}
}
}
#[derive(Fail, Debug)]
pub enum DataError {
#[fail(display = "SQL Query failed: {}", _0)]
DieselResultError(#[cause] diesel::result::Error),
#[fail(display = "Database Migration error: {}", _0)]
DieselMigrationError(#[cause] RunMigrationsError),
#[fail(display = "R2D2 error: {}", _0)]
R2D2Error(#[cause] r2d2::Error),
#[fail(display = "R2D2 Pool error: {}", _0)]
R2D2PoolError(#[cause] r2d2::PoolError),
#[fail(display = "Hyper Error: {}", _0)]
HyperError(#[cause] hyper::Error),
#[fail(display = "ToStr Error: {}", _0)]
HttpToStr(#[cause] http::header::ToStrError),
#[fail(display = "Failed to parse a url: {}", _0)]
UrlError(#[cause] url::ParseError),
#[fail(display = "TLS Error: {}", _0)]
TLSError(#[cause] native_tls::Error),
#[fail(display = "IO Error: {}", _0)]
IOError(#[cause] io::Error),
#[fail(display = "RSS Error: {}", _0)]
RssError(#[cause] rss::Error),
#[fail(display = "XML Reader Error: {}", _0)]
XmlReaderError(#[cause] xml::reader::Error),
#[fail(display = "Error: {}", _0)]
Bail(String),
#[fail(display = "{}", _0)]
HttpStatusGeneral(HttpStatusError),
#[fail(display = "Source redirects to a new url")]
FeedRedirect(Source),
#[fail(display = "Feed is up to date")]
FeedNotModified(Source),
#[fail(
display = "Error occurred while Parsing an Episode. Reason: {}",
reason
)]
ParseEpisodeError { reason: String, parent_id: i32 },
#[fail(display = "Episode was not changed and thus skipped.")]
EpisodeNotChanged,
}
// Maps a type to a variant of the DataError enum
macro_rules! easy_from_impl {
($outer_type:ty, $from:ty => $to:expr) => (
impl From<$from> for $outer_type {
fn from(err: $from) -> Self {
$to(err)
}
}
);
($outer_type:ty, $from:ty => $to:expr, $($f:ty => $t:expr),+) => (
easy_from_impl!($outer_type, $from => $to);
easy_from_impl!($outer_type, $($f => $t),+);
);
}
easy_from_impl!(
DataError,
RunMigrationsError => DataError::DieselMigrationError,
diesel::result::Error => DataError::DieselResultError,
r2d2::Error => DataError::R2D2Error,
r2d2::PoolError => DataError::R2D2PoolError,
hyper::Error => DataError::HyperError,
http::header::ToStrError => DataError::HttpToStr,
url::ParseError => DataError::UrlError,
native_tls::Error => DataError::TLSError,
io::Error => DataError::IOError,
rss::Error => DataError::RssError,
xml::reader::Error => DataError::XmlReaderError,
String => DataError::Bail
);

View File

@ -1,4 +1,24 @@
#![cfg_attr(feature = "cargo-clippy", allow(unit_arg))]
// feed.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#![allow(clippy::unit_arg)]
//! Index Feeds.
use futures::future::*;
@ -6,10 +26,10 @@ use futures::prelude::*;
use futures::stream;
use rss;
use dbqueries;
use errors::DataError;
use models::{Index, IndexState, Update};
use models::{NewEpisode, NewEpisodeMinimal, NewShow, Show};
use crate::dbqueries;
use crate::errors::DataError;
use crate::models::{Index, IndexState, Update};
use crate::models::{NewEpisode, NewEpisodeMinimal, NewShow, Show};
/// Wrapper struct that hold a `Source` id and the `rss::Channel`
/// that corresponds to the `Source.uri` field.
@ -26,7 +46,7 @@ pub struct Feed {
impl Feed {
/// Index the contents of the RSS `Feed` into the database.
pub fn index(self) -> impl Future<Item = (), Error = DataError> + Send {
self.parse_podcast_async()
ok(self.parse_podcast())
.and_then(|pd| pd.to_podcast())
.and_then(move |pd| self.index_channel_items(pd))
}
@ -35,16 +55,13 @@ impl Feed {
NewShow::new(&self.channel, self.source_id)
}
fn parse_podcast_async(&self) -> impl Future<Item = NewShow, Error = DataError> + Send {
ok(self.parse_podcast())
}
fn index_channel_items(self, pd: Show) -> impl Future<Item = (), Error = DataError> + Send {
let stream = stream::iter_ok::<_, DataError>(self.channel.into_items());
// Parse the episodes
let episodes = stream.filter_map(move |item| {
glue(&item, pd.id())
NewEpisodeMinimal::new(&item, pd.id())
.and_then(move |ep| determine_ep_state(ep, &item))
.map_err(|err| error!("Failed to parse an episode: {}", err))
.ok()
});
@ -56,10 +73,6 @@ impl Feed {
}
}
fn glue(item: &rss::Item, id: i32) -> Result<IndexState<NewEpisode>, DataError> {
NewEpisodeMinimal::new(item, id).and_then(move |ep| determine_ep_state(ep, item))
}
fn determine_ep_state(
ep: NewEpisodeMinimal,
item: &rss::Item,
@ -87,21 +100,22 @@ fn filter_episodes<'a, S>(
where
S: Stream<Item = IndexState<NewEpisode>, Error = DataError> + Send + 'a,
{
stream.filter_map(|state| match state {
IndexState::NotChanged => None,
// Update individual rows, and filter them
IndexState::Update((ref ep, rowid)) => {
ep.update(rowid)
.map_err(|err| error!("{}", err))
.map_err(|_| error!("Failed to index episode: {:?}.", ep.title()))
.ok();
stream
.filter_map(|state| match state {
IndexState::NotChanged => None,
// Update individual rows, and filter them
IndexState::Update((ref ep, rowid)) => {
ep.update(rowid)
.map_err(|err| error!("{}", err))
.map_err(|_| error!("Failed to index episode: {:?}.", ep.title()))
.ok();
None
},
IndexState::Index(s) => Some(s),
})
// only Index is left, collect them for batch index
.collect()
None
}
IndexState::Index(s) => Some(s),
})
// only Index is left, collect them for batch index
.collect()
}
fn batch_insert_episodes(episodes: &[NewEpisode]) {
@ -127,13 +141,14 @@ fn batch_insert_episodes(episodes: &[NewEpisode]) {
#[cfg(test)]
mod tests {
use failure::Error;
use rss::Channel;
use tokio_core::reactor::Core;
use tokio::{self, prelude::*};
use database::truncate_db;
use dbqueries;
use utils::get_feed;
use Source;
use crate::database::truncate_db;
use crate::dbqueries;
use crate::utils::get_feed;
use crate::Source;
use std::fs;
use std::io::BufReader;
@ -171,8 +186,8 @@ mod tests {
};
#[test]
fn test_complete_index() {
truncate_db().unwrap();
fn test_complete_index() -> Result<(), Error> {
truncate_db()?;
let feeds: Vec<_> = URLS
.iter()
@ -183,41 +198,43 @@ mod tests {
})
.collect();
let mut core = Core::new().unwrap();
// Index the channels
let list: Vec<_> = feeds.into_iter().map(|x| x.index()).collect();
let _foo = core.run(join_all(list));
let stream_ = stream::iter_ok(feeds).for_each(|x| x.index());
tokio::run(stream_.map_err(|_| ()));
// Assert the index rows equal the controlled results
assert_eq!(dbqueries::get_sources().unwrap().len(), 5);
assert_eq!(dbqueries::get_podcasts().unwrap().len(), 5);
assert_eq!(dbqueries::get_episodes().unwrap().len(), 354);
assert_eq!(dbqueries::get_sources()?.len(), 5);
assert_eq!(dbqueries::get_podcasts()?.len(), 5);
assert_eq!(dbqueries::get_episodes()?.len(), 354);
Ok(())
}
#[test]
fn test_feed_parse_podcast() {
truncate_db().unwrap();
fn test_feed_parse_podcast() -> Result<(), Error> {
truncate_db()?;
let path = "tests/feeds/2018-01-20-Intercepted.xml";
let feed = get_feed(path, 42);
let file = fs::File::open(path).unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
let file = fs::File::open(path)?;
let channel = Channel::read_from(BufReader::new(file))?;
let pd = NewShow::new(&channel, 42);
assert_eq!(feed.parse_podcast(), pd);
Ok(())
}
#[test]
fn test_feed_index_channel_items() {
truncate_db().unwrap();
fn test_feed_index_channel_items() -> Result<(), Error> {
truncate_db()?;
let path = "tests/feeds/2018-01-20-Intercepted.xml";
let feed = get_feed(path, 42);
let pd = feed.parse_podcast().to_podcast().unwrap();
let pd = feed.parse_podcast().to_podcast()?;
feed.index_channel_items(pd).wait().unwrap();
assert_eq!(dbqueries::get_podcasts().unwrap().len(), 1);
assert_eq!(dbqueries::get_episodes().unwrap().len(), 43);
feed.index_channel_items(pd).wait()?;
assert_eq!(dbqueries::get_podcasts()?.len(), 1);
assert_eq!(dbqueries::get_episodes()?.len(), 43);
Ok(())
}
}

145
podcasts-data/src/lib.rs Normal file
View File

@ -0,0 +1,145 @@
// lib.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#![recursion_limit = "1024"]
#![allow(unknown_lints)]
#![cfg_attr(
all(test, feature = "clippy"),
allow(option_unwrap_used, result_unwrap_used)
)]
#![cfg_attr(
feature = "clippy",
warn(
option_unwrap_used,
result_unwrap_used,
print_stdout,
wrong_pub_self_convention,
mut_mut,
non_ascii_literal,
similar_names,
unicode_not_nfc,
enum_glob_use,
if_not_else,
items_after_statements,
used_underscore_binding
)
)]
// Enable lint group collections
#![warn(nonstandard_style, bad_style, unused)]
#![warn(edition_2018, rust_2018_idioms)]
// standalone lints
#![warn(
const_err,
improper_ctypes,
non_shorthand_field_patterns,
no_mangle_generic_items,
overflowing_literals,
plugin_as_library,
unconditional_recursion,
unions_with_drop_fields,
while_true,
missing_debug_implementations,
missing_docs,
trivial_casts,
trivial_numeric_casts,
elided_lifetime_in_paths,
missing_copy_implementations
)]
#![allow(proc_macro_derive_resolution_fallback)]
//! FIXME: Docs
#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;
#[cfg(test)]
#[macro_use]
extern crate maplit;
#[macro_use]
extern crate derive_builder;
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate diesel_migrations;
// #[macro_use]
// extern crate failure;
#[macro_use]
extern crate failure_derive;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
pub mod database;
#[allow(missing_docs)]
pub mod dbqueries;
#[allow(missing_docs)]
pub mod errors;
mod feed;
pub(crate) mod models;
pub mod opml;
mod parser;
pub mod pipeline;
mod schema;
pub mod utils;
pub use crate::feed::{Feed, FeedBuilder};
pub use crate::models::Save;
pub use crate::models::{Episode, EpisodeWidgetModel, Show, ShowCoverModel, Source};
// Set the user agent, See #53 for more
// Keep this in sync with Tor-browser releases
/// The user-agent to be used for all the requests.
/// It originates from the Tor-browser UA.
pub const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0";
/// [XDG Base Directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) Paths.
#[allow(missing_debug_implementations)]
pub mod xdg_dirs {
use std::path::PathBuf;
use xdg;
lazy_static! {
pub(crate) static ref PODCASTS_XDG: xdg::BaseDirectories = {
xdg::BaseDirectories::with_prefix("gnome-podcasts").unwrap()
};
/// XDG_DATA Directory `Pathbuf`.
pub static ref PODCASTS_DATA: PathBuf = {
PODCASTS_XDG.create_data_directory(PODCASTS_XDG.get_data_home()).unwrap()
};
/// XDG_CONFIG Directory `Pathbuf`.
pub static ref PODCASTS_CONFIG: PathBuf = {
PODCASTS_XDG.create_config_directory(PODCASTS_XDG.get_config_home()).unwrap()
};
/// XDG_CACHE Directory `Pathbuf`.
pub static ref PODCASTS_CACHE: PathBuf = {
PODCASTS_XDG.create_cache_directory(PODCASTS_XDG.get_cache_home()).unwrap()
};
/// GNOME Podcasts Download Directory `PathBuf`.
pub static ref DL_DIR: PathBuf = {
PODCASTS_XDG.create_data_directory("Downloads").unwrap()
};
}
}

View File

@ -0,0 +1,19 @@
data_sources = files(
'models/episode.rs',
'models/mod.rs',
'models/new_episode.rs',
'models/new_show.rs',
'models/new_source.rs',
'models/show.rs',
'models/source.rs',
'database.rs',
'dbqueries.rs',
'errors.rs',
'feed.rs',
'lib.rs',
'opml.rs',
'parser.rs',
'pipeline.rs',
'schema.rs',
'utils.rs',
)

View File

@ -1,12 +1,31 @@
// episode.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
use chrono::prelude::*;
use diesel;
use diesel::prelude::*;
use diesel::SaveChangesDsl;
use database::connection;
use errors::DataError;
use models::{Save, Show};
use schema::episodes;
use crate::database::connection;
use crate::errors::DataError;
use crate::models::{Save, Show};
use crate::schema::episodes;
#[derive(Queryable, Identifiable, AsChangeset, Associations, PartialEq)]
#[table_name = "episodes"]
@ -53,11 +72,6 @@ impl Episode {
&self.title
}
/// Set the `title`.
pub fn set_title(&mut self, value: &str) {
self.title = value.to_string();
}
/// Get the value of the `uri`.
///
/// Represents the url(usually) that the media file will be located at.
@ -65,11 +79,6 @@ impl Episode {
self.uri.as_ref().map(|s| s.as_str())
}
/// Set the `uri`.
pub fn set_uri(&mut self, value: Option<&str>) {
self.uri = value.map(|x| x.to_string());
}
/// Get the value of the `local_uri`.
///
/// Represents the local uri,usually filesystem path,
@ -78,31 +87,16 @@ impl Episode {
self.local_uri.as_ref().map(|s| s.as_str())
}
/// Set the `local_uri`.
pub fn set_local_uri(&mut self, value: Option<&str>) {
self.local_uri = value.map(|x| x.to_string());
}
/// Get the `description`.
pub fn description(&self) -> Option<&str> {
self.description.as_ref().map(|s| s.as_str())
}
/// Set the `description`.
pub fn set_description(&mut self, value: Option<&str>) {
self.description = value.map(|x| x.to_string());
}
/// Get the Episode's `guid`.
pub fn guid(&self) -> Option<&str> {
self.guid.as_ref().map(|s| s.as_str())
}
/// Set the `guid`.
pub fn set_guid(&mut self, value: Option<&str>) {
self.guid = value.map(|x| x.to_string());
}
/// Get the `epoch` value.
///
/// Retrieved from the rss Item publish date.
@ -111,11 +105,6 @@ impl Episode {
self.epoch
}
/// Set the `epoch`.
pub fn set_epoch(&mut self, value: i32) {
self.epoch = value;
}
/// Get the `length`.
///
/// The number represents the size of the file in bytes.
@ -123,11 +112,6 @@ impl Episode {
self.length
}
/// Set the `length`.
pub fn set_length(&mut self, value: Option<i32>) {
self.length = value;
}
/// Get the `duration` value.
///
/// The number represents the duration of the item/episode in seconds.
@ -135,11 +119,6 @@ impl Episode {
self.duration
}
/// Set the `duration`.
pub fn set_duration(&mut self, value: Option<i32>) {
self.duration = value;
}
/// Epoch representation of the last time the episode was played.
///
/// None/Null for unplayed.
@ -147,22 +126,10 @@ impl Episode {
self.played
}
/// Set the `played` value.
pub fn set_played(&mut self, value: Option<i32>) {
self.played = value;
}
/// `Show` table foreign key.
pub fn show_id(&self) -> i32 {
self.show_id
}
/// Sets the `played` value with the current `epoch` timestap and save it.
pub fn set_played_now(&mut self) -> Result<(), DataError> {
let epoch = Utc::now().timestamp() as i32;
self.set_played(Some(epoch));
self.save().map(|_| ())
}
}
#[derive(Queryable, AsChangeset, PartialEq)]
@ -205,7 +172,7 @@ impl Save<usize> for EpisodeWidgetModel {
/// Helper method to easily save/"sync" current state of self to the
/// Database.
fn save(&self) -> Result<usize, Self::Error> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let tempdb = db.get()?;
@ -275,11 +242,6 @@ impl EpisodeWidgetModel {
self.duration
}
/// Set the `duration`.
pub fn set_duration(&mut self, value: Option<i32>) {
self.duration = value;
}
/// Epoch representation of the last time the episode was played.
///
/// None/Null for unplayed.
@ -288,7 +250,7 @@ impl EpisodeWidgetModel {
}
/// Set the `played` value.
pub fn set_played(&mut self, value: Option<i32>) {
fn set_played(&mut self, value: Option<i32>) {
self.played = value;
}
@ -323,7 +285,7 @@ impl Save<usize> for EpisodeCleanerModel {
/// Helper method to easily save/"sync" current state of self to the
/// Database.
fn save(&self) -> Result<usize, Self::Error> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let tempdb = db.get()?;
@ -447,11 +409,6 @@ impl EpisodeMinimal {
self.length
}
/// Set the `length`.
pub fn set_length(&mut self, value: Option<i32>) {
self.length = value;
}
/// Get the `duration` value.
///
/// The number represents the duration of the item/episode in seconds.

View File

@ -1,3 +1,22 @@
// mod.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
mod new_episode;
mod new_show;
mod new_source;
@ -39,7 +58,7 @@ pub trait Insert<T> {
pub trait Update<T> {
type Error;
fn update(&self, i32) -> Result<T, Self::Error>;
fn update(&self, _: i32) -> Result<T, Self::Error>;
}
// This might need to change in the future

View File

@ -1,16 +1,35 @@
// new_episode.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
use ammonia;
use diesel;
use diesel::prelude::*;
use rfc822_sanitizer::parse_from_rfc2822_with_fallback as parse_rfc822;
use rss;
use database::connection;
use dbqueries;
use errors::DataError;
use models::{Episode, EpisodeMinimal, Index, Insert, Update};
use parser;
use schema::episodes;
use utils::url_cleaner;
use crate::database::connection;
use crate::dbqueries;
use crate::errors::DataError;
use crate::models::{Episode, EpisodeMinimal, Index, Insert, Update};
use crate::parser;
use crate::schema::episodes;
use crate::utils::url_cleaner;
#[derive(Insertable, AsChangeset)]
#[table_name = "episodes"]
@ -47,7 +66,7 @@ impl Insert<()> for NewEpisode {
type Error = DataError;
fn insert(&self) -> Result<(), DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -64,7 +83,7 @@ impl Update<()> for NewEpisode {
type Error = DataError;
fn update(&self, episode_id: i32) -> Result<(), DataError> {
use schema::episodes::dsl::*;
use crate::schema::episodes::dsl::*;
let db = connection();
let con = db.get()?;
@ -217,7 +236,8 @@ impl NewEpisodeMinimal {
let enc = item.enclosure();
// Get the url
let uri = enc.map(|s| url_cleaner(s.url().trim()))
let uri = enc
.map(|s| url_cleaner(s.url().trim()))
// Fallback to Rss.Item.link if enclosure is None.
.or_else(|| item.link().map(|s| url_cleaner(s.trim())));
@ -235,7 +255,7 @@ impl NewEpisodeMinimal {
return Err(err);
};
// Default to rfc2822 represantation of epoch 0.
// Default to rfc2822 representation of epoch 0.
let date = parse_rfc822(item.pub_date().unwrap_or("Thu, 1 Jan 1970 00:00:00 +0000"));
// Should treat information from the rss feeds as invalid by default.
// Case: "Thu, 05 Aug 2016 06:00:00 -0400" <-- Actually that was friday.
@ -310,10 +330,11 @@ impl NewEpisodeMinimal {
#[cfg(test)]
mod tests {
use database::truncate_db;
use dbqueries;
use models::new_episode::{NewEpisodeMinimal, NewEpisodeMinimalBuilder};
use models::*;
use crate::database::truncate_db;
use crate::dbqueries;
use crate::models::new_episode::{NewEpisodeMinimal, NewEpisodeMinimalBuilder};
use crate::models::*;
use failure::Error;
use rss::Channel;
@ -321,7 +342,7 @@ mod tests {
use std::io::BufReader;
// TODO: Add tests for other feeds too.
// Especially if you find an *intresting* generated feed.
// Especially if you find an *interesting* generated feed.
// Known prebuilt expected objects.
lazy_static! {
@ -486,68 +507,72 @@ mod tests {
}
#[test]
fn test_new_episode_minimal_intercepted() {
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_episode_minimal_intercepted() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let episode = channel.items().iter().nth(14).unwrap();
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
let ep = NewEpisodeMinimal::new(&episode, 42)?;
assert_eq!(ep, *EXPECTED_MINIMAL_INTERCEPTED_1);
let episode = channel.items().iter().nth(15).unwrap();
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
let ep = NewEpisodeMinimal::new(&episode, 42)?;
assert_eq!(ep, *EXPECTED_MINIMAL_INTERCEPTED_2);
Ok(())
}
#[test]
fn test_new_episode_intercepted() {
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_episode_intercepted() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let episode = channel.items().iter().nth(14).unwrap();
let ep = NewEpisode::new(&episode, 42).unwrap();
let ep = NewEpisode::new(&episode, 42)?;
assert_eq!(ep, *EXPECTED_INTERCEPTED_1);
let episode = channel.items().iter().nth(15).unwrap();
let ep = NewEpisode::new(&episode, 42).unwrap();
let ep = NewEpisode::new(&episode, 42)?;
assert_eq!(ep, *EXPECTED_INTERCEPTED_2);
Ok(())
}
#[test]
fn test_new_episode_minimal_lup() {
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_episode_minimal_lup() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let episode = channel.items().iter().nth(18).unwrap();
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
let ep = NewEpisodeMinimal::new(&episode, 42)?;
assert_eq!(ep, *EXPECTED_MINIMAL_LUP_1);
let episode = channel.items().iter().nth(19).unwrap();
let ep = NewEpisodeMinimal::new(&episode, 42).unwrap();
let ep = NewEpisodeMinimal::new(&episode, 42)?;
assert_eq!(ep, *EXPECTED_MINIMAL_LUP_2);
Ok(())
}
#[test]
fn test_new_episode_lup() {
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_episode_lup() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let episode = channel.items().iter().nth(18).unwrap();
let ep = NewEpisode::new(&episode, 42).unwrap();
let ep = NewEpisode::new(&episode, 42)?;
assert_eq!(ep, *EXPECTED_LUP_1);
let episode = channel.items().iter().nth(19).unwrap();
let ep = NewEpisode::new(&episode, 42).unwrap();
let ep = NewEpisode::new(&episode, 42)?;
assert_eq!(ep, *EXPECTED_LUP_2);
Ok(())
}
#[test]
fn test_minimal_into_new_episode() {
truncate_db().unwrap();
fn test_minimal_into_new_episode() -> Result<(), Error> {
truncate_db()?;
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let item = channel.items().iter().nth(14).unwrap();
let ep = EXPECTED_MINIMAL_INTERCEPTED_1
@ -564,42 +589,44 @@ mod tests {
.clone()
.into_new_episode(&item);
assert_eq!(ep, *EXPECTED_INTERCEPTED_2);
Ok(())
}
#[test]
fn test_new_episode_insert() {
truncate_db().unwrap();
fn test_new_episode_insert() -> Result<(), Error> {
truncate_db()?;
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let episode = channel.items().iter().nth(14).unwrap();
let new_ep = NewEpisode::new(&episode, 42).unwrap();
new_ep.insert().unwrap();
let ep = dbqueries::get_episode_from_pk(new_ep.title(), new_ep.show_id()).unwrap();
let new_ep = NewEpisode::new(&episode, 42)?;
new_ep.insert()?;
let ep = dbqueries::get_episode_from_pk(new_ep.title(), new_ep.show_id())?;
assert_eq!(new_ep, ep);
assert_eq!(&new_ep, &*EXPECTED_INTERCEPTED_1);
assert_eq!(&*EXPECTED_INTERCEPTED_1, &ep);
let episode = channel.items().iter().nth(15).unwrap();
let new_ep = NewEpisode::new(&episode, 42).unwrap();
new_ep.insert().unwrap();
let ep = dbqueries::get_episode_from_pk(new_ep.title(), new_ep.show_id()).unwrap();
let new_ep = NewEpisode::new(&episode, 42)?;
new_ep.insert()?;
let ep = dbqueries::get_episode_from_pk(new_ep.title(), new_ep.show_id())?;
assert_eq!(new_ep, ep);
assert_eq!(&new_ep, &*EXPECTED_INTERCEPTED_2);
assert_eq!(&*EXPECTED_INTERCEPTED_2, &ep);
Ok(())
}
#[test]
fn test_new_episode_update() {
truncate_db().unwrap();
let old = EXPECTED_INTERCEPTED_1.clone().to_episode().unwrap();
fn test_new_episode_update() -> Result<(), Error> {
truncate_db()?;
let old = EXPECTED_INTERCEPTED_1.clone().to_episode()?;
let updated = &*UPDATED_DURATION_INTERCEPTED_1;
updated.update(old.rowid()).unwrap();
let new = dbqueries::get_episode_from_pk(old.title(), old.show_id()).unwrap();
updated.update(old.rowid())?;
let new = dbqueries::get_episode_from_pk(old.title(), old.show_id())?;
// Assert that updating does not change the rowid and show_id
assert_ne!(old, new);
@ -608,11 +635,12 @@ mod tests {
assert_eq!(updated, &new);
assert_ne!(updated, &old);
Ok(())
}
#[test]
fn test_new_episode_index() {
truncate_db().unwrap();
fn test_new_episode_index() -> Result<(), Error> {
truncate_db()?;
let expected = &*EXPECTED_INTERCEPTED_1;
// First insert
@ -620,7 +648,7 @@ mod tests {
// Second identical, This should take the early return path
assert!(expected.index().is_ok());
// Get the episode
let old = dbqueries::get_episode_from_pk(expected.title(), expected.show_id()).unwrap();
let old = dbqueries::get_episode_from_pk(expected.title(), expected.show_id())?;
// Assert that NewPodcast is equal to the Indexed one
assert_eq!(*expected, old);
@ -629,31 +657,33 @@ mod tests {
// Update the podcast
assert!(updated.index().is_ok());
// Get the new Podcast
let new = dbqueries::get_episode_from_pk(expected.title(), expected.show_id()).unwrap();
let new = dbqueries::get_episode_from_pk(expected.title(), expected.show_id())?;
// Assert it's diff from the old one.
assert_ne!(new, old);
assert_eq!(*updated, new);
assert_eq!(new.rowid(), old.rowid());
assert_eq!(new.show_id(), old.show_id());
Ok(())
}
#[test]
fn test_new_episode_to_episode() {
fn test_new_episode_to_episode() -> Result<(), Error> {
let expected = &*EXPECTED_INTERCEPTED_1;
// Assert insert() produces the same result that you would get with to_podcast()
truncate_db().unwrap();
expected.insert().unwrap();
let old = dbqueries::get_episode_from_pk(expected.title(), expected.show_id()).unwrap();
let ep = expected.to_episode().unwrap();
truncate_db()?;
expected.insert()?;
let old = dbqueries::get_episode_from_pk(expected.title(), expected.show_id())?;
let ep = expected.to_episode()?;
assert_eq!(old, ep);
// Same as above, diff order
truncate_db().unwrap();
let ep = expected.to_episode().unwrap();
truncate_db()?;
let ep = expected.to_episode()?;
// This should error as a unique constrain violation
assert!(expected.insert().is_err());
let old = dbqueries::get_episode_from_pk(expected.title(), expected.show_id()).unwrap();
let old = dbqueries::get_episode_from_pk(expected.title(), expected.show_id())?;
assert_eq!(old, ep);
Ok(())
}
}

View File

@ -1,16 +1,35 @@
// new_show.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
use ammonia;
use diesel;
use diesel::prelude::*;
use rss;
use errors::DataError;
use models::Show;
use models::{Index, Insert, Update};
use schema::shows;
use crate::errors::DataError;
use crate::models::Show;
use crate::models::{Index, Insert, Update};
use crate::schema::shows;
use database::connection;
use dbqueries;
use utils::url_cleaner;
use crate::database::connection;
use crate::dbqueries;
use crate::utils::url_cleaner;
#[derive(Insertable, AsChangeset)]
#[table_name = "shows"]
@ -30,7 +49,7 @@ impl Insert<()> for NewShow {
type Error = DataError;
fn insert(&self) -> Result<(), Self::Error> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
let db = connection();
let con = db.get()?;
@ -46,7 +65,7 @@ impl Update<()> for NewShow {
type Error = DataError;
fn update(&self, show_id: i32) -> Result<(), Self::Error> {
use schema::shows::dsl::*;
use crate::schema::shows::dsl::*;
let db = connection();
let con = db.get()?;
@ -157,10 +176,11 @@ mod tests {
use super::*;
// use tokio_core::reactor::Core;
use failure::Error;
use rss::Channel;
use database::truncate_db;
use models::NewShowBuilder;
use crate::database::truncate_db;
use crate::models::NewShowBuilder;
use std::fs::File;
use std::io::BufReader;
@ -289,73 +309,80 @@ mod tests {
}
#[test]
fn test_new_podcast_intercepted() {
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_podcast_intercepted() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let pd = NewShow::new(&channel, 42);
assert_eq!(*EXPECTED_INTERCEPTED, pd);
Ok(())
}
#[test]
fn test_new_podcast_lup() {
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_podcast_lup() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let pd = NewShow::new(&channel, 42);
assert_eq!(*EXPECTED_LUP, pd);
Ok(())
}
#[test]
fn test_new_podcast_thetipoff() {
let file = File::open("tests/feeds/2018-01-20-TheTipOff.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_podcast_thetipoff() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-01-20-TheTipOff.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let pd = NewShow::new(&channel, 42);
assert_eq!(*EXPECTED_TIPOFF, pd);
Ok(())
}
#[test]
fn test_new_podcast_steal_the_stars() {
let file = File::open("tests/feeds/2018-01-20-StealTheStars.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_podcast_steal_the_stars() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-01-20-StealTheStars.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let pd = NewShow::new(&channel, 42);
assert_eq!(*EXPECTED_STARS, pd);
Ok(())
}
#[test]
fn test_new_podcast_greater_than_code() {
let file = File::open("tests/feeds/2018-01-20-GreaterThanCode.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_podcast_greater_than_code() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-01-20-GreaterThanCode.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let pd = NewShow::new(&channel, 42);
assert_eq!(*EXPECTED_CODE, pd);
Ok(())
}
#[test]
fn test_new_podcast_ellinofreneia() {
let file = File::open("tests/feeds/2018-03-28-Ellinofreneia.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_podcast_ellinofreneia() -> Result<(), Error> {
let file = File::open("tests/feeds/2018-03-28-Ellinofreneia.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let pd = NewShow::new(&channel, 42);
assert_eq!(*EXPECTED_ELLINOFRENEIA, pd);
Ok(())
}
#[test]
// This maybe could be a doc test on insert.
fn test_new_podcast_insert() {
truncate_db().unwrap();
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap();
let channel = Channel::read_from(BufReader::new(file)).unwrap();
fn test_new_podcast_insert() -> Result<(), Error> {
truncate_db()?;
let file = File::open("tests/feeds/2018-01-20-Intercepted.xml")?;
let channel = Channel::read_from(BufReader::new(file))?;
let npd = NewShow::new(&channel, 42);
npd.insert().unwrap();
let pd = dbqueries::get_podcast_from_source_id(42).unwrap();
npd.insert()?;
let pd = dbqueries::get_podcast_from_source_id(42)?;
assert_eq!(npd, pd);
assert_eq!(*EXPECTED_INTERCEPTED, npd);
assert_eq!(&*EXPECTED_INTERCEPTED, &pd);
Ok(())
}
#[test]
@ -363,31 +390,32 @@ mod tests {
// Currently there's a test that only checks new description or title.
// If you have time and want to help, implement the test for the other fields
// too.
fn test_new_podcast_update() {
truncate_db().unwrap();
let old = EXPECTED_INTERCEPTED.to_podcast().unwrap();
fn test_new_podcast_update() -> Result<(), Error> {
truncate_db()?;
let old = EXPECTED_INTERCEPTED.to_podcast()?;
let updated = &*UPDATED_DESC_INTERCEPTED;
updated.update(old.id()).unwrap();
let new = dbqueries::get_podcast_from_source_id(42).unwrap();
updated.update(old.id())?;
let new = dbqueries::get_podcast_from_source_id(42)?;
assert_ne!(old, new);
assert_eq!(old.id(), new.id());
assert_eq!(old.source_id(), new.source_id());
assert_eq!(updated, &new);
assert_ne!(updated, &old);
Ok(())
}
#[test]
fn test_new_podcast_index() {
truncate_db().unwrap();
fn test_new_podcast_index() -> Result<(), Error> {
truncate_db()?;
// First insert
assert!(EXPECTED_INTERCEPTED.index().is_ok());
// Second identical, This should take the early return path
assert!(EXPECTED_INTERCEPTED.index().is_ok());
// Get the podcast
let old = dbqueries::get_podcast_from_source_id(42).unwrap();
let old = dbqueries::get_podcast_from_source_id(42)?;
// Assert that NewShow is equal to the Indexed one
assert_eq!(&*EXPECTED_INTERCEPTED, &old);
@ -396,28 +424,30 @@ mod tests {
// Update the podcast
assert!(updated.index().is_ok());
// Get the new Show
let new = dbqueries::get_podcast_from_source_id(42).unwrap();
let new = dbqueries::get_podcast_from_source_id(42)?;
// Assert it's diff from the old one.
assert_ne!(new, old);
assert_eq!(new.id(), old.id());
assert_eq!(new.source_id(), old.source_id());
Ok(())
}
#[test]
fn test_to_podcast() {
fn test_to_podcast() -> Result<(), Error> {
// Assert insert() produces the same result that you would get with to_podcast()
truncate_db().unwrap();
EXPECTED_INTERCEPTED.insert().unwrap();
let old = dbqueries::get_podcast_from_source_id(42).unwrap();
let pd = EXPECTED_INTERCEPTED.to_podcast().unwrap();
truncate_db()?;
EXPECTED_INTERCEPTED.insert()?;
let old = dbqueries::get_podcast_from_source_id(42)?;
let pd = EXPECTED_INTERCEPTED.to_podcast()?;
assert_eq!(old, pd);
// Same as above, diff order
truncate_db().unwrap();
let pd = EXPECTED_INTERCEPTED.to_podcast().unwrap();
truncate_db()?;
let pd = EXPECTED_INTERCEPTED.to_podcast()?;
// This should error as a unique constrain violation
assert!(EXPECTED_INTERCEPTED.insert().is_err());
let old = dbqueries::get_podcast_from_source_id(42).unwrap();
let old = dbqueries::get_podcast_from_source_id(42)?;
assert_eq!(old, pd);
Ok(())
}
}

View File

@ -1,13 +1,32 @@
// new_source.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
use diesel;
use diesel::prelude::*;
use url::Url;
use database::connection;
use dbqueries;
use crate::database::connection;
use crate::dbqueries;
// use models::{Insert, Update};
use errors::DataError;
use models::Source;
use schema::source;
use crate::errors::DataError;
use crate::models::Source;
use crate::schema::source;
#[derive(Insertable)]
#[table_name = "source"]
@ -31,7 +50,7 @@ impl NewSource {
}
pub(crate) fn insert_or_ignore(&self) -> Result<(), DataError> {
use schema::source::dsl::*;
use crate::schema::source::dsl::*;
let db = connection();
let con = db.get()?;

View File

@ -1,9 +1,24 @@
use diesel::SaveChangesDsl;
// show.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
use database::connection;
use errors::DataError;
use models::{Save, Source};
use schema::shows;
use crate::models::Source;
use crate::schema::shows;
#[derive(Queryable, Identifiable, AsChangeset, Associations, PartialEq)]
#[belongs_to(Source, foreign_key = "source_id")]
@ -20,19 +35,6 @@ pub struct Show {
source_id: i32,
}
impl Save<Show> for Show {
type Error = DataError;
/// Helper method to easily save/"sync" current state of self to the
/// Database.
fn save(&self) -> Result<Show, Self::Error> {
let db = connection();
let tempdb = db.get()?;
self.save_changes::<Show>(&*tempdb).map_err(From::from)
}
}
impl Show {
/// Get the Feed `id`.
pub fn id(&self) -> i32 {
@ -51,21 +53,11 @@ impl Show {
&self.link
}
/// Set the Show/Feed `link`.
pub fn set_link(&mut self, value: &str) {
self.link = value.to_string();
}
/// Get the `description`.
pub fn description(&self) -> &str {
&self.description
}
/// Set the `description`.
pub fn set_description(&mut self, value: &str) {
self.description = value.to_string();
}
/// Get the `image_uri`.
///
/// Represents the uri(url usually) that the Feed cover image is located at.
@ -73,11 +65,6 @@ impl Show {
self.image_uri.as_ref().map(|s| s.as_str())
}
/// Set the `image_uri`.
pub fn set_image_uri(&mut self, value: Option<&str>) {
self.image_uri = value.map(|x| x.to_string());
}
/// `Source` table foreign key.
pub fn source_id(&self) -> i32 {
self.source_id

View File

@ -0,0 +1,358 @@
// source.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
use diesel::SaveChangesDsl;
// use failure::ResultExt;
use rss::Channel;
use url::Url;
use hyper::client::HttpConnector;
use hyper::{Body, Client};
use hyper_tls::HttpsConnector;
use http::header::{
HeaderValue, AUTHORIZATION, ETAG, IF_MODIFIED_SINCE, IF_NONE_MATCH, LAST_MODIFIED, LOCATION,
USER_AGENT as USER_AGENT_HEADER,
};
use http::{Request, Response, StatusCode, Uri};
// use futures::future::ok;
use futures::future::{loop_fn, Future, Loop};
use futures::prelude::*;
use base64::{encode_config, URL_SAFE};
use crate::database::connection;
use crate::errors::*;
use crate::feed::{Feed, FeedBuilder};
use crate::models::{NewSource, Save};
use crate::schema::source;
use crate::USER_AGENT;
use std::str::FromStr;
#[derive(Queryable, Identifiable, AsChangeset, PartialEq)]
#[table_name = "source"]
#[changeset_options(treat_none_as_null = "true")]
#[derive(Debug, Clone)]
/// Diesel Model of the source table.
pub struct Source {
id: i32,
uri: String,
last_modified: Option<String>,
http_etag: Option<String>,
}
impl Save<Source> for Source {
type Error = DataError;
/// Helper method to easily save/"sync" current state of self to the
/// Database.
fn save(&self) -> Result<Source, Self::Error> {
let db = connection();
let con = db.get()?;
self.save_changes::<Source>(&*con).map_err(From::from)
}
}
impl Source {
/// Get the source `id` column.
pub fn id(&self) -> i32 {
self.id
}
/// Represents the location(usually url) of the Feed xml file.
pub fn uri(&self) -> &str {
&self.uri
}
/// Set the `uri` field value.
pub fn set_uri(&mut self, uri: String) {
self.uri = uri;
}
/// Represents the Http Last-Modified Header field.
///
/// See [RFC 7231](https://tools.ietf.org/html/rfc7231#section-7.2) for more.
pub fn last_modified(&self) -> Option<&str> {
self.last_modified.as_ref().map(|s| s.as_str())
}
/// Set `last_modified` value.
pub fn set_last_modified(&mut self, value: Option<String>) {
// self.last_modified = value.map(|x| x.to_string());
self.last_modified = value;
}
/// Represents the Http Etag Header field.
///
/// See [RFC 7231](https://tools.ietf.org/html/rfc7231#section-7.2) for more.
pub fn http_etag(&self) -> Option<&str> {
self.http_etag.as_ref().map(|s| s.as_str())
}
/// Set `http_etag` value.
pub fn set_http_etag(&mut self, value: Option<&str>) {
self.http_etag = value.map(|x| x.to_string());
}
/// Extract Etag and LastModifier from res, and update self and the
/// corresponding db row.
fn update_etag(mut self, res: &Response<Body>) -> Result<Self, DataError> {
let headers = res.headers();
let etag = headers
.get(ETAG)
.and_then(|h| h.to_str().ok())
.map(From::from);
let lmod = headers
.get(LAST_MODIFIED)
.and_then(|h| h.to_str().ok())
.map(From::from);
if (self.http_etag() != etag) || (self.last_modified != lmod) {
self.set_http_etag(etag);
self.set_last_modified(lmod);
self = self.save()?;
}
Ok(self)
}
/// Clear the `HTTP` `Etag` and `Last-modified` headers.
/// This method does not sync the state of self in the database, call
/// .save() method explicitly
fn clear_etags(&mut self) {
debug!("Source etags before clear: {:#?}", &self);
self.http_etag = None;
self.last_modified = None;
}
fn make_err(self, context: &str, code: StatusCode) -> DataError {
DataError::HttpStatusGeneral(HttpStatusError::new(self.uri, code, context.into()))
}
// TODO match on more stuff
// 301: Moved Permanently
// 304: Up to date Feed, checked with the Etag
// 307: Temporary redirect of the url
// 308: Permanent redirect of the url
// 401: Unathorized
// 403: Forbidden
// 408: Timeout
// 410: Feed deleted
// TODO: Rething this api,
fn match_status(mut self, res: Response<Body>) -> Result<Response<Body>, DataError> {
let code = res.status();
if code.is_success() {
// If request is succesful save the etag
self = self.update_etag(&res)?
} else {
match code.as_u16() {
// Save etags if it returns NotModified
304 => self = self.update_etag(&res)?,
// Clear the Etag/lmod else
_ => {
self.clear_etags();
self = self.save()?;
}
};
};
match code.as_u16() {
304 => {
info!("304: Source, (id: {}), is up to date", self.id());
return Err(DataError::FeedNotModified(self));
}
301 | 302 | 308 => {
warn!("Feed was moved permanently.");
self = self.update_url(&res)?;
return Err(DataError::FeedRedirect(self));
}
307 => {
warn!("307: Temporary Redirect.");
// FIXME: How is it actually handling the redirect?
return Err(DataError::FeedRedirect(self));
}
401 => return Err(self.make_err("401: Unauthorized.", code)),
403 => return Err(self.make_err("403: Forbidden.", code)),
404 => return Err(self.make_err("404: Not found.", code)),
408 => return Err(self.make_err("408: Request Timeout.", code)),
410 => return Err(self.make_err("410: Feed was deleted..", code)),
_ => info!("HTTP StatusCode: {}", code),
};
Ok(res)
}
fn update_url(mut self, res: &Response<Body>) -> Result<Self, DataError> {
let code = res.status();
let headers = res.headers();
info!("HTTP StatusCode: {}", code);
debug!("Headers {:#?}", headers);
if let Some(url) = headers.get(LOCATION) {
debug!("Previous Source: {:#?}", &self);
self.set_uri(url.to_str()?.into());
self.clear_etags();
self = self.save()?;
debug!("Updated Source: {:#?}", &self);
info!(
"Feed url of Source {}, was updated successfully.",
self.id()
);
}
Ok(self)
}
/// Construct a new `Source` with the given `uri` and index it.
///
/// This only indexes the `Source` struct, not the Podcast Feed.
pub fn from_url(uri: &str) -> Result<Source, DataError> {
let url = Url::parse(uri)?;
NewSource::new(&url).to_source()
}
/// `Feed` constructor.
///
/// Fetches the latest xml Feed.
///
/// Updates the validator Http Headers.
///
/// Consumes `self` and Returns the corresponding `Feed` Object.
// Refactor into TryInto once it lands on stable.
pub fn into_feed(
self,
client: Client<HttpsConnector<HttpConnector>>,
) -> impl Future<Item = Feed, Error = DataError> {
let id = self.id();
let response = loop_fn(self, move |source| {
source
.request_constructor(&client.clone())
.then(|res| match res {
Ok(response) => Ok(Loop::Break(response)),
Err(err) => match err {
DataError::FeedRedirect(s) => {
info!("Following redirect...");
Ok(Loop::Continue(s))
}
e => Err(e),
},
})
});
response
.and_then(response_to_channel)
.and_then(move |chan| {
FeedBuilder::default()
.channel(chan)
.source_id(id)
.build()
.map_err(From::from)
})
}
fn request_constructor(
self,
client: &Client<HttpsConnector<HttpConnector>>,
) -> impl Future<Item = Response<Body>, Error = DataError> {
// FIXME: remove unwrap somehow
let uri = Uri::from_str(self.uri()).unwrap();
let mut req = Request::get(uri).body(Body::empty()).unwrap();
if let Ok(url) = Url::parse(self.uri()) {
if let Some(password) = url.password() {
let mut auth = "Basic ".to_owned();
auth.push_str(&encode_config(
&format!("{}:{}", url.username(), password),
URL_SAFE,
));
req.headers_mut()
.insert(AUTHORIZATION, HeaderValue::from_str(&auth).unwrap());
}
}
// Set the UserAgent cause ppl still seem to check it for some reason...
req.headers_mut()
.insert(USER_AGENT_HEADER, HeaderValue::from_static(USER_AGENT));
if let Some(etag) = self.http_etag() {
req.headers_mut()
.insert(IF_NONE_MATCH, HeaderValue::from_str(etag).unwrap());
}
if let Some(lmod) = self.last_modified() {
req.headers_mut()
.insert(IF_MODIFIED_SINCE, HeaderValue::from_str(lmod).unwrap());
}
client
.request(req)
.map_err(From::from)
.and_then(move |res| self.match_status(res))
}
}
fn response_to_channel(
res: Response<Body>,
) -> impl Future<Item = Channel, Error = DataError> + Send {
res.into_body()
.concat2()
.map(|x| x.into_iter())
.map_err(From::from)
.map(|iter| iter.collect::<Vec<u8>>())
.map(|utf_8_bytes| String::from_utf8_lossy(&utf_8_bytes).into_owned())
.and_then(|buf| Channel::from_str(&buf).map_err(From::from))
}
#[cfg(test)]
mod tests {
use super::*;
use failure::Error;
use num_cpus;
use tokio;
use crate::database::truncate_db;
use crate::utils::get_feed;
#[test]
fn test_into_feed() -> Result<(), Error> {
truncate_db()?;
let mut rt = tokio::runtime::Runtime::new()?;
let https = HttpsConnector::new(num_cpus::get())?;
let client = Client::builder().build::<_, Body>(https);
let url = "https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\
com/InterceptedWithJeremyScahill";
let source = Source::from_url(url)?;
let id = source.id();
let feed = source.into_feed(client);
let feed = rt.block_on(feed)?;
let expected = get_feed("tests/feeds/2018-01-20-Intercepted.xml", id);
assert_eq!(expected, feed);
Ok(())
}
}

355
podcasts-data/src/opml.rs Normal file
View File

@ -0,0 +1,355 @@
// opml.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//! FIXME: Docs
// #![allow(unused)]
use crate::dbqueries;
use crate::errors::DataError;
use crate::models::Source;
use xml::{
common::XmlVersion,
reader,
writer::{events::XmlEvent, EmitterConfig},
};
use std::collections::HashSet;
use std::fs;
use std::io::{Read, Write};
use std::path::Path;
use std::fs::File;
// use std::io::BufReader;
use failure::Error;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
// FIXME: Make it a Diesel model
/// Represents an `outline` xml element as per the `OPML` [specification][spec]
/// not `RSS` related sub-elements are omitted.
///
/// [spec]: http://dev.opml.org/spec2.html
pub struct Opml {
title: String,
description: String,
url: String,
}
/// Import feed url's from a `R` into the `Source` table.
// TODO: Write test
pub fn import_to_db<R: Read>(reader: R) -> Result<Vec<Source>, reader::Error> {
let feeds = extract_sources(reader)?
.iter()
.map(|opml| Source::from_url(&opml.url))
.filter_map(|s| {
if let Err(ref err) = s {
let txt = "If you think this might be a bug please consider filling a report over \
at https://gitlab.gnome.org/World/podcasts/issues/new";
error!("Failed to import a Show: {}", err);
error!("{}", txt);
}
s.ok()
})
.collect();
Ok(feeds)
}
/// Open a File from `P`, try to parse the OPML then insert the Feeds in the database and
/// return the new `Source`s
// TODO: Write test
pub fn import_from_file<P: AsRef<Path>>(path: P) -> Result<Vec<Source>, DataError> {
let content = fs::read(path)?;
import_to_db(content.as_slice()).map_err(From::from)
}
/// Export a file to `P`, taking the feeds from the database and outputting
/// them in opml format.
pub fn export_from_db<P: AsRef<Path>>(path: P, export_title: &str) -> Result<(), Error> {
let file = File::create(path)?;
export_to_file(&file, export_title)
}
/// Export from `Source`s and `Show`s into `F` in OPML format
pub fn export_to_file<F: Write>(file: F, export_title: &str) -> Result<(), Error> {
let config = EmitterConfig::new().perform_indent(true);
let mut writer = config.create_writer(file);
let mut events: Vec<XmlEvent<'_>> = Vec::new();
// Set up headers
let doc = XmlEvent::StartDocument {
version: XmlVersion::Version10,
encoding: Some("UTF-8"),
standalone: Some(false),
};
events.push(doc);
let opml: XmlEvent<'_> = XmlEvent::start_element("opml")
.attr("version", "2.0")
.into();
events.push(opml);
let head: XmlEvent<'_> = XmlEvent::start_element("head").into();
events.push(head);
let title_ev: XmlEvent<'_> = XmlEvent::start_element("title").into();
events.push(title_ev);
let title_chars: XmlEvent<'_> = XmlEvent::characters(export_title).into();
events.push(title_chars);
// Close <title> & <head>
events.push(XmlEvent::end_element().into());
events.push(XmlEvent::end_element().into());
let body: XmlEvent<'_> = XmlEvent::start_element("body").into();
events.push(body);
for event in events {
writer.write(event)?;
}
// FIXME: Make this a model of a joined query (http://docs.diesel.rs/diesel/macro.joinable.html)
let shows = dbqueries::get_podcasts()?.into_iter().map(|show| {
let source = dbqueries::get_source_from_id(show.source_id()).unwrap();
(source, show)
});
for (ref source, ref show) in shows {
let title = show.title();
let link = show.link();
let xml_url = source.uri();
let s_ev: XmlEvent<'_> = XmlEvent::start_element("outline")
.attr("text", title)
.attr("title", title)
.attr("type", "rss")
.attr("xmlUrl", xml_url)
.attr("htmlUrl", link)
.into();
let end_ev: XmlEvent<'_> = XmlEvent::end_element().into();
writer.write(s_ev)?;
writer.write(end_ev)?;
}
// Close <body> and <opml>
let end_bod: XmlEvent<'_> = XmlEvent::end_element().into();
writer.write(end_bod)?;
let end_opml: XmlEvent<'_> = XmlEvent::end_element().into();
writer.write(end_opml)?;
Ok(())
}
/// Extracts the `outline` elements from a reader `R` and returns a `HashSet` of `Opml` structs.
pub fn extract_sources<R: Read>(reader: R) -> Result<HashSet<Opml>, reader::Error> {
let mut list = HashSet::new();
let parser = reader::EventReader::new(reader);
parser
.into_iter()
.map(|e| match e {
Ok(reader::XmlEvent::StartElement {
name, attributes, ..
}) => {
if name.local_name == "outline" {
let mut title = String::new();
let mut url = String::new();
let mut description = String::new();
attributes.into_iter().for_each(|attribute| {
match attribute.name.local_name.as_str() {
"title" => title = attribute.value,
"xmlUrl" => url = attribute.value,
"description" => description = attribute.value,
_ => {}
}
});
let feed = Opml {
title,
description,
url,
};
list.insert(feed);
}
Ok(())
}
Err(err) => Err(err),
_ => Ok(()),
})
.collect::<Result<Vec<_>, reader::Error>>()?;
Ok(list)
}
#[cfg(test)]
mod tests {
use super::*;
use chrono::Local;
use failure::Error;
use futures::Future;
use crate::database::{truncate_db, TEMPDIR};
use crate::utils::get_feed;
const URLS: &[(&str, &str)] = {
&[
(
"tests/feeds/2018-01-20-Intercepted.xml",
"https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\
com/InterceptedWithJeremyScahill",
),
(
"tests/feeds/2018-01-20-LinuxUnplugged.xml",
"https://web.archive.org/web/20180120110314if_/https://feeds.feedburner.\
com/linuxunplugged",
),
(
"tests/feeds/2018-01-20-TheTipOff.xml",
"https://web.archive.org/web/20180120110727if_/https://rss.acast.com/thetipoff",
),
(
"tests/feeds/2018-01-20-StealTheStars.xml",
"https://web.archive.org/web/20180120104957if_/https://rss.art19.\
com/steal-the-stars",
),
(
"tests/feeds/2018-01-20-GreaterThanCode.xml",
"https://web.archive.org/web/20180120104741if_/https://www.greaterthancode.\
com/feed/podcast",
),
(
"tests/feeds/2019-01-27-ACC.xml",
"https://web.archive.org/web/20190127005213if_/https://anticapitalistchronicles.libsyn.com/rss"
),
]
};
#[test]
fn test_extract() -> Result<(), Error> {
let int_title = String::from("Intercepted with Jeremy Scahill");
let int_url = String::from("https://feeds.feedburner.com/InterceptedWithJeremyScahill");
let int_desc = String::from(
"The people behind The Intercepts fearless reporting and incisive \
commentaryJeremy Scahill, Glenn Greenwald, Betsy Reed and othersdiscuss the \
crucial issues of our time: national security, civil liberties, foreign policy, \
and criminal justice. Plus interviews with artists, thinkers, and newsmakers \
who challenge our preconceptions about the world we live in.",
);
let dec_title = String::from("Deconstructed with Mehdi Hasan");
let dec_url = String::from("https://rss.prod.firstlook.media/deconstructed/podcast.rss");
let dec_desc = String::from(
"Journalist Mehdi Hasan is known around the world for his televised takedowns of \
presidents and prime ministers. In this new podcast from The Intercept, Mehdi \
unpacks a game-changing news event of the week while challenging the conventional \
wisdom. As a Brit, a Muslim and an immigrant based in Donald Trump's Washington \
D.C., Mehdi gives a refreshingly provocative perspective on the ups and downs of \
Americanand globalpolitics.",
);
#[cfg_attr(rustfmt, rustfmt_skip)]
let sample1 = format!(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?> \
<opml version=\"2.0\"> \
<head> \
<title>Test OPML File</title> \
<dateCreated>{}</dateCreated> \
<docs>http://www.opml.org/spec2</docs> \
</head> \
<body> \
<outline type=\"rss\" title=\"{}\" description=\"{}\" xmlUrl=\"{}\"/> \
<outline type=\"rss\" title=\"{}\" description=\"{}\" xmlUrl=\"{}\"/> \
</body> \
</opml>",
Local::now().format("%a, %d %b %Y %T %Z"),
int_title,
int_desc,
int_url,
dec_title,
dec_desc,
dec_url,
);
let map = hashset![
Opml {
title: int_title,
description: int_desc,
url: int_url
},
Opml {
title: dec_title,
description: dec_desc,
url: dec_url
},
];
assert_eq!(extract_sources(sample1.as_bytes())?, map);
Ok(())
}
#[test]
fn text_export() -> Result<(), Error> {
truncate_db()?;
URLS.iter().for_each(|&(path, url)| {
// Create and insert a Source into db
let s = Source::from_url(url).unwrap();
let feed = get_feed(path, s.id());
feed.index().wait().unwrap();
});
let mut map: HashSet<Opml> = HashSet::new();
let shows = dbqueries::get_podcasts()?.into_iter().map(|show| {
let source = dbqueries::get_source_from_id(show.source_id()).unwrap();
(source, show)
});
for (ref source, ref show) in shows {
let title = show.title().to_string();
// description is an optional field that we don't export
let description = String::new();
let url = source.uri().to_string();
map.insert(Opml {
title,
description,
url,
});
}
let opml_path = TEMPDIR.path().join("podcasts.opml");
export_from_db(opml_path.as_path(), "GNOME Podcasts Subscriptions")?;
let opml_file = File::open(opml_path.as_path())?;
assert_eq!(extract_sources(&opml_file)?, map);
// extract_sources drains the reader its passed
let mut opml_file = File::open(opml_path.as_path())?;
let mut opml_str = String::new();
opml_file.read_to_string(&mut opml_str)?;
assert_eq!(opml_str, include_str!("../tests/export_test.opml"));
Ok(())
}
}

View File

@ -1,3 +1,22 @@
// parser.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
use rss::extension::itunes::ITunesItemExtension;
/// Parses an Item Itunes extension and returns it's duration value in seconds.
@ -77,5 +96,4 @@ mod tests {
let item = Some(&extension);
assert_eq!(parse_itunes_duration(item), Some(6970));
}
}

View File

@ -0,0 +1,133 @@
// pipeline.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
// FIXME:
//! Docs.
use futures::{future::ok, lazy, prelude::*, stream::FuturesUnordered};
use tokio;
use hyper::client::HttpConnector;
use hyper::{Body, Client};
use hyper_tls::HttpsConnector;
use num_cpus;
use crate::errors::DataError;
use crate::Source;
use std::iter::FromIterator;
type HttpsClient = Client<HttpsConnector<HttpConnector>>;
/// The pipline to be run for indexing and updating a Podcast feed that originates from
/// `Source.uri`.
///
/// Messy temp diagram:
/// Source -> GET Request -> Update Etags -> Check Status -> Parse `xml/Rss` ->
/// Convert `rss::Channel` into `Feed` -> Index Podcast -> Index Episodes.
pub fn pipeline<'a, S>(sources: S, client: HttpsClient) -> impl Future<Item = (), Error = ()> + 'a
where
S: Stream<Item = Source, Error = DataError> + Send + 'a,
{
sources
.and_then(move |s| s.into_feed(client.clone()))
.map_err(|err| {
match err {
// Avoid spamming the stderr when its not an eactual error
DataError::FeedNotModified(_) => (),
_ => error!("Error: {}", err),
}
})
.and_then(move |feed| {
let fut = lazy(|| feed.index().map_err(|err| error!("Error: {}", err)));
tokio::spawn(fut);
Ok(())
})
// For each terminates the stream at the first error so we make sure
// we pass good values regardless
.then(move |_| ok(()))
// Convert the stream into a Future to later execute as a tokio task
.for_each(move |_| ok(()))
}
/// Creates a tokio `reactor::Core`, and a `hyper::Client` and
/// runs the pipeline to completion. The `reactor::Core` is dropped afterwards.
pub fn run<S>(sources: S) -> Result<(), DataError>
where
S: IntoIterator<Item = Source>,
{
let https = HttpsConnector::new(num_cpus::get())?;
let client = Client::builder().build::<_, Body>(https);
let foo = sources.into_iter().map(ok::<_, _>);
let stream = FuturesUnordered::from_iter(foo);
let p = pipeline(stream, client);
tokio::run(p);
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
use crate::database::truncate_db;
use crate::dbqueries;
use crate::Source;
use failure::Error;
// (path, url) tuples.
const URLS: &[&str] = &[
"https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\
com/InterceptedWithJeremyScahill",
"https://web.archive.org/web/20180120110314if_/https://feeds.feedburner.com/linuxunplugged",
"https://web.archive.org/web/20180120110727if_/https://rss.acast.com/thetipoff",
"https://web.archive.org/web/20180120104957if_/https://rss.art19.com/steal-the-stars",
"https://web.archive.org/web/20180120104741if_/https://www.greaterthancode.\
com/feed/podcast",
];
#[test]
/// Insert feeds and update/index them.
fn test_pipeline() -> Result<(), Error> {
truncate_db()?;
let bad_url = "https://gitlab.gnome.org/World/podcasts.atom";
// if a stream returns error/None it stops
// bad we want to parse all feeds regardless if one fails
Source::from_url(bad_url)?;
URLS.iter().for_each(|url| {
// Index the urls into the source table.
Source::from_url(url).unwrap();
});
let sources = dbqueries::get_sources()?;
run(sources)?;
let sources = dbqueries::get_sources()?;
// Run again to cover Unique constrains erros.
run(sources)?;
// Assert the index rows equal the controlled results
assert_eq!(dbqueries::get_sources()?.len(), 6);
assert_eq!(dbqueries::get_podcasts()?.len(), 5);
assert_eq!(dbqueries::get_episodes()?.len(), 354);
Ok(())
}
}

View File

@ -1,7 +1,7 @@
diff --git a/hammond-data/src/schema.rs b/hammond-data/src/schema.rs
diff --git a/podcasts-data/src/schema.rs b/podcasts-data/src/schema.rs
index 03cbed0..88f1622 100644
--- a/hammond-data/src/schema.rs
+++ b/hammond-data/src/schema.rs
--- a/podcasts-data/src/schema.rs
+++ b/podcasts-data/src/schema.rs
@@ -1,8 +1,11 @@
+#![allow(warnings)]
+

View File

@ -1,3 +1,22 @@
// utils.rs
//
// Copyright 2017 Jordan Petridis <jpetridis@gnome.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: GPL-3.0-or-later
//! Helper utilities for accomplishing various tasks.
use chrono::prelude::*;
@ -5,10 +24,10 @@ use rayon::prelude::*;
use url::{Position, Url};
use dbqueries;
use errors::DataError;
use models::{EpisodeCleanerModel, Save, Show};
use xdg_dirs::DL_DIR;
use crate::dbqueries;
use crate::errors::DataError;
use crate::models::{EpisodeCleanerModel, Save, Show};
use crate::xdg_dirs::DL_DIR;
use std::fs;
use std::path::Path;
@ -37,7 +56,7 @@ fn download_checker() -> Result<(), DataError> {
Ok(())
}
/// Delete watched `episodes` that have exceded their liftime after played.
/// Delete watched `episodes` that have exceeded their lifetime after played.
fn played_cleaner(cleanup_date: DateTime<Utc>) -> Result<(), DataError> {
let mut episodes = dbqueries::get_played_cleaner_episodes()?;
let now_utc = cleanup_date.timestamp() as i32;
@ -49,7 +68,7 @@ fn played_cleaner(cleanup_date: DateTime<Utc>) -> Result<(), DataError> {
let limit = ep.played().unwrap();
if now_utc > limit {
delete_local_content(ep)
.map(|_| info!("Episode {:?} was deleted succesfully.", ep.local_uri()))
.map(|_| info!("Episode {:?} was deleted successfully.", ep.local_uri()))
.map_err(|err| error!("Error: {}", err))
.map_err(|_| error!("Failed to delete file: {:?}", ep.local_uri()))
.ok();
@ -103,7 +122,7 @@ pub fn url_cleaner(s: &str) -> String {
// https://rust-lang-nursery.github.io/rust-cookbook/net.html
// #remove-fragment-identifiers-and-query-pairs-from-a-url
match Url::parse(s) {
Ok(parsed) => parsed[..Position::AfterPath].to_owned(),
Ok(parsed) => parsed[..Position::AfterQuery].to_owned(),
_ => s.trim().to_owned(),
}
}
@ -125,24 +144,23 @@ pub fn get_download_folder(pd_title: &str) -> Result<String, DataError> {
// TODO: Write Tests
pub fn delete_show(pd: &Show) -> Result<(), DataError> {
dbqueries::remove_feed(pd)?;
info!("{} was removed succesfully.", pd.title());
info!("{} was removed successfully.", pd.title());
let fold = get_download_folder(pd.title())?;
fs::remove_dir_all(&fold)?;
info!("All the content at, {} was removed succesfully", &fold);
info!("All the content at, {} was removed successfully", &fold);
Ok(())
}
#[cfg(test)]
use Feed;
use crate::Feed;
#[cfg(test)]
/// Helper function that open a local file, parse the rss::Channel and gives back a Feed object.
/// Alternative Feed constructor to be used for tests.
pub fn get_feed(file_path: &str, id: i32) -> Feed {
use feed::FeedBuilder;
use crate::feed::FeedBuilder;
use rss::Channel;
use std::fs;
use std::io::BufReader;
// open the xml file
@ -158,27 +176,26 @@ pub fn get_feed(file_path: &str, id: i32) -> Feed {
#[cfg(test)]
mod tests {
extern crate tempdir;
use self::tempdir::TempDir;
use super::*;
use chrono::Duration;
use failure::Error;
use tempdir::TempDir;
use database::truncate_db;
use models::NewEpisodeBuilder;
use crate::database::truncate_db;
use crate::models::NewEpisodeBuilder;
use std::fs::File;
use std::io::Write;
fn helper_db() -> TempDir {
fn helper_db() -> Result<TempDir, Error> {
// Clean the db
truncate_db().unwrap();
truncate_db()?;
// Setup tmp file stuff
let tmp_dir = TempDir::new("hammond_test").unwrap();
let tmp_dir = TempDir::new("podcasts_test")?;
let valid_path = tmp_dir.path().join("virtual_dl.mp3");
let bad_path = tmp_dir.path().join("invalid_thing.mp3");
let mut tmp_file = File::create(&valid_path).unwrap();
writeln!(tmp_file, "Foooo").unwrap();
let mut tmp_file = File::create(&valid_path)?;
writeln!(tmp_file, "Foooo")?;
// Setup episodes
let n1 = NewEpisodeBuilder::default()
@ -186,33 +203,31 @@ mod tests {
.show_id(0)
.build()
.unwrap()
.to_episode()
.unwrap();
.to_episode()?;
let n2 = NewEpisodeBuilder::default()
.title("bar_baz".to_string())
.show_id(1)
.build()
.unwrap()
.to_episode()
.unwrap();
.to_episode()?;
let mut ep1 = dbqueries::get_episode_from_pk(n1.title(), n1.show_id()).unwrap();
let mut ep2 = dbqueries::get_episode_from_pk(n2.title(), n2.show_id()).unwrap();
let mut ep1 = dbqueries::get_episode_cleaner_from_pk(n1.title(), n1.show_id())?;
let mut ep2 = dbqueries::get_episode_cleaner_from_pk(n2.title(), n2.show_id())?;
ep1.set_local_uri(Some(valid_path.to_str().unwrap()));
ep2.set_local_uri(Some(bad_path.to_str().unwrap()));
ep1.save().unwrap();
ep2.save().unwrap();
ep1.save()?;
ep2.save()?;
tmp_dir
Ok(tmp_dir)
}
#[test]
fn test_download_checker() {
let tmp_dir = helper_db();
download_checker().unwrap();
let episodes = dbqueries::get_downloaded_episodes().unwrap();
fn test_download_checker() -> Result<(), Error> {
let tmp_dir = helper_db()?;
download_checker()?;
let episodes = dbqueries::get_downloaded_episodes()?;
let valid_path = tmp_dir.path().join("virtual_dl.mp3");
assert_eq!(episodes.len(), 1);
@ -221,69 +236,75 @@ mod tests {
episodes.first().unwrap().local_uri()
);
let _tmp_dir = helper_db();
download_checker().unwrap();
let episode = dbqueries::get_episode_from_pk("bar_baz", 1).unwrap();
let _tmp_dir = helper_db()?;
download_checker()?;
let episode = dbqueries::get_episode_cleaner_from_pk("bar_baz", 1)?;
assert!(episode.local_uri().is_none());
Ok(())
}
#[test]
fn test_download_cleaner() {
let _tmp_dir = helper_db();
fn test_download_cleaner() -> Result<(), Error> {
let _tmp_dir = helper_db()?;
let mut episode: EpisodeCleanerModel =
dbqueries::get_episode_from_pk("foo_bar", 0).unwrap().into();
dbqueries::get_episode_cleaner_from_pk("foo_bar", 0)?.into();
let valid_path = episode.local_uri().unwrap().to_owned();
delete_local_content(&mut episode).unwrap();
delete_local_content(&mut episode)?;
assert_eq!(Path::new(&valid_path).exists(), false);
Ok(())
}
#[test]
fn test_played_cleaner_expired() {
let _tmp_dir = helper_db();
let mut episode = dbqueries::get_episode_from_pk("foo_bar", 0).unwrap();
fn test_played_cleaner_expired() -> Result<(), Error> {
let _tmp_dir = helper_db()?;
let mut episode = dbqueries::get_episode_cleaner_from_pk("foo_bar", 0)?;
let cleanup_date = Utc::now() - Duration::seconds(1000);
let epoch = cleanup_date.timestamp() as i32 - 1;
episode.set_played(Some(epoch));
episode.save().unwrap();
episode.save()?;
let valid_path = episode.local_uri().unwrap().to_owned();
// This should delete the file
played_cleaner(cleanup_date).unwrap();
played_cleaner(cleanup_date)?;
assert_eq!(Path::new(&valid_path).exists(), false);
Ok(())
}
#[test]
fn test_played_cleaner_none() {
let _tmp_dir = helper_db();
let mut episode = dbqueries::get_episode_from_pk("foo_bar", 0).unwrap();
fn test_played_cleaner_none() -> Result<(), Error> {
let _tmp_dir = helper_db()?;
let mut episode = dbqueries::get_episode_cleaner_from_pk("foo_bar", 0)?;
let cleanup_date = Utc::now() - Duration::seconds(1000);
let epoch = cleanup_date.timestamp() as i32 + 1;
episode.set_played(Some(epoch));
episode.save().unwrap();
episode.save()?;
let valid_path = episode.local_uri().unwrap().to_owned();
// This should not delete the file
played_cleaner(cleanup_date).unwrap();
played_cleaner(cleanup_date)?;
assert_eq!(Path::new(&valid_path).exists(), true);
Ok(())
}
#[test]
fn test_url_cleaner() {
let good_url = "http://traffic.megaphone.fm/FL8608731318.mp3";
let bad_url = "http://traffic.megaphone.fm/FL8608731318.mp3?updated=1484685184";
fn test_url_cleaner() -> Result<(), Error> {
let good_url = "http://traffic.megaphone.fm/FL8608731318.mp3?updated=1484685184";
let bad_url = "http://traffic.megaphone.fm/FL8608731318.mp3?updated=1484685184#foobar";
assert_eq!(url_cleaner(bad_url), good_url);
assert_eq!(url_cleaner(good_url), good_url);
assert_eq!(url_cleaner(&format!(" {}\t\n", bad_url)), good_url);
Ok(())
}
#[test]
// This test needs access to local system so we ignore it by default.
#[ignore]
fn test_get_dl_folder() {
fn test_get_dl_folder() -> Result<(), Error> {
let foo_ = format!("{}/{}", DL_DIR.to_str().unwrap(), "foo");
assert_eq!(get_download_folder("foo").unwrap(), foo_);
assert_eq!(get_download_folder("foo")?, foo_);
let _ = fs::remove_dir_all(foo_);
Ok(())
}
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<opml version="2.0">
<head>
<title>GNOME Podcasts Subscriptions</title>
</head>
<body>
<outline text="David Harvey&apos;s Anti-Capitalist Chronicles" title="David Harvey&apos;s Anti-Capitalist Chronicles" type="rss" xmlUrl="https://web.archive.org/web/20190127005213if_/https://anticapitalistchronicles.libsyn.com/rss" htmlUrl="https://www.democracyatwork.info/acc" />
<outline text="Greater Than Code" title="Greater Than Code" type="rss" xmlUrl="https://web.archive.org/web/20180120104741if_/https://www.greaterthancode.com/feed/podcast" htmlUrl="https://www.greaterthancode.com/" />
<outline text="Intercepted with Jeremy Scahill" title="Intercepted with Jeremy Scahill" type="rss" xmlUrl="https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.com/InterceptedWithJeremyScahill" htmlUrl="https://theintercept.com/podcasts" />
<outline text="LINUX Unplugged Podcast" title="LINUX Unplugged Podcast" type="rss" xmlUrl="https://web.archive.org/web/20180120110314if_/https://feeds.feedburner.com/linuxunplugged" htmlUrl="http://www.jupiterbroadcasting.com/" />
<outline text="Steal the Stars" title="Steal the Stars" type="rss" xmlUrl="https://web.archive.org/web/20180120104957if_/https://rss.art19.com/steal-the-stars" htmlUrl="http://tor-labs.com/" />
<outline text="The Tip Off" title="The Tip Off" type="rss" xmlUrl="https://web.archive.org/web/20180120110727if_/https://rss.acast.com/thetipoff" htmlUrl="http://www.acast.com/thetipoff" />
</body>
</opml>

View File

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:cc="http://web.resource.org/cc/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<channel>
<atom:link href="https://anticapitalistchronicles.libsyn.com/rss" rel="self" type="application/rss+xml"/>
<title>David Harvey's Anti-Capitalist Chronicles</title>
<pubDate>Thu, 17 Jan 2019 05:00:00 +0000</pubDate>
<lastBuildDate>Thu, 17 Jan 2019 05:06:40 +0000</lastBuildDate>
<generator>Libsyn WebEngine 2.0</generator>
<link>https://www.democracyatwork.info/acc</link>
<language>en</language>
<copyright><![CDATA[Democracy at Work 2018]]></copyright>
<docs>https://www.democracyatwork.info/acc</docs>
<managingEditor>info@democracyatwork.info (info@democracyatwork.info)</managingEditor>
<itunes:summary><![CDATA[The Anti-Capitalist Chronicles look at capitalism through a Marxist lens. Support the show on Patreon and get early access to episodes and more: https://www.patreon.com/davidharveyacc]]></itunes:summary>
<image>
<url>https://ssl-static.libsyn.com/p/assets/0/9/2/b/092b811513b710af/ACC_Logo_Final_LibsynSize.png</url>
<title>David Harvey's Anti-Capitalist Chronicles</title>
<link><![CDATA[https://www.democracyatwork.info/acc]]></link>
</image>
<itunes:author>David Harvey</itunes:author>
<itunes:keywords>capitalism,economics,marxism,politics</itunes:keywords>
<itunes:category text="News &amp; Politics"/>
<itunes:category text="Education"></itunes:category>
<itunes:image href="https://ssl-static.libsyn.com/p/assets/0/9/2/b/092b811513b710af/ACC_Logo_Final_LibsynSize.png" />
<itunes:explicit>clean</itunes:explicit>
<itunes:owner>
<itunes:name><![CDATA[Democracy at Work]]></itunes:name>
<itunes:email>acc@democracyatwork.info</itunes:email>
</itunes:owner>
<description><![CDATA[The Anti-Capitalist Chronicles look at capitalism through a Marxist lens. Support the show on Patreon and get early access to episodes and more: https://www.patreon.com/davidharveyacc ]]></description>
<itunes:subtitle><![CDATA[]]></itunes:subtitle>
<itunes:type>episodic</itunes:type>
<item>
<title>The significance of China in the Global Economy</title>
<itunes:title>The significance of China in the Global Economy</itunes:title>
<pubDate>Thu, 17 Jan 2019 05:00:00 +0000</pubDate>
<guid isPermaLink="false"><![CDATA[b64981bbe26247e19e66f1c9c14a332a]]></guid>
<link><![CDATA[http://anticapitalistchronicles.libsyn.com/the-significance-of-china-in-the-global-economy]]></link>
<itunes:image href="https://ssl-static.libsyn.com/p/assets/0/9/2/b/092b811513b710af/ACC_Logo_Final_LibsynSize.png" />
<description><![CDATA[<p>The Chinese economy is now the 2nd largest in the world. Prof. Harvey argues that China's expansion saved capitalism after the 2008 crash.</p>]]></description>
<content:encoded><![CDATA[<p>The Chinese economy is now the 2nd largest in the world. Prof. Harvey argues that China's expansion saved capitalism after the 2008 crash.</p>]]></content:encoded>
<enclosure length="106240847" type="audio/mpeg" url="https://traffic.libsyn.com/secure/anticapitalistchronicles/ACC_S1_E07.mp3?dest-id=796288" />
<itunes:duration>44:15</itunes:duration>
<itunes:explicit>clean</itunes:explicit>
<itunes:keywords />
<itunes:subtitle><![CDATA[The Chinese economy is now the 2nd largest in the world. Prof. Harvey argues that China's expansion saved capitalism after the 2008 crash.]]></itunes:subtitle>
<itunes:summary>The Chinese economy is now the 2nd largest in the world. Prof. Harvey argues that China's expansion saved capitalism after the 2008 crash.</itunes:summary>
<itunes:season>1</itunes:season>
<itunes:episode>7</itunes:episode>
<itunes:episodeType>full</itunes:episodeType>
<itunes:author>Democracy at Work</itunes:author>
</item>
<item>
<title>Does Socialism Affect Freedom?</title>
<itunes:title>Does Socialism Affect Freedom? </itunes:title>
<pubDate>Thu, 03 Jan 2019 05:00:00 +0000</pubDate>
<guid isPermaLink="false"><![CDATA[3fe5b10d8f6045d7a65bc3de64f23277]]></guid>
<link><![CDATA[http://anticapitalistchronicles.libsyn.com/does-socialism-affect-freedom]]></link>
<itunes:image href="https://ssl-static.libsyn.com/p/assets/0/9/2/b/092b811513b710af/ACC_Logo_Final_LibsynSize.png" />
<description><![CDATA[<p>Does socialism require the surrender of individual freedom? The realm of freedom begins when the realm of necessity is left behind. Is freedom of the market real freedom?  And what about justice?  Prof. Harvey tries to answer these questions and more.</p>]]></description>
<content:encoded><![CDATA[<p>Does socialism require the surrender of individual freedom? The realm of freedom begins when the realm of necessity is left behind. Is freedom of the market real freedom?  And what about justice?  Prof. Harvey tries to answer these questions and more.</p>]]></content:encoded>
<enclosure length="60112942" type="audio/mpeg" url="https://traffic.libsyn.com/secure/anticapitalistchronicles/acc_ep06_Does_socialism_affect_freedom.mp3?dest-id=796288" />
<itunes:duration>25:02</itunes:duration>
<itunes:explicit>clean</itunes:explicit>
<itunes:keywords />
<itunes:subtitle><![CDATA[Does socialism require the surrender of individual freedom? The realm of freedom begins when the realm of necessity is left behind. Is freedom of the market real freedom?  And what about justice?  Prof. Harvey tries to answer these questions...]]></itunes:subtitle>
<itunes:summary>Does socialism require the surrender of individual freedom? The realm of freedom begins when the realm of necessity is left behind. Is freedom of the market real freedom?  And what about justice?  Prof. Harvey tries to answer these questions and more.</itunes:summary>
<itunes:season>1</itunes:season>
<itunes:episode>6</itunes:episode>
<itunes:episodeType>full</itunes:episodeType>
<itunes:author>Democracy at Work</itunes:author>
</item>
<item>
<title>The Value of Everything</title>
<itunes:title>"The Value of Everything</itunes:title>
<pubDate>Thu, 13 Dec 2018 05:00:00 +0000</pubDate>
<guid isPermaLink="false"><![CDATA[6ca8e36116924b4f8b1ebeb1b6c35bae]]></guid>
<link><![CDATA[http://anticapitalistchronicles.libsyn.com/the-value-of-everything]]></link>
<itunes:image href="https://ssl-static.libsyn.com/p/assets/0/9/2/b/092b811513b710af/ACC_Logo_Final_LibsynSize.png" />
<description><![CDATA[<p>Prof. Harvey talks about Mariana Mazzucato's new book "The Value of Everything: Making and Taking in the Global Economy."</p>]]></description>
<content:encoded><![CDATA[<p>Prof. Harvey talks about Mariana Mazzucato's new book "The Value of Everything: Making and Taking in the Global Economy."</p>]]></content:encoded>
<enclosure length="60810663" type="audio/mpeg" url="https://traffic.libsyn.com/secure/anticapitalistchronicles/acc_ep05_2018.10_pt2.mp3?dest-id=796288" />
<itunes:duration>25:19</itunes:duration>
<itunes:explicit>clean</itunes:explicit>
<itunes:keywords />
<itunes:subtitle><![CDATA[Prof. Harvey talks about Mariana Mazzucato's new book "The Value of Everything: Making and Taking in the Global Economy."]]></itunes:subtitle>
<itunes:summary>Prof. Harvey talks about Mariana Mazzucato's new book "The Value of Everything: Making and Taking in the Global Economy."</itunes:summary>
<itunes:season>1</itunes:season>
<itunes:episode>5</itunes:episode>
<itunes:episodeType>full</itunes:episodeType>
<itunes:author>Democracy at Work</itunes:author>
</item>
<item>
<title>The Brazilian Elections</title>
<itunes:title>The Brazilian Elections</itunes:title>
<pubDate>Thu, 29 Nov 2018 05:00:00 +0000</pubDate>
<guid isPermaLink="false"><![CDATA[f76a6e81de1c44db847b5424f7b338de]]></guid>
<link><![CDATA[http://anticapitalistchronicles.libsyn.com/the-brazilian-elections]]></link>
<itunes:image href="https://ssl-static.libsyn.com/p/assets/0/9/2/b/092b811513b710af/ACC_Logo_Final_LibsynSize.png" />
<description><![CDATA[<p>Prof. Harvey talks about the recent Brazilian elections and the growing alliance between Neo-liberalism and Right-Wing Populism.</p>]]></description>
<content:encoded><![CDATA[<p>Prof. Harvey talks about the recent Brazilian elections and the growing alliance between Neo-liberalism and Right-Wing Populism.</p>]]></content:encoded>
<enclosure length="72984484" type="audio/mpeg" url="https://traffic.libsyn.com/secure/anticapitalistchronicles/acc_ep04_2018.10_pt1.mp3?dest-id=796288" />
<itunes:duration>30:23</itunes:duration>
<itunes:explicit>clean</itunes:explicit>
<itunes:keywords />
<itunes:subtitle><![CDATA[Prof. Harvey talks about the recent Brazilian elections and the growing alliance between Neo-liberalism and Right-Wing Populism.]]></itunes:subtitle>
<itunes:summary>Prof. Harvey talks about the recent Brazilian elections and the growing alliance between Neo-liberalism and Right-Wing Populism.</itunes:summary>
<itunes:season>1</itunes:season>
<itunes:episode>4</itunes:episode>
<itunes:episodeType>full</itunes:episodeType>
<itunes:author>Democracy at Work</itunes:author>
</item>
<item>
<title>The Financialization of Power</title>
<itunes:title>The Financialization of Power</itunes:title>
<pubDate>Thu, 15 Nov 2018 13:10:00 +0000</pubDate>
<guid isPermaLink="false"><![CDATA[e4641accc886461dbcbef94775532adc]]></guid>
<link><![CDATA[http://anticapitalistchronicles.libsyn.com/the-financialization-of-power]]></link>
<itunes:image href="https://ssl-static.libsyn.com/p/assets/a/4/d/7/a4d743af97f5ad8e/ACC_Logo_IconOnly_LibsynSize.png" />
<description><![CDATA[<p>Financial services become part of GDP in the 1970s and legitimize the power of financial institutions. </p>]]></description>
<content:encoded><![CDATA[<p>Financial services become part of GDP in the 1970s and legitimize the power of financial institutions. </p>]]></content:encoded>
<enclosure length="46686237" type="audio/mpeg" url="https://traffic.libsyn.com/secure/anticapitalistchronicles/acc_ep03_2018.09.mp3?dest-id=796288" />
<itunes:duration>19:27</itunes:duration>
<itunes:explicit>no</itunes:explicit>
<itunes:keywords />
<itunes:subtitle><![CDATA[Financial services become part of GDP in the 1970s and legitimize the power of financial institutions. ]]></itunes:subtitle>
<itunes:summary>Financial services become part of GDP in the 1970s and legitimize the power of financial institutions. </itunes:summary>
<itunes:season>1</itunes:season>
<itunes:episode>3</itunes:episode>
<itunes:episodeType>full</itunes:episodeType>
<itunes:author>Democracy at Work</itunes:author>
</item>
<item>
<title>Contradictions of Neo-Liberalism</title>
<itunes:title>The Contradictions of Neo-Liberalism</itunes:title>
<pubDate>Thu, 15 Nov 2018 13:05:00 +0000</pubDate>
<guid isPermaLink="false"><![CDATA[a4f0d0206b8d4572b8e54764a39c8a48]]></guid>
<link><![CDATA[http://anticapitalistchronicles.libsyn.com/contradictions-of-neo-liberalism]]></link>
<itunes:image href="https://ssl-static.libsyn.com/p/assets/9/b/e/d/9bed97160a2d6344/ACC_Logo_IconOnly_LibsynSize.png" />
<description><![CDATA[<p>The crash of 2008 challenges Neo-Liberalism.</p>]]></description>
<content:encoded><![CDATA[<p>The crash of 2008 challenges Neo-Liberalism.</p>]]></content:encoded>
<enclosure length="45500801" type="audio/mpeg" url="https://traffic.libsyn.com/secure/anticapitalistchronicles/acc_ep02_2018.09.mp3?dest-id=796288" />
<itunes:duration>18:58</itunes:duration>
<itunes:explicit>clean</itunes:explicit>
<itunes:keywords />
<itunes:subtitle><![CDATA[The crash of 2008 challenges Neo-Liberalism.]]></itunes:subtitle>
<itunes:summary>The crash of 2008 challenge Neo-Liberalism.</itunes:summary>
<itunes:season>1</itunes:season>
<itunes:episode>2</itunes:episode>
<itunes:episodeType>full</itunes:episodeType>
<itunes:author>Democracy at Work</itunes:author>
</item>
<item>
<title>A brief history of Neo-Liberalism</title>
<itunes:title>A brief history of Neo-Liberalism</itunes:title>
<pubDate>Mon, 12 Nov 2018 22:01:39 +0000</pubDate>
<guid isPermaLink="false"><![CDATA[3daeb566cd964764a5847da4f2a6a309]]></guid>
<link><![CDATA[http://anticapitalistchronicles.libsyn.com/a-brief-history-of-neo-liberalism]]></link>
<itunes:image href="https://ssl-static.libsyn.com/p/assets/0/7/e/0/07e073ebe1b26e3f/ACC_Logo_IconOnly_LibsynSize.png" />
<description><![CDATA[<p>Prof. David Harvey's pilot episode. He provides a quick history of the rise and growth of Neo-Liberalism. </p> <p>Support the show on Patreon and get early access to episodes and more: https://www.patreon.com/davidharveyacc</p>]]></description>
<content:encoded><![CDATA[<p>Prof. David Harvey's pilot episode. He provides a quick history of the rise and growth of Neo-Liberalism. </p> <p>Support the show on Patreon and get early access to episodes and more: https://www.patreon.com/davidharveyacc</p>]]></content:encoded>
<enclosure length="47001933" type="audio/mpeg" url="https://traffic.libsyn.com/secure/anticapitalistchronicles/acc_ep01_2018.09.mp3?dest-id=796288" />
<itunes:duration>19:35</itunes:duration>
<itunes:explicit>clean</itunes:explicit>
<itunes:keywords />
<itunes:subtitle><![CDATA[Prof. David Harvey's pilot episode. He provides a quick history of the rise and growth of Neo-Liberalism.  Support the show on Patreon and get early access to episodes and more: https://www.patreon.com/davidharveyacc]]></itunes:subtitle>
<itunes:summary>Prof. David Harvey's pilot episode. He provides a quick history of the rise and growth of Neo-Liberalism.
Support the show on Patreon and get early access to episodes and more: https://www.patreon.com/davidharveyacc</itunes:summary>
<itunes:season>1</itunes:season>
<itunes:episode>1</itunes:episode>
<itunes:episodeType>full</itunes:episodeType>
<itunes:author>Democracy at Work</itunes:author>
</item>
</channel>
</rss>

View File

@ -42,4 +42,10 @@ Raw file: https://web.archive.org/web/20180120104741if_/https://www.greaterthanc
Web view: https://web.archive.org/web/20180328083913/https://ellinofreneia.sealabs.net/audio/podcast.rss
Raw file: https://web.archive.org/web/20180328083913if_/https://ellinofreneia.sealabs.net/audio/podcast.rss
Raw file: https://web.archive.org/web/20180328083913if_/https://ellinofreneia.sealabs.net/audio/podcast.rss
#### David Harvey's Anti-Capitalist Chronicles
Web view: https://web.archive.org/web/20190127005213/https://anticapitalistchronicles.libsyn.com/rss
Raw file: https://web.archive.org/web/20190127005213if_/https://anticapitalistchronicles.libsyn.com/rss

View File

@ -0,0 +1,20 @@
[package]
authors = ["Jordan Petridis <jpetridis@gnome.org>"]
name = "podcasts-downloader"
version = "0.1.0"
edition = "2018"
[dependencies]
log = "0.4.8"
mime_guess = "2.0.3"
reqwest = "0.9.22"
tempdir = "0.3.7"
glob = "0.3.0"
failure = "0.1.8"
failure_derive = "0.1.8"
[dependencies.podcasts-data]
path = "../podcasts-data"
[dev-dependencies]
pretty_assertions = "0.6.1"

Some files were not shown because too many files have changed in this diff Show More