These forums are archived

See this post for further info

get_iplayer forums

Forum archived. Posting disabled.

How do I match full programme names with regex?

user-2167

Unless I'm misunderstanding something, I think there might be a problem with the regex searching in programme names.

Here's the last few results from a query for some snooker:

Code:
$ get_iplayer "^Snooker:\sWorld\sChampionship:\s2018" | tail
6258: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Morning Session, BBC Two, b0b2q9dd
6259: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session Part 2, BBC Two, b0b2q9dg
6260: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Evening Session, BBC Two, b0b2q9dj
6261: Snooker: World Championship: 2018 - Day 16 Final, Afternoon Session, BBC Two, b0b2qggy
6262: Snooker: World Championship: 2018 - Day 16 Final, Evening Session, BBC Two, b0b2qgh0
6263: Snooker: World Championship: 2018 - Day 17 Final, Afternoon Session, BBC Two, b0b2qmf2
6264: Snooker: World Championship: 2018 - Day 17 Final, Evening Session, BBC Two, b0b2qmf4
6265: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session, BBC One, b0b2wxnf
6266: Snooker: World Championship: 2018 - Day 14 Semi-Finals, Afternoon Session, BBC One, b0b3vj4d
INFO: 44 matching programmes

Looks great. Except... that's as far as the regex will go, adding just one more whitespace to the end causes it to fail when based on perl regex, it should not.

Code:
$ get_iplayer "^Snooker:\sWorld\sChampionship:\s2018\s"
get_iplayer 3.14.0-darwin, Copyright (C) 2008-2010 Phil Lewis
 This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
 This is free software, and you are welcome to redistribute it under certain
 conditions; use --conditions for details.

INFO: 0 matching programmes

As will searching for anything beyond that point in the name, e.g. I can't search for "Semi Final".

Code:
$ get_iplayer "Semi\sFinal"
get_iplayer 3.14.0-darwin, Copyright (C) 2008-2010 Phil Lewis
 This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
 This is free software, and you are welcome to redistribute it under certain
 conditions; use --conditions for details.

INFO: 0 matching programmes

It feels like perhaps "Snooker: World Championship: 2018" is the programme name and thus searchable and the rest is something else that is concatenated with it, but I tried showing just the name field and that shows the same information, so it seems like the "Day 15 Semi-Finals, Morning..." stuff is part of the name.

Code:
$ get_iplayer --fields name "Snooker:\sWorld\sChampionship:\s2018" | tail
6258: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Morning Session, BBC Two, b0b2q9dd
6259: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session Part 2, BBC Two, b0b2q9dg
6260: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Evening Session, BBC Two, b0b2q9dj
6261: Snooker: World Championship: 2018 - Day 16 Final, Afternoon Session, BBC Two, b0b2qggy
6262: Snooker: World Championship: 2018 - Day 16 Final, Evening Session, BBC Two, b0b2qgh0
6263: Snooker: World Championship: 2018 - Day 17 Final, Afternoon Session, BBC Two, b0b2qmf2
6264: Snooker: World Championship: 2018 - Day 17 Final, Evening Session, BBC Two, b0b2qmf4
6265: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session, BBC One, b0b2wxnf
6266: Snooker: World Championship: 2018 - Day 14 Semi-Finals, Afternoon Session, BBC One, b0b3vj4d
INFO: 44 matching programmes

So it's confusing that I can't regex on that. Any ideas?

user-1815

Looks like they are different fields.

Using the Web Pvr interface I see...

Name : Snooker: World Championship: 2018
Episode : Day 3, Morning Session
Description : Masters champion Mark Allen aims to book his place in round two.

user-975

For ease, next time you can just use --info. For example:

get_iplayer --info --pid=b0b2q9dd

user-2100

tv.cache is made up of fields the <space>-<space> is between the two fields name and episode.

Searching on fields name and episode, default is to search on the name field

$ get_iplayer --field name "Snooker: World Championship: 2018" --field episode "Day 15 Semi-Finals"
get_iplayer v3.13, Copyright (C) 2008-2010 Phil Lewis
This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
This is free software, and you are welcome to redistribute it under certain
conditions; use --conditions for details.


Matches:
5951: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Morning Session, BBC Two, b0b2q9dd
5952: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session Part 2, BBC Two, b0b2q9dg
5953: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Evening Session, BBC Two, b0b2q9dj
5958: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session, BBC One, b0b2wxnf
INFO: 4 matching programmes

There is no character after the 2018 apart from end of string 2018\s finds nothing, 2018$ for name field or ^Day 15 work for field episode.

user-2167

Fantastic. Thanks. My experiment using `--fields name` threw me off.

I combed through the docs again, but I can't find a way to intersect the results instead of union. Is there a way?

For example, say I only wanted the Semi-Final of the snooker.

Code:
$ get_iplayer --field name snooker --field episode Semi-Final
get_iplayer 3.14.0-darwin, Copyright (C) 2008-2010 Phil Lewis
  This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
  This is free software, and you are welcome to redistribute it under certain
  conditions; use --conditions for details.


Matches:
1129:    BBC Young Musician: 2018 - Semi-Final, BBC Four, b0b23fm0
2438:    Eurovision Song Contest: 2018 - Semi-Final One, BBC Four, b0b2lz6p
2439:    Eurovision Song Contest: 2018 - Semi-Final Two, BBC Four, b0b2r32h
3398:    Junior Bake Off: Series 4 - The Semi-Final, CBBC, b0844d40
5119:    Only Connect: Series 13 - Semi-Final 1, BBC Four, b0b06sqj
5120:    Only Connect: Series 13 - Semi-Final 2, BBC Four, b0b14wzl
6239:    Snooker: World Championship: 2018 - Day 13 Semi-Finals, Afternoon Session, BBC Two, b0b1yx6s
6240:    Snooker: World Championship: 2018 - Day 13 Semi-Finals, Evening Session, BBC Two, b0b1yx6v
6241:    Snooker: World Championship: 2018 - Day 14 Semi-Finals, Morning Session, BBC Two, b0b1yym2
6242:    Snooker: World Championship: 2018 - Day 14 Semi-Finals, Afternoon Session, BBC Two, b0b1yym4
6243:    Snooker: World Championship: 2018 - Day 14 Semi-Finals, Afternoon Session - Part 2, BBC Two, b0b1yym6
6244:    Snooker: World Championship: 2018 - Day 14 Semi-Finals, Evening Session, BBC Two, b0b1yym8
6246:    Snooker: World Championship: 2018 - Day 15 Semi-Finals, Morning Session, BBC Two, b0b2q9dd
6247:    Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session Part 2, BBC Two, b0b2q9dg
6248:    Snooker: World Championship: 2018 - Day 15 Semi-Finals, Evening Session, BBC Two, b0b2q9dj
6253:    Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session, BBC One, b0b2wxnf
6254:    Snooker: World Championship: 2018 - Day 14 Semi-Finals, Afternoon Session, BBC One, b0b3vj4d
6312:    Songs of Praise - Young Choir of the Year (Junior Semi-Final), BBC One, b0b1zmgm
6313:    Songs of Praise - Young Choir of the Year (Senior Semi-Final), BBC One, b0b2sr0s
7160:    The FA Cup: 2017/18 - Semi-Final: Manchester United v Tottenham Hotspur, BBC One, b0b0h031
7161:    The FA Cup: 2017/18 - Semi-Final Highlights: Manchester United v Tottenham Hotspur, BBC One, b0b0h035
7162:    The FA Cup: 2017/18 - Semi-Final Highlights: Chelsea v Southampton, BBC One, b0b0h637
INFO: 22 matching programmes

user-1815

Your first post's use of tail, shows that you know about piping.

How about filtering on one using get_iplayer then pipe the results through grep to filter on the other?

Would that help?

user-2167

Yes, that is actually what I am doing. I do the basic search in get_iplayer, refine with grep, then extract the pids and get those. It's just a bit of hassle when get_iplayer does very nearly everything I want without having to use additional scripting.

Thanks anyway.

user-2100

--field when there is a list then fields are separated by a space so try
Code:
$ get_iplayer --field name,episode "Snooker.*\sSemi-Final"

get_iplayer Output:


get_iplayer v3.13, Copyright (C) 2008-2010 Phil Lewis
This program comes with ABSOLUTELY NO WARRANTY; for details use --warranty.
This is free software, and you are welcome to redistribute it under certain
conditions; use --conditions for details.


Matches:
5905: Snooker: World Championship: 2018 - Day 13 Semi-Finals, Afternoon Session, BBC Two, b0b1yx6s
5906: Snooker: World Championship: 2018 - Day 13 Semi-Finals, Evening Session, BBC Two, b0b1yx6v
5907: Snooker: World Championship: 2018 - Day 14 Semi-Finals, Morning Session, BBC Two, b0b1yym2
5908: Snooker: World Championship: 2018 - Day 14 Semi-Finals, Afternoon Session, BBC Two, b0b1yym4
5909: Snooker: World Championship: 2018 - Day 14 Semi-Finals, Afternoon Session - Part 2, BBC Two, b0b1yym6
5910: Snooker: World Championship: 2018 - Day 14 Semi-Finals, Evening Session, BBC Two, b0b1yym8
5912: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Morning Session, BBC Two, b0b2q9dd
5913: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session Part 2, BBC Two, b0b2q9dg
5914: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Evening Session, BBC Two, b0b2q9dj
5919: Snooker: World Championship: 2018 - Day 15 Semi-Finals, Afternoon Session, BBC One, b0b2wxnf
5920: Snooker: World Championship: 2018 - Day 14 Semi-Finals, Afternoon Session, BBC One, b0b3vj4d
INFO: 11 matching programmes

user-1699

You need to double up the backslashes. The shell is interpreting them first. So "Semi\sFinal" on the command line is passed to perl as SemisFinal. With doubling "Semi\\sFinal" is passed in as Semi\sFinal

user-2

(19-05-2018, 06:38 PM)You need to double up the backslashes
No, you don't. If that were true, the output above could not have been generated. If you think that is happening to you, follow our instructions to provide a proper report so we can see what is happening on your system. Identify your OS and shell.

user-2167

(19-05-2018, 04:03 PM)--field when there is a list then fields are separated by a space so try
Code:
$ get_iplayer --field name,episode "Snooker.*\sSemi-Final"  

Thank you very much, this is exactly what I needed!

These forums are archived

See this post for further info