Repository navigation
URL parsing that keeps up with how Youtube links are actually shared today, and a way to page through a channel's playlists. Additive only, so this is a drop-in upgrade from 1.3.0, with one narrow behaviour change noted under Changed.
Added
parseVIdFromURL()now understands Shorts URLs (youtube.com/shorts/xxxx).
Reported in #79 by
@malbero.parseVIdFromURL()now understands two further path forms:
youtube.com/live/xxxx, which is what live streams and the VODs they leave
behind are shared as, and the legacy embed URLyoutube.com/v/xxxx, which is
still present in a lot of older content. Both accept a query string and a
trailing slash, and both work with or withoutwwwand with or without a
scheme, exactly as/embed/and/shorts/already did. Requested in
#85.getPlaylistsByChannelIdAdvanced($params, $pageInfo = false), which takes raw
playlists.listparameters and can return the pagination envelope alongside
the results.getPlaylistsByChannelId()returned one page and gave the caller
no way to readnextPageToken, so a channel with more playlists than a single
page holds was silently truncated; passing apageTokenthrough$paramsand
reading the next one back frominfonow walks the whole channel.
getPlaylistsByChannelId()is unchanged for existing callers and is now a thin
wrapper over the new method, the same waygetPlaylistItemsByPlaylistId()
wraps its own...Advanced()counterpart. Originally proposed in
#71 by
@tyteck.
Changed
getPlaylistsByChannelId()now rejects anullchannel id before making a
request, throwingInvalidArgumentExceptionthe way the other...Advanced()
methods already do for their required ids. Previously thenullwas passed
through as an emptychannelIdparameter and the request was sent anyway, so
the caller paid a quota unit to have the API reject it. Any other value,
including the empty string, reaches the API exactly as before. Callers that
catch\Exceptionare unaffected, sinceInvalidArgumentExceptionextends it.
Fixed
parseVIdFromURL()discarded the video id whenever a path-style URL carried a
query string, because the?v=branch assignednullunconditionally when no
vparameter was present.youtube.com/embed/xxxx?start=30and
youtube.com/shorts/xxxx?feature=shareboth threw
"The supplied URL does not look like a Youtube URL". A?v=parameter still
takes precedence when one is actually present. Also from
#79./embed/was matched anywhere in the URL rather than at the start of the path,
so the id was parsed from the wrong offset for URLs that merely contained the
word. Both/embed/and/shorts/are now matched as path prefixes, and only
the first path segment is taken as the id, so a trailing slash is no longer
included in the returned id.- A short URL written with a trailing slash,
youtu.be/xxxx/, returned the id
with the slash still attached (xxxx/), which then produced 404s from the API
for anyone passing the result straight through. Theyoutu.bebranch took the
whole path rather than its first segment; it now follows the same rule as the
path-prefix forms. Reported alongside
#85.
Full changelog: v1.3.0...v1.4.0