Skip to content

1.4.0

Latest

Choose a tag to compare

@madcoda madcoda released this 27 Jul 12:39

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 URL youtube.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 without www and with or without a
    scheme, exactly as /embed/ and /shorts/ already did. Requested in
    #85.
  • getPlaylistsByChannelIdAdvanced($params, $pageInfo = false), which takes raw
    playlists.list parameters and can return the pagination envelope alongside
    the results. getPlaylistsByChannelId() returned one page and gave the caller
    no way to read nextPageToken, so a channel with more playlists than a single
    page holds was silently truncated; passing a pageToken through $params and
    reading the next one back from info now walks the whole channel.
    getPlaylistsByChannelId() is unchanged for existing callers and is now a thin
    wrapper over the new method, the same way getPlaylistItemsByPlaylistId()
    wraps its own ...Advanced() counterpart. Originally proposed in
    #71 by
    @tyteck.

Changed

  • getPlaylistsByChannelId() now rejects a null channel id before making a
    request, throwing InvalidArgumentException the way the other ...Advanced()
    methods already do for their required ids. Previously the null was passed
    through as an empty channelId parameter 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 \Exception are unaffected, since InvalidArgumentException extends it.

Fixed

  • parseVIdFromURL() discarded the video id whenever a path-style URL carried a
    query string, because the ?v= branch assigned null unconditionally when no
    v parameter was present. youtube.com/embed/xxxx?start=30 and
    youtube.com/shorts/xxxx?feature=share both 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. The youtu.be branch 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