pid recursive and exclude

MacFH - C E Macfarlane - News news at macfh.co.uk
Tue Mar 4 02:35:19 PST 2025


On 2025-03-04 09:14, Dean Bennett wrote:
> Hi
> Does anyone know if or how I get the -exclude option to work with pid recursive
> I am downloading comedy of the week from the command line.
> Using
> get_iplayer --pid=p02pc9x6 --pid-recursive  --sortreverse --quality=396p --type=radio --file-prefix="<firstbcastdate> <nameshort> <.senum> <.episodeshort> <.pid> --exclude "Janey Godley,Newsjack" --output "F:\Media\radio"
> however it keeps downloading the programs included in the exclude statement
> I have tried it with and without the quotes and no change
> I did try
> get_iplayer janey godley
> and it brought up this list
>   Matches:
> 36111:  radio, Janey Godley: The C Bomb: Series 2 - 2. It Was Acceptable in the 70s, BBC Radio 4, m001x53c
> 36112:  radio, Janey Godley: The C Bomb: Series 2 - 3. Motherhood, Marriage and George Clooney, BBC Radio 4, m001xdgt
> 36113:  radio, Janey Godley: The C Bomb: Series 2 - 4. Friends, Enemies and a Big Decision, BBC Radio 4, m001xmgs
> INFO: 3 matching programmes
> And then
> get_iplayer janey godley --exclude "Janey godley"
>
> and it brought up this
>
> INFO: 0 matching programmes
>
> So obviously it works to some extent
>
> I cant seem to find any examples in the help file and its driving me mad
>
> Any suggestions would be appreciated. Maybe it just does not work

No, natively I'm afraid it doesn't, at least not without changing the
script, which I do every time I upgrade to the latest version; I copy a
raft of personal modifications from the previous version to the latest
one.  Currently I'm running v3.34, and in this version, lines 1007-1016,
which are in the subroutine find_pid_matches, read as follows:

	for my $ep ( @ep_list ) {
			my $this;
			if ( $prog->{$ep->{pid}}->{pid} ) {
				$this = $prog->{$ep->{pid}};
			} else {
				$this = $ep;
			}
			push @match_list, $this;
	}
	if ( @match_list ) {

I alter these to read (beware possible unintended line-wrap):

	for my $ep ( @ep_list ) {
			my $this;
			if ( $prog->{$ep->{pid}}->{pid} ) {
				$this = $prog->{$ep->{pid}};
			} else {
				$this = $ep;
			}
			push @match_list, $this;
	}
	# CEM change
	if ( @match_list && $opt->{exclude} )
		{
		my $exclude_regex = '('.(join '|', ( split /,/, $opt->{exclude} ) ).')';
		logger "DEBUG: \$exclude_regex = $exclude_regex\n" if $opt->{verbose};
		# Determine fields to search
		my @searchfields;
		# User-defined fields list
		if ( $opt->{fields} )
			{
			@searchfields = split /\s*,\s*/, lc( $opt->{fields} );
			}
		# Search long descriptions and episode data if -l is specified
		elsif ( $opt->{long} )
			{
			@searchfields = ( 'name', 'episode', 'desc' );
			}
		# Default is name search only
		 else
		 	{
			@searchfields = ( 'name' );
			}
		my $ep = 0;
		do
			{
			for my $field ( @searchfields )
				{
				if ( $match_list[$ep]->{$field} =~ /$exclude_regex/i )
					{
					splice(@match_list, $ep, 1);
					last;
					}
				}
			$ep++;
			}
		while ( $ep < scalar @match_list );
		}
         # End of CEM change
	if ( @match_list ) {

If you decide to try editing your script, use Notepad or similar, not a
word processor, and MAKE A BACK UP COPY OF IT FIRST, in case you foul up.

I have a raft of other such changes I copy over every time I upgrade,
and one very useful one, not included in the above edit, allows one to
prefix the value of certain command-line options with a + sign, which
means that the value is merged with/added to defaults from the options
file rather than overwriting them.  Primarily I devised this because I'd
get pissed off when wishing to exclude particular programs to download,
only to find that when I gave an exclude option, cruddy programmes
previously excluded by the options file would start downloading, so all
that had been gained by the exclude option was to get different crud.




More information about the get_iplayer mailing list