「モジュール:YouTube channel」の版間の差分

Softyu (トーク | 投稿記録)
Softyu がページ「モジュール:YouTube channe」を「モジュール:YouTube channel」に、リダイレクトを残さずに移動しました: 误字
Motodai (トーク | 投稿記録)
編集の要約なし
 
(3人の利用者による、間の12版が非表示)
1行目: 1行目:
local p = {};
local p = {};


local function setProperty(dataStore)
local function setProperty(dataStore)
12行目: 11行目:
         return true;
         return true;
     end
     end
   


 
     local result = mw.smw.set( dataStore )
     local result = mw.smw.set(dataStore)


     if result == true then
     if result == true then
25行目: 22行目:


function p.main( frame )
function p.main( frame )
local args = require( 'Module:Arguments' ).getArgs( frame, { wrappers = 'Template:YouTube_channe', removeBlanks = false, parentFirst = true });
local args = require( 'Module:Arguments' ).getArgs( frame, { wrappers = 'Template:YouTube_channel', removeBlanks = false, parentFirst = true });
local dataStore = {}
local dataStore = {}
 
 
-- YouTube_channe ID
-- YouTube_channel ID
local y_id = args[1] or args.id or '';
local y_id = args[1] or args.id or '';
local formatterURL = "https://www.youtube.com/channel/$1";
local formatterURL = "https://www.youtube.com/channel/$1";
local url = mw.ustring.gsub(formatterURL, "\$1", y_id);
local url = mw.ustring.gsub(formatterURL, "\$1", y_id);
dataStore['YouTubeチャンネル'] = y_id
 
 
-- YouTube_user ID
-- YouTube_user ID
41行目: 37行目:
formatterURL = "https://www.youtube.com/user/$1";
formatterURL = "https://www.youtube.com/user/$1";
url = mw.ustring.gsub(formatterURL, "\$1", y_user);
url = mw.ustring.gsub(formatterURL, "\$1", y_user);
dataStore['YouTubeユーザー'] = y_user
end
end


-- YouTube_channe 表示名
-- YouTube handles: A new way to identify your YouTube channel
local handle = args.handle or '';
if handle == '' then
        v_handle = '';
else
        local y_handle = handle
v_handle = '(@' ..handle.. ')';
formatterURL = "https://www.youtube.com/@$1";
url = mw.ustring.gsub(formatterURL, "\$1", y_handle);
end 
 
-- YouTube channel 表示名
local name = args[2] or args.name or '';
local name = args[2] or args.name or '';
-- SemanticMediaWiki
-- YouTube channel verify
if not args.smw then
local verify = args[3] or args.verify or '';
setProperty(dataStore);
    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
end


 
--YouTube channel 表示名デフォルト
-- YouTube_channe 表示名デフォルト
if name == '' then
if name == '' then
name = "YouTube チャンネル";
name = mw.ustring.gsub(mw.title.getCurrentTitle().text,"%s+%b()$","");
end
end
-- SemanticMediaWiki
    local dataStore = {}
    dataStore['YouTubeRecord'] = '' ..y_id .. ';'..name .. ';'..verify
-- if not args.nosmw then
-- setProperty(dataStore);
-- end


return '[' ..url ..' ' ..name ..'] - [[YouTube]]';
return '[' ..url ..' ' ..name ..']' ..v_handle ..v_music ..v_veryfy ..' - [[YouTube]]';
end
end


return p;
return p;