Difference between revisions of "Meta:Create YouTube playlists on-the-fly with semantic queries"

From protonation
Jump to navigation Jump to search
(Νέα σελίδα με '{{under construction}} It is easy to create a YouTube playlist from a query. All you need is the (upgraded) Widget:YouTube from the MediaWiki Widgets extension. ==...')
 
(Yeah, but how do I embed this?)
(3 intermediate revisions by the same user not shown)
Line 17: Line 17:
 
  https://www.youtube.com/watch?v=ntpt0fq3Jn8&list=TLGGUeJrTjDLyMgyMjA1MjAyMA
 
  https://www.youtube.com/watch?v=ntpt0fq3Jn8&list=TLGGUeJrTjDLyMgyMjA1MjAyMA
  
where  
+
where <code>TLGGUeJrTjDLyMgyMjA1MjAyMA</code> is the newly created playlist ID. This playlist ID is as good as any playlist created by a user. You may use it the same way you would use a "proper" playlist ID and it never expires.
  
 
===Yeah, but how do I embed this?===
 
===Yeah, but how do I embed this?===
  
 +
If you click on the YouTube ''share'' button and then select the ''embed'' option you will get a simple iframe code with some control params such as dimensions etc and the embed URL which has the following form:
 +
<nowiki>https://www.youtube.com/embed/</nowiki>'''VIDEO_ID'''
 +
If you try to share a playlist you will get a slightly different URL:
 +
<nowiki>https://www.youtube.com/embed?listType=playlist&list=</nowiki>'''PLAYLIST_ID'''
 +
Note that you need to prepend the playlist ID with the letters <code>PL</code> as shown in the following example:
 +
https://www.youtube.com/embed?listType=playlist&list=PLTLGGUeJrTjDLyMgyMjA1MjAyMA
  
 +
https://www.youtube.com/embed/DoR08T26IPU?playlist=QyPRTblP2-4,OyiNc7zNN9c
  
 +
==Embeding YouTube player in MediWiki==
 +
 +
All the above refer to pure HTML webpages. In MediaWiki we cannot just use iframe code. Instead we can use the [[Widget:YouTube]] which does the embeding.
 +
 +
So, to embed an on-the-fly playlist we use the param <code>idlist</code> with a comma separated list of IDs.
 +
 +
<nowiki>{{#widget:YouTube|id=</nowiki>'''VIDEO_ID_1'''<nowiki>|additionalids=</nowiki>'''VIDEO_ID_2''','''VIDEO_ID_3''', ... ,'''VIDEO_ID_n'''}}
 +
where <code>id</code> is the video ID of the '''first''' video and <code>additionalids</code> is a comma separated list of the '''additional''' video IDs, i.e. from the '''second''' to the n-th one.
 +
 +
For example:
 +
<nowiki>{{#widget:YouTube|id=ntpt0fq3Jn8|additionalids=iZ9vkd7Rp-g,L4GrDOOIIbk}}</nowiki>
  
 
[[Category:Semantic MediaWiki tips]]
 
[[Category:Semantic MediaWiki tips]]

Revision as of 02:01, 23 May 2020

VLC.svg Under construction

This page is under construction.


It is easy to create a YouTube playlist from a query. All you need is the (upgraded) Widget:YouTube from the MediaWiki Widgets extension.

Rationale

YouTube allows the creation of playlists on the fly, i.e. without even logging in, just from the URL. All you need to do is provide the URL with a comma separated list of the video IDs you want to play sequentially.

The URL must have the following form:

https://www.youtube.com/watch_videos?video_ids=ID1,ID2,etc

Think of the above not so much as a URL but rather as a command to YouTube to create a playlist. When YouTube receives this "command" it automatically creates a playlist, as if it was created by a user, and then assigns it a playlist ID as well, which is permanent. Then it redirects you to a "proper" YouTube playlist URL.

For example, if you click this URL:

https://www.youtube.com/watch_videos?video_ids=ntpt0fq3Jn8,iZ9vkd7Rp-g,L4GrDOOIIbk

you will be redirected to this URL:

https://www.youtube.com/watch?v=ntpt0fq3Jn8&list=TLGGUeJrTjDLyMgyMjA1MjAyMA

where TLGGUeJrTjDLyMgyMjA1MjAyMA is the newly created playlist ID. This playlist ID is as good as any playlist created by a user. You may use it the same way you would use a "proper" playlist ID and it never expires.

Yeah, but how do I embed this?

If you click on the YouTube share button and then select the embed option you will get a simple iframe code with some control params such as dimensions etc and the embed URL which has the following form:

https://www.youtube.com/embed/VIDEO_ID

If you try to share a playlist you will get a slightly different URL:

https://www.youtube.com/embed?listType=playlist&list=PLAYLIST_ID

Note that you need to prepend the playlist ID with the letters PL as shown in the following example:

https://www.youtube.com/embed?listType=playlist&list=PLTLGGUeJrTjDLyMgyMjA1MjAyMA
https://www.youtube.com/embed/DoR08T26IPU?playlist=QyPRTblP2-4,OyiNc7zNN9c

Embeding YouTube player in MediWiki

All the above refer to pure HTML webpages. In MediaWiki we cannot just use iframe code. Instead we can use the Widget:YouTube which does the embeding.

So, to embed an on-the-fly playlist we use the param idlist with a comma separated list of IDs.

{{#widget:YouTube|id=VIDEO_ID_1|additionalids=VIDEO_ID_2,VIDEO_ID_3, ... ,VIDEO_ID_n}}

where id is the video ID of the first video and additionalids is a comma separated list of the additional video IDs, i.e. from the second to the n-th one.

For example:

{{#widget:YouTube|id=ntpt0fq3Jn8|additionalids=iZ9vkd7Rp-g,L4GrDOOIIbk}}