|
|
@ -5,6 +5,7 @@ import requests |
|
|
from bs4 import BeautifulSoup |
|
|
from bs4 import BeautifulSoup |
|
|
from subprocess import call |
|
|
from subprocess import call |
|
|
import os, shutil |
|
|
import os, shutil |
|
|
|
|
|
import uuid |
|
|
|
|
|
|
|
|
STEAM_COLLECTION_URL = "https://steamcommunity.com/sharedfiles/filedetails/?id=2620032135" |
|
|
STEAM_COLLECTION_URL = "https://steamcommunity.com/sharedfiles/filedetails/?id=2620032135" |
|
|
MAPS = "../maps" |
|
|
MAPS = "../maps" |
|
|
@ -23,6 +24,7 @@ class Tf2Map: |
|
|
app_id = 440 |
|
|
app_id = 440 |
|
|
map_id = 0 |
|
|
map_id = 0 |
|
|
def __init__(self, url, name) -> None: |
|
|
def __init__(self, url, name) -> None: |
|
|
|
|
|
self.uuid = uuid.uuid4() |
|
|
self.map_id = int(url.split("?id=")[1]) |
|
|
self.map_id = int(url.split("?id=")[1]) |
|
|
self.url = url |
|
|
self.url = url |
|
|
self.name = name.replace("|", " ").replace("\\", " ").replace("/"," ") |
|
|
self.name = name.replace("|", " ").replace("\\", " ").replace("/"," ") |
|
|
@ -60,7 +62,8 @@ class Tf2Map: |
|
|
return self.sourced |
|
|
return self.sourced |
|
|
|
|
|
|
|
|
def readme(self): |
|
|
def readme(self): |
|
|
with open(os.path.dirname(self.downloaded[0]) + "/README", "w", encoding="utf8") as readme: |
|
|
readme_file = os.path.dirname(self.downloaded[0]) + "/README" |
|
|
|
|
|
with open(readme_file, "a" if os.path.exists(readme_file) else "w", encoding="utf8") as readme: |
|
|
readme.write(self.url) |
|
|
readme.write(self.url) |
|
|
|
|
|
|
|
|
class CollectionMap: |
|
|
class CollectionMap: |
|
|
@ -79,6 +82,7 @@ class CollectionParser: |
|
|
for collect in self.soup.findAll('div', class_='collectionItem'): |
|
|
for collect in self.soup.findAll('div', class_='collectionItem'): |
|
|
url = collect.find("div", class_="workshopItem").find("a")['href'] |
|
|
url = collect.find("div", class_="workshopItem").find("a")['href'] |
|
|
name = collect.find("div", class_="collectionItemDetails").find("div", class_="workshopItemTitle").text |
|
|
name = collect.find("div", class_="collectionItemDetails").find("div", class_="workshopItemTitle").text |
|
|
|
|
|
print(name, url) |
|
|
_item = Tf2Map(url, name) |
|
|
_item = Tf2Map(url, name) |
|
|
if _item.downloaded and skip_downloaded: |
|
|
if _item.downloaded and skip_downloaded: |
|
|
print(f"{name} already downloaded") |
|
|
print(f"{name} already downloaded") |
|
|
@ -102,6 +106,7 @@ class MapDownloader: |
|
|
self.call(cmd) |
|
|
self.call(cmd) |
|
|
|
|
|
|
|
|
def move(self, _map): |
|
|
def move(self, _map): |
|
|
|
|
|
print(_map) |
|
|
os.chdir(os.path.dirname(__file__)) |
|
|
os.chdir(os.path.dirname(__file__)) |
|
|
os.chdir("../maps") |
|
|
os.chdir("../maps") |
|
|
os.mkdir(_map.name) if not OSPATH.exists(_map.name) else None |
|
|
os.mkdir(_map.name) if not OSPATH.exists(_map.name) else None |
|
|
|