Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dev-guide
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VeNtura
dev-guide
Commits
2534ce12
Commit
2534ce12
authored
Feb 16, 2016
by
Giang Tran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In progress video
parent
8d8fd6ec
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
12 deletions
+39
-12
ruby/video2html.rb
+39
-12
No files found.
ruby/video2html.rb
View file @
2534ce12
...
...
@@ -9,16 +9,33 @@
#
def
run
## Get all files
#
files
=
get_all_video_files_current_dir
end
puts
"Start to run"
run
def
generate_html
(
file_list
)
end
# Tranverse all directory
def
get_all_video_files
(
current_dir
)
Dir
.
glob
(
"
#{
current_dir
}
/*.mp4"
)
do
|
video_file
|
puts
"working on:
#{
my_text_file
}
..."
def
get_all_video_files_current_dir
puts
"Tranversing folders..."
file_arr
=
Array
.
new
Dir
.
glob
(
"**/*.mp4"
)
do
|
video_path
|
tmp_arr
=
video_path
.
split
(
'/'
)
file_arr
.
push
(
course_name:
tmp_arr
.
first
,
mid_path:
tmp_arr
[
1
..
(
tmp_arr
.
length
-
2
)].
join
(
'/'
),
video_file:
tmp_arr
.
last
)
puts
"working on:
#{
video_file
}
..."
end
file_arr
end
# Get list of video files
...
...
@@ -27,21 +44,28 @@ end
# Generate template
#
def
generate_video_playlist_html
(
path
,
video_list
)
html
=
<<
EOT
def
generate_video_playlist_html
(
video_list
)
puts
"Generate html..."
html
=
%Q{
<html>
<head>
<title>Playlist for
#{
path
}
</title>
</head>
<body>
<ul>
EOT
}
video_list
.
foreach
do
|
item
|
{
li
=
"<li><a href="
item
.
course_name
">
#{
item
.
course_name
}
</a></li>"
}
video_list
.
each
do
|
video_file
|
html
+
"
\n
<li><a href='
#{
video_file
}
'>
#{
video_file
}
</a></li>"
end
<
li
><
/li>
html =
<<EOT
return html +
<<EOT
</u
l
>
<
/body>
</
html
>
...
...
@@ -50,7 +74,8 @@ def generate_video_playlist_html(path, video_list)
end
def
generate_video_player_html
(
video_path
)
html = <<EOT
puts
"Generate video player html..."
html
=
%Q{
<html>
<head>
<title>
#{
video_path
}
</title>
...
...
@@ -64,6 +89,8 @@ def generate_video_player_html(video_path)
</script>
</body>
</html>
EOT
}
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment