Skip to content

Commit 8a0b4b3

Browse files
committed
- add completed scripts put together for full jwplayer import
0 parents  commit 8a0b4b3

File tree

3 files changed

+142
-0
lines changed

3 files changed

+142
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Developer Scripts
2+
3+
Scripts thrown together to allow for running certain frequent commands from the host machine terminal.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
3+
# Full import command:
4+
# local - bash bin/jwplayer-full-import.sh local-dev.consumer-cms 200 338 true (doesn't currently work on macOS BigSur)
5+
# dev - bash bin/jwplayer-full-import.sh cms-accuweather.develop 200 338 false
6+
if [ $# -lt 3 ]; then
7+
echo "usage: $0 <env-name> <posts-per-page> <pages>"
8+
exit 1
9+
fi
10+
11+
ENV_NAME=$1
12+
POSTS_PER_PAGE=$2
13+
PAGES=${3}
14+
15+
run_lando_accuweather_jwplayer_video_import() {
16+
17+
if [[ 0 -eq "$POSTS_PER_PAGE" ]]; then
18+
POSTS_PER_PAGE=1;
19+
elif [[ 1000 -lt "$POSTS_PER_PAGE" ]]; then
20+
POSTS_PER_PAGE=1000;
21+
fi
22+
23+
# Create log file name.
24+
# local LOG_FILE_NAME="import_jwplayer_videos_page_${CURRENT_PAGE}_videos_${POSTS_PER_PAGE}_import.log"
25+
local LOG_FILE_NAME="import_jwplayer_videos_page_${PAGES}_videos_${POSTS_PER_PAGE}_import.log"
26+
27+
# Run the single import command.
28+
lando wp accuweather import_jwplayer_videos --per-page="$POSTS_PER_PAGE" --pages=1 --offset="$VIDEO_OFFSET" --update-existing --verbose --format=table | tee -a "$IMPORT_LOG_DIR/$LOG_FILE_NAME"
29+
}
30+
31+
run_lando_full_jwplayer_video_import() {
32+
local VIP_DEV_ENV_DIR=".local/share/vip/dev-environment"
33+
if [[ -z "$ENV_NAME" || ! -d "$HOME/$VIP_DEV_ENV_DIR/$ENV_NAME" ]]; then
34+
return;
35+
else
36+
local CURRENT_DIR=$(pwd)
37+
cd "$HOME/$VIP_DEV_ENV_DIR/$ENV_NAME"
38+
fi
39+
40+
local VIDEO_OFFSET=0
41+
local CURRENT_PAGE=1
42+
local IMPORT_LOG_DIR="$HOME/Desktop/jwplayer-full-import-logs"
43+
44+
if [[ 0 -eq "$PAGE" ]]; then
45+
PAGE=$CURRENT_PAGE
46+
fi
47+
48+
if [ ! -d "$IMPORT_LOG_DIR" ]; then
49+
mkdir -p $IMPORT_LOG_DIR
50+
fi
51+
52+
for (( i=1; i <= PAGES; i++ )); do
53+
CURRENT_PAGE=$i
54+
run_lando_accuweather_jwplayer_video_import
55+
VIDEO_OFFSET=$(( CURRENT_PAGE*POSTS_PER_PAGE ))
56+
done
57+
58+
# Change back to previous working directory.
59+
cd $CURRENT_DIR
60+
}
61+
62+
# nvm use 14
63+
run_lando_full_jwplayer_video_import
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
3+
# Full import commands:
4+
#
5+
# local - `bash ./jwplayer-full-import.sh local-dev.consumer-cms 200 338 true`
6+
# - This doesn't currently work for me on macOS BigSur
7+
# - Error Message:
8+
# - "OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: chdir to cwd ("/app/public_html/wp-content") set in config.json failed: no such file or directory: unknown"
9+
# "Error: OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: chdir to cwd ("/app/public_html/wp-content") set in config.json failed: no such file or directory: unknown"
10+
#
11+
# dev - `bash ./jwplayer-full-import.sh cms-accuweather.develop 200 338 false`
12+
#
13+
if [ $# -lt 3 ]; then
14+
echo "usage: $0 <env-name> <posts-per-page> <pages> [is-local-env]"
15+
exit 1
16+
fi
17+
18+
ENV_NAME=$1
19+
POSTS_PER_PAGE=$2
20+
PAGES=${3}
21+
OFFSET=${4-0}
22+
IS_LOCAL=${5-false}
23+
24+
run_vip_accuweather_jwplayer_video_import() {
25+
26+
if [[ 0 -eq "$POSTS_PER_PAGE" ]]; then
27+
POSTS_PER_PAGE=1;
28+
elif [[ 1000 -lt "$POSTS_PER_PAGE" ]]; then
29+
POSTS_PER_PAGE=1000;
30+
fi
31+
32+
if [[ -z "$IS_LOCAL" || "$IS_LOCAL" = false ]]; then
33+
IS_LOCAL=false
34+
local LOCAL_ENV="@$ENV_NAME"
35+
else
36+
local LOCAL_ENV="--slug=$ENV_NAME dev-env exec"
37+
fi
38+
39+
# Create log file name.
40+
# local LOG_FILE_NAME="import_jwplayer_videos_page_${CURRENT_PAGE}_videos_${POSTS_PER_PAGE}_import.log"
41+
local LOG_FILE_NAME="${ENV_NAME}_import_jwplayer_videos_page_${PAGES}_videos_${POSTS_PER_PAGE}_import.log"
42+
43+
# Run the single import command.
44+
# Removing verbose as it caused issues: --verbose
45+
vip "${LOCAL_ENV}" -- wp accuweather import_jwplayer_videos --per-page="$POSTS_PER_PAGE" --pages=1 --offset="$VIDEO_OFFSET" --update-existing --format=table | tee -a "$IMPORT_LOG_DIR/$LOG_FILE_NAME"
46+
47+
# sleep for 5 seconds
48+
sleep 5
49+
}
50+
51+
run_vip_full_jwplayer_video_import() {
52+
53+
if [ -z "$ENV_NAME" ]; then
54+
return;
55+
fi
56+
57+
local VIDEO_OFFSET=0
58+
local CURRENT_PAGE=1
59+
local IMPORT_LOG_DIR="${HOME}/Desktop/jwplayer-full-import-logs"
60+
61+
if [[ 0 -eq "$PAGE" ]]; then
62+
PAGE=$CURRENT_PAGE
63+
fi
64+
65+
if [ ! -d "$IMPORT_LOG_DIR" ]; then
66+
mkdir -p $IMPORT_LOG_DIR
67+
fi
68+
69+
for (( i=1; i <= PAGES; i++ )); do
70+
CURRENT_PAGE=$i
71+
run_vip_accuweather_jwplayer_video_import
72+
VIDEO_OFFSET=$(( CURRENT_PAGE*POSTS_PER_PAGE ))
73+
done
74+
}
75+
76+
run_vip_full_jwplayer_video_import

0 commit comments

Comments
 (0)