Giml is a small PHP web application that helps generate HTML snippets to embed images from Google Drive or videos from Gan Jing World into posts (for example: Moodle course pages or forum posts). The app can extract the real video URL (including HLS .m3u8) using Puppeteer and produces embed code compatible with browsers.
- Convert Google Drive share links (
/file/d/...) into embeddable<img>tags. - Extract real video URLs from Gan Jing World using Puppeteer (headless Chrome), returning:
- An HLS embed (for
.m3u8) usinghls.js. - A plain
<video>tag when a direct video file is available.
- An HLS embed (for
- Auto-clean temporary files:
- Images removed after 30 minutes if not accessed.
- Videos removed after 1 day if not accessed.
- Activity logging to
giml.logfor troubleshooting.
index.php— main file (UI + PHP logic).fetch_video_url.js— Node.js script using Puppeteer to extract video URLs.package.json/package-lock.json— Node.js dependencies (Puppeteer).images/— storage for downloaded images (auto-created).videos-gjw/— storage for downloaded videos (auto-created).giml.log— runtime log file (auto-created).README_vi.md,README_en.md— project documentation.
- PHP 7.x or later (with
cURLandfileinfoextensions). - Node.js (>= 16) and npm to install Puppeteer.
- Web server (Apache, Nginx) to run
index.php. - VPS/server should have enough RAM/CPU to run headless Chromium (recommend at least 512 MB free RAM for the browser process).
- Put the project into your web root, e.g.
/var/www/html/giml. - Install Node.js and npm if missing.
- In the project folder run:
npm install
# if Puppeteer complains about a missing browser, run:
npx puppeteer browsers install chrome- Ensure write permissions for
images/andvideos-gjw/(or let the app create them):
chown -R www-data:www-data /path/to/giml
chmod -R 755 /path/to/giml/images /path/to/giml/videos-gjw- On some distros (CentOS/AlmaLinux) you may need additional system packages/fonts for Chromium to run.
- Open
index.phpin a browser. - Paste a Google Drive or Gan Jing World video link into the form.
- Click "Create HTML snippet".
- Copy the generated HTML and paste it into Moodle (course page, forum post, or an HTML block).
- For HLS (
.m3u8) results, the snippet includeshls.jsto play streams on modern browsers. Example snippet:
<video id="video" controls style="max-width:100%;"></video>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script>
var video = document.getElementById('video');
var videoSrc = 'URL_MASTER_M3U8';
if (Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(videoSrc);
hls.attachMedia(video);
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = videoSrc; // Safari native support
}
</script>- Puppeteer/Chromium consumes resources: a browser instance can use a few hundred MB of RAM and high CPU while loading pages. On small VPS instances, consider upgrading resources or serializing requests so only one Puppeteer job runs at a time.
- If Puppeteer reports missing Chrome, run
npx puppeteer browsers install chromeor setPUPPETEER_EXECUTABLE_PATHto an installed Chrome/Chromium binary. - If the script returns extra logs merged with stdout (because PHP runs the command with
2>&1), note that the app is configured to only print the actual URL to stdout. - When no video is found, check
giml.logfor navigation/timeouts or missing JS-rendered resources. Adjustfetch_video_url.jstimeouts andwaitUntilvalue as needed.
- The app downloads external media temporarily; avoid storing private/sensitive content in public folders.
- The form does not accept uploads — only remote links.
- Puppeteer options (timeouts, launch args) are in
fetch_video_url.js. - To add new providers, update
index.phpand/orfetch_video_url.jsto extract the desired links.
Developer: Nguyễn Đăng Minh Phúc Profile: https://ganjingworld.com/@ndmphuc/
Updated: 2025-11-12