Update database connection details and add scripts for image URL updates and downloads
43
download-images.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const mysql = require('mysql');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
const downloadDir = path.join(require('os').homedir(), 'Downloads', 'pokemon-images');
|
||||
|
||||
// Create the download directory if it doesn't exist
|
||||
if (!fs.existsSync(downloadDir)) {
|
||||
fs.mkdirSync(downloadDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Database connection
|
||||
const connection = mysql.createConnection({
|
||||
host: 'localhost',
|
||||
user: 'root',
|
||||
password: '',
|
||||
database: 'pokedex',
|
||||
});
|
||||
|
||||
connection.connect();
|
||||
|
||||
// Fetch Pokémon data
|
||||
connection.query('SELECT id, image_url FROM pokemon', (error, results) => {
|
||||
if (error) throw error;
|
||||
|
||||
results.forEach((pokemon) => {
|
||||
const file = fs.createWriteStream(path.join(downloadDir, `${pokemon.id}.png`));
|
||||
https.get(pokemon.image_url, (response) => {
|
||||
response.pipe(file);
|
||||
file.on('finish', () => {
|
||||
file.close();
|
||||
console.log(`Downloaded: ${pokemon.image_url}`);
|
||||
});
|
||||
}).on('error', (err) => {
|
||||
fs.unlink(path.join(downloadDir, `${pokemon.id}.png`));
|
||||
console.error(`Error downloading ${pokemon.image_url}: ${err.message}`);
|
||||
});
|
||||
});
|
||||
|
||||
connection.end();
|
||||
});
|
||||
30
update-image-urls.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const mysql = require('mysql');
|
||||
|
||||
// Database connection
|
||||
const connection = mysql.createConnection({
|
||||
host: 'localhost',
|
||||
user: 'root',
|
||||
password: '',
|
||||
database: 'pokedex',
|
||||
});
|
||||
|
||||
connection.connect();
|
||||
|
||||
// Fetch Pokémon data
|
||||
connection.query('SELECT id FROM pokemon', (error, results) => {
|
||||
if (error) throw error;
|
||||
|
||||
results.forEach((pokemon) => {
|
||||
const newImageUrl = `./images/${pokemon.id}.png`;
|
||||
connection.query(
|
||||
'UPDATE pokemon SET image_url = ? WHERE id = ?',
|
||||
[newImageUrl, pokemon.id],
|
||||
(updateError) => {
|
||||
if (updateError) throw updateError;
|
||||
console.log(`Updated image URL for Pokémon ID: ${pokemon.id}`);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
connection.end();
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
$servername = "localhost:3306";
|
||||
$username = "database1";
|
||||
$password = "181t$1lJg";
|
||||
$dbname = "pokedex1";
|
||||
$servername = "localhost";
|
||||
$username = "root";
|
||||
$password = "";
|
||||
$dbname = "pokedex";
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
|
||||
BIN
v2/images/1.png
Normal file
|
After Width: | Height: | Size: 199 KiB |
BIN
v2/images/10.png
Normal file
|
After Width: | Height: | Size: 170 KiB |
BIN
v2/images/100.png
Normal file
|
After Width: | Height: | Size: 178 KiB |
BIN
v2/images/1000.png
Normal file
|
After Width: | Height: | Size: 97 KiB |
BIN
v2/images/1001.png
Normal file
|
After Width: | Height: | Size: 160 KiB |
BIN
v2/images/1002.png
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
v2/images/1003.png
Normal file
|
After Width: | Height: | Size: 126 KiB |
BIN
v2/images/1004.png
Normal file
|
After Width: | Height: | Size: 100 KiB |
BIN
v2/images/1005.png
Normal file
|
After Width: | Height: | Size: 143 KiB |
BIN
v2/images/1006.png
Normal file
|
After Width: | Height: | Size: 130 KiB |
BIN
v2/images/1007.png
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
v2/images/1008.png
Normal file
|
After Width: | Height: | Size: 111 KiB |
BIN
v2/images/1009.png
Normal file
|
After Width: | Height: | Size: 111 KiB |
BIN
v2/images/101.png
Normal file
|
After Width: | Height: | Size: 186 KiB |
BIN
v2/images/1010.png
Normal file
|
After Width: | Height: | Size: 98 KiB |
BIN
v2/images/102.png
Normal file
|
After Width: | Height: | Size: 152 KiB |
BIN
v2/images/103.png
Normal file
|
After Width: | Height: | Size: 166 KiB |
BIN
v2/images/104.png
Normal file
|
After Width: | Height: | Size: 153 KiB |
BIN
v2/images/105.png
Normal file
|
After Width: | Height: | Size: 131 KiB |
BIN
v2/images/106.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
v2/images/107.png
Normal file
|
After Width: | Height: | Size: 107 KiB |
BIN
v2/images/108.png
Normal file
|
After Width: | Height: | Size: 183 KiB |
BIN
v2/images/109.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
v2/images/11.png
Normal file
|
After Width: | Height: | Size: 116 KiB |
BIN
v2/images/110.png
Normal file
|
After Width: | Height: | Size: 145 KiB |
BIN
v2/images/111.png
Normal file
|
After Width: | Height: | Size: 180 KiB |
BIN
v2/images/112.png
Normal file
|
After Width: | Height: | Size: 134 KiB |
BIN
v2/images/113.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
v2/images/114.png
Normal file
|
After Width: | Height: | Size: 217 KiB |
BIN
v2/images/115.png
Normal file
|
After Width: | Height: | Size: 179 KiB |
BIN
v2/images/116.png
Normal file
|
After Width: | Height: | Size: 138 KiB |
BIN
v2/images/117.png
Normal file
|
After Width: | Height: | Size: 125 KiB |
BIN
v2/images/118.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
v2/images/119.png
Normal file
|
After Width: | Height: | Size: 170 KiB |
BIN
v2/images/12.png
Normal file
|
After Width: | Height: | Size: 179 KiB |
BIN
v2/images/120.png
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
v2/images/121.png
Normal file
|
After Width: | Height: | Size: 194 KiB |
BIN
v2/images/122.png
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
v2/images/123.png
Normal file
|
After Width: | Height: | Size: 128 KiB |
BIN
v2/images/124.png
Normal file
|
After Width: | Height: | Size: 152 KiB |
BIN
v2/images/125.png
Normal file
|
After Width: | Height: | Size: 131 KiB |
BIN
v2/images/126.png
Normal file
|
After Width: | Height: | Size: 155 KiB |
BIN
v2/images/127.png
Normal file
|
After Width: | Height: | Size: 139 KiB |
BIN
v2/images/128.png
Normal file
|
After Width: | Height: | Size: 126 KiB |
BIN
v2/images/129.png
Normal file
|
After Width: | Height: | Size: 134 KiB |
BIN
v2/images/13.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
v2/images/130.png
Normal file
|
After Width: | Height: | Size: 143 KiB |
BIN
v2/images/131.png
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
v2/images/132.png
Normal file
|
After Width: | Height: | Size: 126 KiB |
BIN
v2/images/133.png
Normal file
|
After Width: | Height: | Size: 139 KiB |
BIN
v2/images/134.png
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
v2/images/135.png
Normal file
|
After Width: | Height: | Size: 139 KiB |
BIN
v2/images/136.png
Normal file
|
After Width: | Height: | Size: 146 KiB |
BIN
v2/images/137.png
Normal file
|
After Width: | Height: | Size: 150 KiB |
BIN
v2/images/138.png
Normal file
|
After Width: | Height: | Size: 170 KiB |
BIN
v2/images/139.png
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
v2/images/14.png
Normal file
|
After Width: | Height: | Size: 124 KiB |
BIN
v2/images/140.png
Normal file
|
After Width: | Height: | Size: 152 KiB |
BIN
v2/images/141.png
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
v2/images/142.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
v2/images/143.png
Normal file
|
After Width: | Height: | Size: 136 KiB |
BIN
v2/images/144.png
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
v2/images/145.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
v2/images/146.png
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
v2/images/147.png
Normal file
|
After Width: | Height: | Size: 100 KiB |
BIN
v2/images/148.png
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
v2/images/149.png
Normal file
|
After Width: | Height: | Size: 129 KiB |
BIN
v2/images/15.png
Normal file
|
After Width: | Height: | Size: 143 KiB |
BIN
v2/images/150.png
Normal file
|
After Width: | Height: | Size: 116 KiB |
BIN
v2/images/151.png
Normal file
|
After Width: | Height: | Size: 130 KiB |
BIN
v2/images/152.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
v2/images/153.png
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
v2/images/154.png
Normal file
|
After Width: | Height: | Size: 114 KiB |
BIN
v2/images/155.png
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
v2/images/156.png
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
v2/images/157.png
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
v2/images/158.png
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
v2/images/159.png
Normal file
|
After Width: | Height: | Size: 118 KiB |
BIN
v2/images/16.png
Normal file
|
After Width: | Height: | Size: 142 KiB |
BIN
v2/images/160.png
Normal file
|
After Width: | Height: | Size: 160 KiB |
BIN
v2/images/161.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
v2/images/162.png
Normal file
|
After Width: | Height: | Size: 129 KiB |
BIN
v2/images/163.png
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
v2/images/164.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
v2/images/165.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
v2/images/166.png
Normal file
|
After Width: | Height: | Size: 116 KiB |
BIN
v2/images/167.png
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
v2/images/168.png
Normal file
|
After Width: | Height: | Size: 142 KiB |
BIN
v2/images/169.png
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
v2/images/17.png
Normal file
|
After Width: | Height: | Size: 155 KiB |
BIN
v2/images/170.png
Normal file
|
After Width: | Height: | Size: 98 KiB |
BIN
v2/images/171.png
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
v2/images/172.png
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
v2/images/173.png
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
v2/images/174.png
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
v2/images/175.png
Normal file
|
After Width: | Height: | Size: 182 KiB |
BIN
v2/images/176.png
Normal file
|
After Width: | Height: | Size: 110 KiB |