Ссылки на ютуб обрезаются? / FAQ :: dev :: реактор :: вопрос к joyreactor

вопрос к joyreactor dev реактор faq 

Ссылки на ютуб обрезаются?

Есть такой вопрос по функционалу реактора:

Когда создаю пост с видео, то вставляю ссылку сразу с плейлистом для удобства, но реактор режет ссылку вида https:// href="http: // www. youtube.com"> www. youtube.com /watch?v =0 MZ3UcOKdf0&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197

превращается в ссылку просто на видео без плейлиста.

Например, на реддите все нормально.

Это баг или фича?

Саму ссылку разделил пробелами, иначе просто вставляло видео.


Подробнее
вопрос к joyreactor,dev,реактор,FAQ
Еще на тему
Развернуть
Вродебы Это из за сложностей в обработке адресов;
Сейчас у Ютуб ссылок вроде берётся ид видео и опционально время начала воспроизведения и больше нечего,
раньше вроде было только ид видео...


Admin(о) тут для тєбє!
Є для тебе Admin(о)!!!


Примерно для версии что была раньше я написал код
добавлюший атрибуты
['start','end','loop','mute','color','list','index']
^мне иммено эти понравились надеюсь что иммено их(+их) и добавят
для Ютуб ссылок эмбэтов.
Особо не тестил...
Код нужно использовать вместе с жойРеакторским парсером(который для ютуба , версия без атрибутов) ссылок, в соответствии инструкции приведённой в коде.


Ищё что то?
Если всё ok
Можно делайте!!! ~_^


<script>
/*
Version : v1.0 for open Beta test
YTGetAttribute(string1)// string1 == youtube URL/URI

Author : IONE
https://m.joyreactor.cc/user/IONE

License :
Not use for evil,
author this text(code) IONE ,
is accepted 'as is' the author is not a responsibility,
if all true, you can use this text(code) !


Function get some** attributes
in some URL/URI*
and create attribute line for add youtube embed code without attributes.

*for youtube but code not choose special
**some attributes ['start','end','loop','mute','color','list','index'];

Like a:
iframe src= https://youtube.com/embed/SomeID + answerThisFunction

How use it:
1)sort you text with your youtube link parser
2)create raw array with youtube link
3)create array 'attributes' with this function for array with youtube links
4)create youtube iframe(s) without attributes per your your youtube link parser
and add attributes from array 'attributes'

It works?

~_^

*/

function YTGetAttribute(string1,answerAttribute,YTAttributeList,f){

//its will be anwer;
answerAttribute='';

//what attributes we will search ;
YTAttributeList=['start','end','loop','mute','color','list','index'];

//function try get attribute in URL/URI ;
// string1 <=where search, attribut1 <=what to search ;

function YTGetAttrib(string1,attribut1){
//cut start string1 ;
string1.match(attribut1+'=')?
string1=string1.split(attribut1+'=')[1]:
string1='';

//cut end string1 ;
if(string1.match('&'))
string1=string1.split('&')[0];

//for disabled 'bad' code in string1 delete all ['>','<'] ;
string1=string1.split('>').join('');
string1=string1.split('<').join('');

// something found? return this! ;
return string1!=''?attribut1+'='+string1:''
}

//line1)for sort attributes ;
//line2)if sub function return nothing do nothing ;
//line3)make answer;

for(f=0;f<YTAttributeList.length;f++)
if(YTGetAttrib(string1,YTAttributeList[f])!='')
answerAttribute+=(answerAttribute==''?'?':'&')+YTGetAttrib(string1,YTAttributeList[f]);

// return answer!;
return answerAttribute
}

// example from https://m.joyreactor.cc/post/5327885 ;
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4'));
// ?list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4
// use after ^ https://www.youtube.com/embed/bRWA3Hl_-U8
// like a ^ https://www.youtube.com/embed/bRWA3Hl_-U8?list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4

</script>
IONE IONE 14.09.202205:52 ответить ссылка 0.0
Версия v1.1
js Кода YTGetAttribute(string1) для получения некоторых атрибутов Ютуб



Исправлено добавлено v1.0 => v1.1 :
*
*параметр t= конвртируется в start=
*параметры 'list','listType'
*параметр rel=0 в конце всегда
*символы не из латиницы(regex /[^-_.,a-zA-Z0-9]/ ) автоматически удаляются из ответа
(^возможно удаляется лишнее по желанию проверьте regex и ютуб документацию)
*указано что код javascript
(^код спрятан в html тег скрипт)

Примечания:*
*ограничения на максимальную длину не добавлены из за параметра playlist (он это "массив" id видео что уже есть в существующем плейлисте указывает на порядок воспроизведения)
*код может выплюнуть два параметра start= если строка содержит t= и start= первым будет t= превращенная в первый start= которому и будет отдан приоритет(так получалось при тестах)
*для построения нормальной песочницы мне нужен либо ваш парсер либо мне нужно писать новый полностью по этому пока(?) без неё...
*если адрес содержит лист то ид видео не обязателен но вместо него нужно что то написать
* если вам нужно убрать из любого адреса Ютуба параметры вы можете использовать:
(function(YTAddres){return YTAddres.split('?')[0]})('https://youtu.be/mw2kKyJu9gY?t=125')
*некоторые параметры не работают возможно из за изменений политики Ютуба
*Я точно не знаю почему почему у Ютуа по умалчиванию мало параметров читайте документацию Ютуба( (пока(?)) не знаю где) и если это не соответствует их каким то правилам то я не рекомендую использовать код приведённый ниже(в самом "ниже" комментария)


Немного потестил...

Возможно полезные ссылки

|||
проверить регулярное выражение:
https://regex101.com/
|||
Параметры проигрывателя Ютуб(не всё читал...)
https://developers.google.com/youtube/player_parameters#Parameters


Уже хорошо или ещё что то?
Если всё ok
Можно(?) Делайте!!! ~_^


<script>
/*
Version : v1.1 for open Beta test
Source type : javascript
Function name : YTGetAttribute(string1)// string1 == youtube URL/URI
Author : IONE contact(maybe): https://m.joyreactor.cc/user/IONE

License :
Not use for evil,
author this text(code) IONE ,
is accepted 'as is' the author is not a responsibility,
if all true, you can use this text(code) !

How it works:
Function get some** attributes
in some URL/URI*
and create attribute line for add youtube embed code without attributes.

*for youtube but code not choose special
**some attributes **['start','end','loop','mute','color','list','listType','playlist','index']
** and 'rel=0' and 't='(convert to 'start=')

Like a:
iframe src= https://youtube.com/embed/SomeID + answerThisFunction

How use it:
1)sort you text with your youtube link parser
2)create raw array with youtube link
3)create array 'attributes' with this function for array with youtube links
4)create youtube iframe(s) without attributes per your your youtube link parser
and add attributes from array 'attributes'

It works?

~_^

*/

function YTGetAttribute(string1,answerAttribute,YTAttributeList,f){

//its will be anwer;
answerAttribute='';

//v1.1(added listType and playlist ) what attributes we will search ;
YTAttributeList=['start','end','loop','mute','color','list','listType','playlist','index'];

//v1.1 try get attribute time( '?t='* or '&t='* ) and convert to '?start='* ;
if(string1.match(/\?t=|&t=/))answerAttribute+='?start='+string1.split(/\?t=|&t=/)[1].split('&')[0];

//function try get attribute in URL/URI ;
// string1 <=where search, attribut1 <=what to search ;

function YTGetAttrib(string1,attribut1){
//cut start string1 ;
string1.match(attribut1+'=')?
string1=string1.split(attribut1+'=')[1]:
string1='';

//cut end string1 ;
if(string1.match('&'))
string1=string1.split('&')[0];

//for disabled 'bad' code in string1 delete all ['>','<'] ;
//string1=string1.split('>').join('');
//string1=string1.split('<').join('');
// /\/\/\ been /\/\/\ \/\/\/new on bottom\/\/\/ ;
//v1.1 for disabled 'bad' code in string1 delete all symbol what not -_.,a-zA-Z0-9 ;
//v1.1 if something wrong go to old (disabled 'bad' code) version (need do it hands) ;

string1=string1.split(/[^-_.,a-zA-Z0-9]/).join('');

// something found? return this! ;
return string1!=''?attribut1+'='+string1:''
}

//line1)for sort attributes ;
//line2)if sub function return nothing do nothing ;
//line3)make answer;

for(f=0;f<YTAttributeList.length;f++)
if(YTGetAttrib(string1,YTAttributeList[f])!='')
answerAttribute+=(answerAttribute==''?'?':'&')+YTGetAttrib(string1,YTAttributeList[f]);

//v1.1 add rel=0 ;
answerAttribute==''?answerAttribute+='?rel=0':answerAttribute+='&rel=0';

// return answer!;
return answerAttribute
}

// example from https://m.joyreactor.cc/post/5327885 ;
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4'));
// ?list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4
// use after ^ https://www.youtube.com/embed/bRWA3Hl_-U8
// like a ^ https://www.youtube.com/embed/bRWA3Hl_-U8?list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4

</script>
IONE IONE 16.09.202208:46 ответить ссылка 0.0
Версия v1.3 [Total Rebuild] Open Beta test
js Кода YTGetAttribute(string1) для получения некоторых атрибутов Ютуб


Код нужно использовать вместе с жойРеакторским парсером(который для ютуба , версия без атрибутов) ссылок, в соответствии инструкции приведённой в коде.

*Я точно не знаю почему у Ютуа по умалчиванию мало параметров читайте документацию Ютуба( (пока(?)) не знаю где) и если это не соответствует их каким то правилам то я не рекомендую использовать код приведённый ниже(в самом "ниже" комментария)

Исправлено добавлено v1.1 => v1.3 :*
*Иправлен(?) баг в v1.1 добавился 'listType' который конфликтовал с 'list'
*переписан код.
*добавлено много сложно читаемых но рабочих тестов

Примечания:
У Ютуба оказывается вроде специфические "ключи"

С каким нибудь "безЗвука"(да|нет) вроде всё просто, а вот "поКругу" срабатывает только для одной песни и только в списке который можно и в адресной строке создать но только после создания плейлиста на Ютубе а так только для одного видео , старт энд работают но сбрасываются на повторе...
*'playlist' пока не получилось полностью проверить
^*обособленности" Ютуьа к моему коду не относятся то есть: это вроде это на их стороне

Параметры проигрывателя Ютуб(не всё читал... подсказки икалал на стакеоверфлоу и.т.п.)
https://developers.google.com/youtube/player_parameters#Parameters

Та вроде код работает...
Третий раз звучит не круто. Но
Всё?
Если всё ok
Можно делайте!!! ~_^

<script>
/*
Version : v1.3 Open Beta test
Source type : javascript
Function name : YTGetAttribute('string1',argumetsArray(opcional))
Author : IONE contact(maybe) : https://m.joyreactor.cc/user/IONE

License :
Not use for evil,
author this text(code) IONE ,
is accepted 'as is' the author is not a responsibility,
if all true, you can use this text(code) !

How it works:
Function get some** attributes
in some URL/URI*
and create attribute line for add youtube embed code without attributes.

*for youtube but code not choose special
**some attributes **['start','end','loop','mute','color','list','listType','playlist','index']
** ^^ or your array ^^
** and 'rel=0' and 't='(convert to 'start=') on default

Like a:
iframe src= https://youtube.com/embed/SomeID + answerThisFunction

How use it:
1)sort you text with your youtube link parser
2)create raw array with youtube link
3)create array 'attributes' with this function for array with youtube links
4)create youtube iframe(s) without attributes per your your youtube link parser
and add attributes from array 'attributes'

It works?

~_^

*/

function YTGetAttribute(string1,YTAttrib1,answer1,f){
//v1.3 Total Rebuild ;

//its will be anwer ;

answer1=[];

//what attributes we will search ;
if(typeof YTAttrib1=='undefined')
YTAttrib1=['start','end','loop','mute','color','list','listType','playlist','index'];

//try get attribute time( '?t='* or '&t='* or ) and convert to '?start='* ;
if(string1.match(/\?t=|&t=/))
answer1[0]='start='+string1.split(/\?t=|&t=/)[1].split('&')[0];

//line1)for(f) sort attributes ;
//line2)try get attribute(YTAttrib1[f]) in URL/URI(string1) ;
//line3-5) if can add in answer1 YTAttrib1[f] ;
//line4)cut start string1 . cut end string1 ;
for(f=0;f<YTAttrib1.length;f++)
if(string1.match(new RegExp('\\?'+YTAttrib1[f]+'=|&'+YTAttrib1[f]+'=')))
answer1[answer1.length]=YTAttrib1[f]+'='+string1
.split(new RegExp('\\?'+YTAttrib1[f]+'=|&'+YTAttrib1[f]+'='))[1].split('&')[0]
.split(/[^-_.,a-zA-Z0-9]/).join('');
//line5) ^ disabled 'bad' code in string1 delete all not - _ . , a-z A-Z 0-9 ;

//add rel=0 ;
answer1[answer1.length]='rel=0';

// return answer! ;
return '?'+answer1.join('&')
}

// some examples from https://m.joyreactor.cc/post/5327885 ;
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4'));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4',['list']));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4&playlist=bRWA3Hl_-U8&loop=1',['playlist','loop']));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&t=44',[]));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&start=44',[]));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&start=44&end=100'));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&mute=1'));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8'));
// all use after ^ https://www.youtube.com/embed/bRWA3Hl_-U8
// like a ^ https://www.youtube.com/embed/bRWA3Hl_-U8?list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4

</script>
IONE IONE 18.09.202215:39 ответить ссылка 0.0
Версия v1.3.5 [я немного приболел поэтому v1.3.5 а не v1.4] Open Beta test
js Кода YTGetAttribute(string1) для получения некоторых атрибутов Ютуб


Код нужно использовать вместе с жойРеакторским парсером ссылок(который для ютуба , мой код только для парараметров после знака вопросса "?" но заточен под джой), в соответствии инструкции приведённой в коде.

*Я точно не знаю почему у Ютуа по умалчиванию мало параметров читайте документацию Ютуба( (пока(?)) не знаю где) и если это не соответствует их каким то правилам то я не рекомендую использовать код приведённый ниже(в самом "ниже" комментария)

Исправлено добавлено v1.3 => v1.3.5 :*
* в Ютубе нашел ссылку:
https://www.youtube.com/embed/videoseries?si=Pnay9c-SJ6K3Ogac&amp;list=PLeZeafB7m27wCVeIrpYBRUHAdk0cks0sq
которая плохо читалась из за "&amp;" , подозреваю что это баг Ютуба, тем не менее исправил код. Но если "&amp;" в результате для чего то нужен то на данный момент у меня он не поддерживается
^ссылка взята отсюда:
https://www.youtube.com/playlist?list=PLeZeafB7m27wCVeIrpYBRUHAdk0cks0sq
(графическая кнопка "поделится" а далее вкладка "встроить")
* минимально переписан код.
^главное что изменено 2 раза в двух строках
//было
new RegExp('\\?'+YTAttrib1[f]+'=|&'+YTAttrib1[f]+'=')
//стало=>
new RegExp('[\\?|&|;]'+YTAttrib1[f]+'=')

^^я не уверен в этом исправлении поэтому v1.3.5
*к много сложно читаемым но рабочим тестам добавлен один новый

Примечания:
У Ютуба оказывается вроде специфические "ключи"

С каким нибудь "безЗвука"(да|нет) вроде всё просто, а вот "поКругу" срабатывает только для одной песни и только в списке который можно и в адресной строке создать но только после создания плейлиста на Ютубе а так только для одного видео , "start" и "end" работают но сбрасываются на повторе...
*'playlist' пока не получилось полностью проверить
^*обособленности" Ютуба к моему коду не относятся то есть: это вроде это на их стороне

Параметры проигрывателя Ютуб(не всё читал... подсказки искалал на стакеоверфлоу и.т.п.)
https://developers.google.com/youtube/player_parameters#Parameters


Не реклама а отзыв. спасибо вебсервсу:
https://regex101.com/


Та вроде код работает...
Четвёртый раз:( переделавую и мало тестирую
Но если всё ok
Можно делайте!!! ~_^



//<script>
/*
Version : v1.3 Open Beta test
Source type : javascript
Function name : YTGetAttribute('string1',argumetsArray(opcional))
Author : IONE contact(maybe) : https://m.joyreactor.cc/user/IONE

License :
Not use for evil,
author this text(code) IONE ,
is accepted 'as is' the author is not a responsibility,
if all true, you can use this text(code) !

How it works:
Function get some** attributes
in some URL/URI*
and create attribute line for add youtube embed code without attributes.

*for youtube but code not choose special
**some attributes **['start','end','loop','mute','color','list','listType','playlist','index']
** ^^ or your array ^^
** and 'rel=0' and 't='(convert to 'start=') on default

Like a:
iframe src= https://youtube.com/embed/SomeID + answerThisFunction

How use it:
1)sort you text with your youtube link parser
2)create raw array with youtube link
3)create array 'attributes' with this function for array with youtube links
4)create youtube iframe(s) without attributes per your your youtube link parser
and add attributes from array 'attributes'

It works?

~_^

*/

function YTGetAttribute(string1,YTAttrib1,answer1,f){
//v1.3.5 bug fix ";"

//its will be anwer ;

answer1=[];

//what attributes we will search ;
if(typeof YTAttrib1=='undefined')
YTAttrib1=['start','end','loop','mute','color','list','listType','playlist','index'];

//try get attribute time( '?t='* or '&t='* or ) and convert to '?start='* ;
if(string1.match(/\?t=|&t=/))
answer1[0]='start='+string1.split(/\?t=|&t=/)[1].split('&')[0];

//line1)for(f) sort attributes ;
//line2)try get attribute(YTAttrib1[f]) in URL/URI(string1) ;
//line3-5) if can add in answer1 YTAttrib1[f] ;
//line4)cut start string1 . cut end string1 ;
for(f=0;f<YTAttrib1.length;f++)
if(string1.match(new RegExp('[\\?|&|;]'+YTAttrib1[f]+'=')))
answer1[answer1.length]=YTAttrib1[f]+'='+string1
.split(new RegExp('[\\?|&|;]'+YTAttrib1[f]+'='))[1].split('&')[0]
.split(/[^-_.,a-zA-Z0-9]/).join('');
//line5) ^ disabled 'bad' code in string1 delete all not - _ . , a-z A-Z 0-9 ;

//add rel=0 ;
answer1[answer1.length]='rel=0';

// return answer! ;
return '?'+answer1.join('&')
}

// some examples from https://m.joyreactor.cc/post/5327885 ;
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4'));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4',['list']));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4&playlist=bRWA3Hl_-U8&loop=1',['playlist','loop']));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&t=44',[]));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&start=44',[]));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&start=44&end=100'));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&mute=1'));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8'));
// all use after ^ https://www.youtube.com/embed/bRWA3Hl_-U8
// like a ^ https://www.youtube.com/embed/bRWA3Hl_-U8?list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4
//New test here:

console.log(YTGetAttribute('https://www.youtube.com/embed/videoseries?si=Pnay9c-SJ6K3Ogac&amp;list=PLeZeafB7m27wCVeIrpYBRUHAdk0cks0sq'));

//</script>
IONE IONE 29.09.202304:12 ответить ссылка 0.0
Версия v1.4 [но я всё ещё немного болею] Open Beta test
js Кода YTGetAttribute(string1) для получения некоторых атрибутов Ютуб


Код нужно использовать вместе с жойРеакторским парсером ссылок(который для ютуба , мой код только для параметров после знака вопроса "?" но заточен под джой), в соответствии инструкции приведённой в коде.

*Я точно не знаю почему у Ютуба по умалчиванию мало параметров читайте документацию Ютуба( (пока(?)) не знаю где) и если это не соответствует их каким то правилам то я не рекомендую использовать код приведённый ниже(в самом "ниже" комментария)

Исправлено добавлено с v1.3.5 до=> v1.4 :*
* всего одно : раннее вылез баг с кусочком строки "&amp;" мешавший читать параметры из за символа ";", я его вроде исправил но представил ситуацию которая не встречалась на практике, что появится "&amp;t=" и параметр "t" будет пропущен.
В общем параметр "t" короткий атрибут и дублируют параметр "start"(который совместим с "end" в отличие "t" (но это проверять возможно надо)) мой код по идее теперь должен ловить [";t=","&t=","?t="] а раньше обрабатывал только ["&t=","?t="]
//было
if(string1.match(/\?t=|&t=/))
answer1[0]='start='+string1.split(/\?t=|&t=/)[1].split('&')[0];
//стало=>
if(string1.match(/[\?|&|;]t=/))
answer1[0]='start='+string1.split(/[\?|&|;]t=/)[1].split('&')[0];
*ну инсрукцыю переписал как то...

Примечания:
У Ютуба оказывается вроде специфические "ключи"

С каким нибудь "безЗвука"(да|нет) вроде всё просто, а вот "поКругу" срабатывает только для одной песни и только в списке который можно и в адресной строке создать но только после создания плейлиста на Ютубе а так только для одного видео , "start" и "end" работают но сбрасываются на повторе...
*'playlist' пока не проверялось полностью
^*обособленности" Ютуба к моему коду не относятся то есть: это вроде это на их стороне

Параметры проигрывателя Ютуб(не всё читал... подсказки искал на стакеоверфлоу и.т.п.)
https://developers.google.com/youtube/player_parameters#Parameters

Не реклама а отзыв. спасибо вебсервсу:
https://regex101.com/
^ссылка добавлена для собственого удобства...

Код вроде работает... но я сейчас нмного более рассеяный чем обычно
публикацыя номер:5 v.1.4
если всё ok то:
Можно делайте!!! ~_^


//<script>
/*
Version : v1.4 Open Beta test
Source type : javascript
Function name : YTGetAttribute('string1',argumetsArray(opcional))
Author : IONE contact(maybe) : https://m.joyreactor.cc/user/IONE

License :
Not use for evil,
author this text(code) IONE ,
is accepted 'as is' the author is not a responsibility,
if all true, you can use this text(code) !

How it works:
Function get some** attributes in some URL/URI*
and create attribute line for add youtube embed code without attributes.

*for youtube but code not choose special
**some attributes **['start','end','loop','mute','color','list','listType','playlist','index']
** ^^ or your array ^^
** and 'rel=0' and 't='(convert to 'start=') on default

Like a:
iframe src= https://youtube.com/embed/SomeID + answerThisFunction

How use it:
1)sort you text with your youtube link parser
2)create embed link with youtube link without any parameters except ≈"videoID"
3)use function YTGetAttribute("type:string youtube link",["type:array for change defaut parameters list(this not necessary)"]) for get parameters from youtube link
4)create youtube iframe(s) with url from your parser and add too url result function YTGetAttribute

It works? ~_^

*/

function YTGetAttribute(string1,YTAttrib1,answer1,f){
//v1.4 hypotic bug fix ";"

//its will be anwer ;

answer1=[];

//what attributes we will search ;
if(typeof YTAttrib1=='undefined')
YTAttrib1=['start','end','loop','mute','color','list','listType','playlist','index'];

//try get attribute time( '?t='* or '&t='* or ';t='*) and convert to '?start='* ;
if(string1.match(/[\?|&|;]t=/))
answer1[0]='start='+string1.split(/[\?|&|;]t=/)[1].split('&')[0];

//line1)for(f) sort attributes ;
//line2)try get attribute(YTAttrib1[f]) in URL/URI(string1) ;
//line3-5) if can add in answer1 YTAttrib1[f] ;
//line4)cut start string1 . cut end string1 ;
for(f=0;f<YTAttrib1.length;f++)
if(string1.match(new RegExp('[\\?|&|;]'+YTAttrib1[f]+'=')))
answer1[answer1.length]=YTAttrib1[f]+'='+string1
.split(new RegExp('[\\?|&|;]'+YTAttrib1[f]+'='))[1].split('&')[0]
.split(/[^-_.,a-zA-Z0-9]/).join('');
//line5) ^ disabled 'bad' code in string1 delete all not - _ . , a-z A-Z 0-9 ;

//add rel=0 ;
answer1[answer1.length]='rel=0';

// return answer! ;
return '?'+answer1.join('&')
}

// some examples from https://m.joyreactor.cc/post/5327885 ;
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4'));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4',['list']));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4&playlist=bRWA3Hl_-U8&loop=1',['playlist','loop']));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&t=44',[]));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&start=44',[]));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&start=44&end=100'));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8&mute=1'));
console.log(YTGetAttribute('https://www.youtube.com/watch?v=bRWA3Hl_-U8'));
// all use after ^ https://www.youtube.com/embed/bRWA3Hl_-U8
// like a ^ https://www.youtube.com/embed/bRWA3Hl_-U8?list=PLoOG71RkaBSxlUpVudUsv-vWQawgxR197&index=4
//New test here:

console.log(YTGetAttribute('https://www.youtube.com/embed/videoseries?si=Pnay9c-SJ6K3Ogac&amp;list=PLeZeafB7m27wCVeIrpYBRUHAdk0cks0sq'));
//</script>
IONE IONE 29.09.202318:48 ответить ссылка 0.0
Только зарегистрированные и активированные пользователи могут добавлять комментарии.
Похожие темы

Похожие посты