Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DONE] Fix migration script for bbb #1214

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pod/import_video/utils.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cela fonctionne avec cette modification dans tous les cas ?
Typiquement, ce code est prévu pour gérer les anciens enregistrements du type :
https://scalelite.univ.fr/playback/presentation/2.0/playback.html?meetingId=XXXX
et devrait les convertir en :
https://scalelite.univ.fr/playback/presentation/2.3/XXXX

En regardant de plus près, il ne faudrait pas mettre à minima ce code :
source_video_url = source_url.replace(
"presentation/2.0/playback.html?meetingId=", "presentation/2.3/"
)
???
Merci

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alors j'avoue que je n'ai pas compris l'origine de cette réécriture du lien. Quand je veux importer la présentation dans Pod (à partir de notre BBB 2.2), avec la réécriture, bbb-recorder me renvoie l'erreur

Error: Evaluation failed: TypeError: Cannot read properties of null (reading 'duration')
    at __puppeteer_evaluation_script__:2:72
    at ExecutionContext._evaluateInternal (/home/pod/bbb-recorder/node_modules/puppeteer/lib/ExecutionContext.js:122:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/home/pod/bbb-recorder/node_modules/puppeteer/lib/ExecutionContext.js:48:12)
    at async main (/home/pod/bbb-recorder/export.js:142:27)
  -- ASYNC --
    at ExecutionContext.<anonymous> (/home/pod/bbb-recorder/node_modules/puppeteer/lib/helper.js:111:15)
    at DOMWorld.evaluate (/home/pod/bbb-recorder/node_modules/puppeteer/lib/DOMWorld.js:112:20)
  -- ASYNC --
    at Frame.<anonymous> (/home/pod/bbb-recorder/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.evaluate (/home/pod/bbb-recorder/node_modules/puppeteer/lib/Page.js:860:43)
    at Page.<anonymous> (/home/pod/bbb-recorder/node_modules/puppeteer/lib/helper.js:112:23)
    at main (/home/pod/bbb-recorder/export.js:142:38)

Par contre en laissant le lien original, ça marche sans problème.

Donc pour bbb-recorder, le lien à utiliser pour les BBB < 2.3 me semble bien https://scalelite.univ.fr/playback/presentation/2.0/playback.html?meetingId=XXXX

Si besoin je peux te fournir le lien d'une présentation de notre BBB en 2.2 pour tester

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si cela ne dérange pas, oui, je veux bien tester avec ton lien; j'ai aussi un lien d'un vieux test que je peux t'envoyer.
Sinon, cette erreur de duration me parle; cela venait d'une temporisation insuffisante (cf. https://www.esup-portail.org/wiki/pages/viewpage.action?pageId=914423810, premier paragraphe).

Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,7 @@ def check_source_url(source_url: str): # noqa: C901
# https://xxx/playback/presentation/2.0/playback.html?meetingId=ID
# to https://xxx/playback/presentation/2.3/ID?meetingId=ID
media_id = array_url[-1]
source_video_url = source_url.replace(
"/2.0/playback.html", "/2.3/" + media_id
).replace("playback.html?meetingId=", "")
source_video_url = source_url
format = "webm"
platform = "BBB_Presentation"
elif source_url.find("/playback/presentation/2.3/") != -1:
Expand Down
51 changes: 35 additions & 16 deletions pod/video/management/commands/migrate_bbb_recordings.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonjour, merci pour ces modifications. Dans notre université, la base de Moodle est Postgre, je ne peux alors tester, mais cela me semble bon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chez moi c'est l'inverse : ma base est en mysql et je n'ai rien pour tester postgre :)

Original file line number Diff line number Diff line change
Expand Up @@ -769,21 +769,27 @@ def get_created_in_moodle(generic_recording: Generic_recording): # noqa: C901
with cursor as c:
select_query = (
"SELECT b.id, b.intro, b.course, b.participants FROM "
"public.mdl_bigbluebuttonbn_recordings r, public.mdl_bigbluebuttonbn b "
"mdl_bigbluebuttonbn_recordings r, mdl_bigbluebuttonbn b "
"WHERE r.bigbluebuttonbnid = b.id "
"AND r.recordingid = '%s' "
"AND r.status = 2" % (generic_recording.internal_meeting_id)
)
if MOODLE_DB_TYPE == "postgresql":
select_query = sql.SQL(select_query).format(sql.Identifier("type"))
select_query = sql.SQL(
"SELECT b.id, b.intro, b.course, b.participants FROM "
"public.mdl_bigbluebuttonbn_recordings r, public.mdl_bigbluebuttonbn b "
"WHERE r.bigbluebuttonbnid = b.id "
"AND r.recordingid = '%s' "
"AND r.status = 2" % (generic_recording.internal_meeting_id)
).format(sql.Identifier("type"))
c.execute(select_query)
results = c.fetchall()
for res in results:
# course_id = res["course"]
# Format for participants:
# '[{"selectiontype":"all","selectionid":"all","role":"viewer"},
# {"selectiontype":"user","selectionid":"83","role":"moderator"}]'
participants = res["participants"]
participants = res[3]
if participants != "":
# Parse participants as a JSON string
parsed_data = json.loads(participants)
Expand Down Expand Up @@ -827,18 +833,26 @@ def set_information_in_moodle(options, generic_recording):
connection, cursor = connect_moodle_database(generic_recording)
with cursor as c:
# Request for Moodle v4
select_query = sql.SQL(
select_query = (
"SELECT b.id, b.intro, b.course, b.participants FROM "
"public.mdl_bigbluebuttonbn_recordings r, public.mdl_bigbluebuttonbn b "
"mdl_bigbluebuttonbn_recordings r, mdl_bigbluebuttonbn b "
"WHERE r.bigbluebuttonbnid = b.id "
"AND r.recordingid = '%s' "
"AND r.status = 2" % (generic_recording.internal_meeting_id)
).format(sql.Identifier("type"))
)
if MOODLE_DB_TYPE == "postgresql":
select_query = sql.SQL(
"SELECT b.id, b.intro, b.course, b.participants FROM "
"public.mdl_bigbluebuttonbn_recordings r, public.mdl_bigbluebuttonbn b "
"WHERE r.bigbluebuttonbnid = b.id "
"AND r.recordingid = '%s' "
"AND r.status = 2" % (generic_recording.internal_meeting_id)
).format(sql.Identifier("type"))
c.execute(select_query)
results = c.fetchall()
for res in results:
id = res["id"]
intro = res["intro"]
id = res[0]
intro = res[1]
# course_id = res["course"]
print(" - Set information in Moodle.")
# If SCRIPT_INFORM wasn't already added
Expand Down Expand Up @@ -870,18 +884,23 @@ def get_moodle_user(user_id: str, connection, cursor) -> Generic_user:
generic_user = None
with cursor as c:
# Most important field: username
select_query = sql.SQL(
"SELECT id, username, firstname, lastname, email FROM public.mdl_user "
select_query = (
"SELECT id, username, firstname, lastname, email FROM mdl_user "
"WHERE id = '%s' " % (user_id)
).format(sql.Identifier("type"))
)
if MOODLE_DB_TYPE == "postgresql":
select_query = sql.SQL(
"SELECT id, username, firstname, lastname, email FROM public.mdl_user "
"WHERE id = '%s' " % (user_id)
).format(sql.Identifier("type"))
c.execute(select_query)
dict_user = c.fetchone()
generic_user = Generic_user(
dict_user["id"],
dict_user["username"],
dict_user["firstname"],
dict_user["lastname"],
dict_user["email"],
dict_user[0],
dict_user[1],
dict_user[2],
dict_user[3],
dict_user[4],
)

return generic_user
Expand Down
Loading