「モジュール:YouTube channel」の版間の差分
ナビゲーションに移動
検索に移動
(一旦文法表記だけ揃える(実際のsetPropertyはまだ行わない)) |
(YouTube handles:) |
||
62行目: | 62行目: | ||
v_music = '♪'; | v_music = '♪'; | ||
end | end | ||
-- YouTube handles: A new way to identify your YouTube channel | |||
local handle = args.handle or ''; | |||
if handle == '' then | |||
v_handle = ''; | |||
else | |||
v_handle = '(@' ..handle.. ')'; | |||
end | |||
--YouTube channel 表示名デフォルト | --YouTube channel 表示名デフォルト | ||
77行目: | 84行目: | ||
-- end | -- end | ||
return '[' ..url ..' ' ..name ..']' ..v_music ..v_veryfy ..' - [[YouTube]]'; | return '[' ..url ..' ' ..name ..']' ..v_handle ..v_music ..v_veryfy ..' - [[YouTube]]'; | ||
end | end | ||
return p; | return p; |
2023年2月19日 (日) 05:18時点における版
このモジュールについての説明文ページを モジュール:YouTube channel/doc に作成できます
local p = {};
local function setProperty(dataStore)
-- メイン空間のみ
if not mw.title.getCurrentTitle().namespace == 0 then
return true;
end
if not mw.smw then
return true;
end
local result = mw.smw.set( dataStore )
if result == true then
-- everything ok
else
-- error message to be found in result.error
end
end
function p.main( frame )
local args = require( 'Module:Arguments' ).getArgs( frame, { wrappers = 'Template:YouTube_channel', removeBlanks = false, parentFirst = true });
local dataStore = {}
-- YouTube_channel ID
local y_id = args[1] or args.id or '';
local formatterURL = "https://www.youtube.com/channel/$1";
local url = mw.ustring.gsub(formatterURL, "\$1", y_id);
-- YouTube_user ID
if args.user then
local y_user = args.user or '';
formatterURL = "https://www.youtube.com/user/$1";
url = mw.ustring.gsub(formatterURL, "\$1", y_user);
end
-- YouTube channel 表示名
local name = args[2] or args.name or '';
-- YouTube channel verify
local verify = args[3] or args.verify or '';
local v_veryfy = '';
if verify == '' then
verify = 'false';
v_veryfy = '';
else
verify ='true';
v_veryfy = '[[ファイル:認証バッジ.png|15px]]';
end
-- YouTube channel music
local music = args.music or '';
local v_music = '';
if music == '' then
v_music = '';
else
verify ='true';
v_music = '♪';
end
-- YouTube handles: A new way to identify your YouTube channel
local handle = args.handle or '';
if handle == '' then
v_handle = '';
else
v_handle = '(@' ..handle.. ')';
end
--YouTube channel 表示名デフォルト
if name == '' then
name = mw.ustring.gsub(mw.title.getCurrentTitle().text,"%s+%b()$","");
end
-- SemanticMediaWiki
local dataStore = {}
dataStore['YouTubeRecord'] = '' ..y_id .. ';'..name .. ';'..verify
-- if not args.nosmw then
-- setProperty(dataStore);
-- end
return '[' ..url ..' ' ..name ..']' ..v_handle ..v_music ..v_veryfy ..' - [[YouTube]]';
end
return p;