Skip to content

Commit eda3a23

Browse files
committed
Merge pull request #5 from gpodder/master
Add new "enqueue in VLC" hook script to demo the new context menu feature
2 parents 125a09d + 72dba58 commit eda3a23

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ This repository contains gPodder hook scripts which I use for myself. Please fee
66

77
### What are hooks in gPodder?
88

9-
Hooks are python scripts in ~/.config/gpodder/hooks. Each script must define a class named "gPodderHooks", otherwise it will be ignored.
9+
Hooks are python scripts loaded by gPodder at runtime. Each script must define a class named "gPodderHooks", otherwise it will be ignored.
1010

1111
### How to configure
1212

1313
You could copy or link the scripts in this repository to ~/.config/gpodder/hooks/ and everything should work fine.
1414

15+
For gPodder "tres" (3.x branch), you need to place them in $GPODDER_HOME/Hooks/ (where $GPODDER_HOME defaults to ~/gPodder/ if you have not set it manually)
16+
1517
### How to create my own hook script?
1618

1719
See example documentation at [hooks.py](http://repo.or.cz/w/gpodder.git/blob/HEAD:/doc/dev/examples/hooks.py).
1820

21+
In the "tres" branch, the example is in examples/hooks.py.
1922

2023
# Hooks list
2124

@@ -131,3 +134,12 @@ This github repository includes two options to configure your gPodder installati
131134

132135
The $subj podcast rss does not contain id and pubdate. Because of the missing guid gPodder reports always "no new episodes" for the podcast.
133136
This hook script fixes this. The pubdate can be calculated from the audio file url and I used the same number as guid.
137+
138+
139+
## enqueue_in_vlc
140+
141+
This hook shows a new feature of the gPodder "tres" branch - you can now add
142+
items to the episode list context menu. Each item needs to have a label and
143+
a callable that will take a list of selected episodes. This script shows you
144+
how to implement a "Enqueue in VLC" context menu item using hooks.
145+

enqueue_in_vlc.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
# Hook script to add a context menu item for enqueueing episodes in a player
3+
# Requirements: gPodder 3.x (or "tres" branch newer than 2011-06-08)
4+
# (c) 2011-06-08 Thomas Perl <thp.io/about>
5+
# Released under the same license terms as gPodder itself.
6+
7+
import gpodder
8+
import subprocess
9+
10+
class gPodderHooks(object):
11+
def _enqueue_episodes(self, episodes):
12+
filenames = [episode.get_playback_url() for episode in episodes]
13+
cmd = ['vlc', '--started-from-file', '--playlist-enqueue'] + filenames
14+
subprocess.Popen(cmd)
15+
16+
def on_episodes_context_menu(self, episodes):
17+
return [('Enqueue in VLC', self._enqueue_episodes)]
18+

0 commit comments

Comments
 (0)