Function: hsys-youtube-end-url

hsys-youtube-end-url is an autoloaded and byte-compiled function defined in hsys-youtube.el.

Signature

(hsys-youtube-end-url VIDEO-ID &optional START-TIME-STRING END-TIME-STRING)

Documentation

Return url to play VIDEO-ID from optional START-TIME-STRING to END-TIME-STRING.

VIDEO-ID must be a string and can be a video identifier, e.g. WkwZHSbHmPg, or a full url to the video.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hsys-youtube.el
;;; ************************************************************************
;;; Private functions
;;; ************************************************************************

;;;###autoload
(defun hsys-youtube-end-url (video-id &optional start-time-string end-time-string)
  "Return url to play VIDEO-ID from optional START-TIME-STRING to END-TIME-STRING.
VIDEO-ID must be a string and can be a video identifier,
e.g. WkwZHSbHmPg, or a full url to the video."
  (if (or (null video-id)
	  (not (stringp video-id))
	  (string-empty-p video-id))
      (error "(hsys-youtube-end-url): Invalid 'video-id': '%s'" video-id)
    (setq start-time-string (if (stringp start-time-string)
				(hsys-youtube-time-in-seconds start-time-string)
			      "0")
	  end-time-string (if (stringp end-time-string)
			      (hsys-youtube-time-in-seconds end-time-string)
			    "-1"))
    (format "%s&rand=%d"
	    (if (string-match-p hsys-youtube-url-prefix-regexp video-id)
		(if (string-match-p "[?&]\\(start\\|end\\)=" video-id)
		    video-id
		  (format (concat video-id "?autoplay=1&start=%s&end=%s")
			  start-time-string end-time-string))
	      (format hsys-youtube-end-format video-id start-time-string end-time-string))
	    ;; Need to change the URL each time is called to force
	    ;; replay, so add unused random parameter.
	    (random 10000000))))