rpcs3.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env python3
  2. # -*- coding: utf8 -*-
  3. # libray - Libre Blu-Ray PS3 ISO Tool
  4. # Copyright © 2018 - 2021 Nichlas Severinsen
  5. #
  6. # This file is part of libray.
  7. #
  8. # libray is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # libray is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with libray. If not, see <https://www.gnu.org/licenses/>.
  20. # This is a script to find the redump names and game serial id's using rpcs3's compatibility list.
  21. # It puts the name, serial id, and some other info into an sqlite3 database.
  22. # That database can then be used to harcode serial id to keys into keys.db.
  23. # This script is not included in the release of libray.
  24. import bs4
  25. import string
  26. import sqlite3
  27. import pathlib
  28. import requests
  29. if __name__ == '__main__':
  30. db_path = pathlib.Path('games.db')
  31. #if db_path.exists():
  32. # db_path.unlink()
  33. db = sqlite3.connect(db_path)
  34. c = db.cursor()
  35. c.execute('CREATE TABLE IF NOT EXISTS games (serial TEXT PRIMARY KEY, country TEXT, type TEXT, name TEXT, redump_name TEXT)')
  36. db.commit()
  37. # "#" section
  38. for i in range(1, 18):
  39. url = 'https://rpcs3.net/compatibility?r=200&p=' + str(i)
  40. print('Requesting page ' + str(i))
  41. response = requests.get(url)
  42. soup = bs4.BeautifulSoup(response.text, features='html5lib')
  43. for row in soup.find_all('label', attrs={'class': 'compat-table-row'}):
  44. columns = [column for column in row.find_all('div', attrs={'class': 'compat-table-cell'})]
  45. for serial in columns[0].find_all(['img']):
  46. game_id = serial.attrs['title'].strip()
  47. country = serial.attrs['src'].split('/')[-1].split('.')[0]
  48. game_type = columns[1].find('a').attrs['title'].strip()
  49. name = columns[1].text.strip()
  50. redump_name = ''
  51. entry = [
  52. game_id,
  53. country,
  54. game_type,
  55. name,
  56. country,
  57. game_type,
  58. name
  59. ]
  60. c.execute('INSERT INTO games VALUES (?, ?, ?, ?, ?) ON CONFLICT DO UPDATE SET country = ?, type = ?, name = ? ', entry)
  61. db.commit()