In [1]:
youtube_edits = """
(
'entire video',
(
'The entire video.',
(
'',
'',
)
),
),
"""
In [2]:
%%HTML
<script>
var appendYouTubeEdits = function (){
var quote = "'",
left = '(',
right = ')',
space = ' ',
append = '+=',
colon = ':',
comma = ',',
dblQuote = '"',
spacer = ' ',
cr = '\\n',
startHours = document.getElementById('startHours').value,
startMinutes = document.getElementById('startMinutes').value,
startSeconds = document.getElementById('startSeconds').value,
stopHours = document.getElementById('stopHours').value,
stopMinutes = document.getElementById('stopMinutes').value,
stopSeconds = document.getElementById('stopSeconds').value,
anchor = document.getElementById('anchor').value,
description = document.getElementById('description').value,
command = [
'youtube_edits',
space,
append,
space,
dblQuote,
left,
cr,
spacer,
quote,
anchor,
quote,
comma,
cr,
spacer,
left,
cr,
spacer,
spacer,
quote,
description,
quote,
comma,
cr,
spacer,
spacer,
left,
cr,
spacer,
spacer,
spacer,
quote,
[
startHours,
startMinutes,
startSeconds,
].join(colon),
quote,
comma,
cr,
spacer,
spacer,
spacer,
quote,
[
stopHours,
stopMinutes,
stopSeconds,
].join(colon),
quote,
comma,
cr,
spacer,
spacer,
right,
comma,
cr,
spacer,
right,
comma,
cr,
right,
comma,
cr,
dblQuote,
].join(''),
kernel = IPython.notebook.kernel;
kernel.execute(command);
}
</script>
<div>
<p>start</p>
<input type="text" id="startHours" size="2" maxlength="2" value="00"></input>:
<input type="text" id="startMinutes" size="2" maxlength="2" value="00"></input>:
<input type="text" id="startSeconds" size="2" maxlength="2" value="00"></input><br/>
<p>stop</p>
<input type="text" id="stopHours" size="2" maxlength="2" value="00"></input>:
<input type="text" id="stopMinutes" size="2" maxlength="2" value="00"></input>:
<input type="text" id="stopSeconds" size="2" maxlength="2" value="00"></input><br/>
<p>anchor</p>
<input type="text" id="anchor" size="20" maxlength="20" value="example anchor"></input><br/>
<p>description</p>
<input type="text" id="description" size="80" maxlength="200" value="example description"></input><br/><br/>
<button onClick="appendYouTubeEdits();">set timestamp</button>
</div>
In [3]:
print(type(youtube_edits))
text = "({})".format(youtube_edits)
with open('youtube_edits.py', 'w') as fh:
fh.write(text)
In [4]:
# %load youtube_edits.py
(
(
'entire video',
(
'The entire video.',
(
'',
'',
)
),
),
(
'example anchor',
(
'example description',
(
'00:00:00',
'00:00:00',
),
),
),
)
Out[4]: