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 @@
...
@@ -9,16 +9,33 @@
#
#
def
run
def
run
## Get all files
#
files
=
get_all_video_files_current_dir
end
end
puts
"Start to run"
run
def
generate_html
(
file_list
)
def
generate_html
(
file_list
)
end
# Tranverse all directory
# Tranverse all directory
def
get_all_video_files
(
current_dir
)
def
get_all_video_files_current_dir
Dir
.
glob
(
"
#{
current_dir
}
/*.mp4"
)
do
|
video_file
|
puts
"Tranversing folders..."
puts
"working on:
#{
my_text_file
}
..."
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
end
file_arr
end
end
# Get list of video files
# Get list of video files
...
@@ -27,21 +44,28 @@ end
...
@@ -27,21 +44,28 @@ end
# Generate template
# Generate template
def
generate_video_playlist_html
(
video_list
)
puts
"Generate html..."
#
html
=
%Q{
def
generate_video_playlist_html
(
path
,
video_list
)
html
=
<<
EOT
<html>
<html>
<head>
<head>
<title>Playlist for
#{
path
}
</title>
<title>Playlist for
#{
path
}
</title>
</head>
</head>
<body>
<body>
<ul>
<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
>
</u
l
>
<
/body>
<
/body>
</
html
>
</
html
>
...
@@ -50,7 +74,8 @@ def generate_video_playlist_html(path, video_list)
...
@@ -50,7 +74,8 @@ def generate_video_playlist_html(path, video_list)
end
end
def
generate_video_player_html
(
video_path
)
def
generate_video_player_html
(
video_path
)
html = <<EOT
puts
"Generate video player html..."
html
=
%Q{
<html>
<html>
<head>
<head>
<title>
#{
video_path
}
</title>
<title>
#{
video_path
}
</title>
...
@@ -64,6 +89,8 @@ def generate_video_player_html(video_path)
...
@@ -64,6 +89,8 @@ def generate_video_player_html(video_path)
</script>
</script>
</body>
</body>
</html>
</html>
EOT
}
end
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