Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KalturaSync
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
icommonsCRC
KalturaSync
Commits
84a28f84
There was an error fetching the commit references. Please try again later.
Unverified
Commit
84a28f84
authored
2 years ago
by
icommonsCRC
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Create kaltura.py
parent
a50be64f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
kaltura.py
+77
-0
77 additions, 0 deletions
kaltura.py
with
77 additions
and
0 deletions
kaltura.py
0 → 100644
+
77
−
0
View file @
84a28f84
# Created by Kyle Goetke
import
pysftp
import
shutil
import
os
import
sys
import
time
def
files_in_directory
(
PATH
):
onlyfiles
=
[
f
for
f
in
os
.
listdir
(
PATH
)
if
os
.
path
.
isfile
(
os
.
path
.
join
(
PATH
,
f
))]
return
onlyfiles
def
compare_lists
(
original_list
,
new_list
):
list_of_diff
=
[
x
for
x
in
new_list
if
x
not
in
original_list
]
# Only detects created/moved files, not deleted files
return
list_of_diff
def
main
():
# define constant variables
HOST
=
""
# sftp host
USERNAME
=
""
# sftp username
PASSWORD
=
""
# sftp password
PATH
=
""
# path to OBS save location for recordings
CNOPTS
=
pysftp
.
CnOpts
()
CNOPTS
.
hostkeys
=
None
USER_ID
=
""
# add your abc123
while
True
:
prev_file_list
=
files_in_directory
(
PATH
)
print
(
"
> CURRENT FILES:
"
,
prev_file_list
,
end
=
"
\r
"
)
time
.
sleep
(
10
)
# 10 seconds
# time.sleep(86400) # 24 hours
new_file_list
=
files_in_directory
(
PATH
)
files_diff
=
compare_lists
(
prev_file_list
,
new_file_list
)
prev_file_list
=
new_file_list
if
len
(
files_diff
)
==
0
:
# if no new files are detected
continue
print
(
"
> CURRENT FILES:
"
,
new_file_list
)
for
filename
in
files_diff
:
print
(
f
"
\n
> NEW FILE -
{
filename
}
"
)
name
=
filename
description
=
filename
[:
-
4
]
# full filename, minus the file extension
new_xml_file
=
"
XML/
"
+
description
+
"
.xml
"
shutil
.
copyfile
(
"
XML/template.xml
"
,
new_xml_file
)
print
(
"
> XML TEMPLATE COPIED
"
)
with
open
(
new_xml_file
,
"
r
"
)
as
file
:
data
=
file
.
readlines
()
data
[
6
]
=
f
"
<userId>
{
USER_ID
}
</userId>
\n
"
data
[
7
]
=
f
"
<name>
{
name
}
</name>
\n
"
data
[
8
]
=
f
"
<description>
{
description
}
</description>
\n
"
data
[
19
]
=
f
'
<dropFolderFileContentResource filePath=
"
{
filename
}
"
>
\n
'
with
open
(
new_xml_file
,
"
w
"
)
as
file
:
file
.
writelines
(
data
)
print
(
"
> XML UPDATED
"
)
with
pysftp
.
Connection
(
HOST
,
username
=
USERNAME
,
password
=
PASSWORD
,
cnopts
=
CNOPTS
)
as
SFTP
:
print
(
"
SFTP:
"
,
SFTP
.
listdir
())
SFTP
.
put
(
f
"
{
PATH
}{
filename
}
"
)
SFTP
.
put
(
new_xml_file
)
print
(
"
SFTP:
"
,
SFTP
.
listdir
())
print
(
"
> FILES PUSHED
"
)
print
(
"
ALL FILES PROCESSED
"
)
if
__name__
==
'
__main__
'
:
try
:
main
()
except
KeyboardInterrupt
:
try
:
sys
.
exit
(
0
)
except
SystemExit
:
os
.
_exit
(
0
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment