Skip to content

Commit 430a068

Browse files
author
Mijago
committed
Minor improvements, Readme updates
1 parent 3c6012a commit 430a068

4 files changed

Lines changed: 28 additions & 54 deletions

File tree

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@ My Twitter: https://twitter.com/MijagoCoding/
99

1010
# How to Use?
1111
3) Install all required packages
12-
1) `python -m pip install pandas plotly pathos requests pretty_html_table bar-chart-race`
13-
2) If you want to use mp4 instead of gif, also install `python -m pip install python-ffmpeg` and put a [ffmpeg](https://www.ffmpeg.org/download.html) in your PATH variable. Then set the `VIDEO_TYPE` in `main.py` to `mp4`.
12+
1) `python3 -m pip install pandas plotly pathos requests pretty_html_table bar-chart-race tqdm`
13+
2) If you want to use mp4 instead of gif, also install `python3 -m pip install python-ffmpeg` and put a [ffmpeg](https://www.ffmpeg.org/download.html) in your PATH variable. Then set the `VIDEO_TYPE` in `main.py` to `mp4`.
1414

1515
**I highly encourage you to do this, as the gifs tend to be 40mb in size, whereas the mp4 is only around 1.5mb~2mb**.
1616

1717
Download it here: [ffmpeg](https://github.com/BtbN/FFmpeg-Builds/releases) (for Windows, `ffmpeg-n5.0-latest-win64-gpl-5.0.zip`).
18-
4) Add your api key to `main.py`. For this, edit `api = BungieApi("API-KEY")`. Get it [here](https://www.bungie.net/en/Application).
19-
5) Edit your user info in `main.py`.
18+
4) Set your API key as an environemnt variable `BUNGIE_API_KEY`. Get the key [here](https://www.bungie.net/en/Application).
19+
1) Alternatively: Add your api key to `main.py`. For this, edit `# API_KEY = "123456789"`.
20+
5) Edit your user info in `main.py`. Alternatively, you can also use command line parameters to set this later.
2021
```py
2122
MEMBERSHIP_MIJAGO = (3, 4611686018482684809)
2223
MEMBERSHIP_MYCOOLID = (1, 1231231231231233353) # for example, add this
2324
USED_MEMBERSHIP = MEMBERSHIP_MYCOOLID
24-
api = BungieApi("API-KEY")
2525
```
26-
6) Run! `python3 main.py`
27-
1) May take a while. I need 35~45 seconds for 1000 PGCRs with a download speed of 4.5mb/s.
26+
6) Run the script `python3 main.py`.
27+
1) Complete Example: `BUNGIE_API_KEY=123456789012345 python3 main.py -p 3 -id 4611686018482684809`
28+
2) Alternatively you can also specify the platform and user: `python3 main.py -p 3 -id 4611686018482684809`
29+
3) This may take a while. I need 35~45 seconds for 1000 PGCRs with a download speed of 4.5mb/s.
2830

2931
# Where do I get my user ID?
3032
1) Go to https://www.d2checklist.com (or any other similar page)

app/DiscordSender.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/PgcrCollector.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def downloadActivityPage(page):
6666

6767
return self
6868

69-
def getPGCRs(self, pagesize=1000):
69+
def getPGCRs(self):
7070
bungo = self.api
7171

7272
def downloadPGCR(activity):
@@ -81,20 +81,12 @@ def downloadPGCR(activity):
8181
with open("%s/pgcr_%s.json" % (Director.GetPGCRDirectory(self.membershipType, self.membershipId), pgcr["activityDetails"]["instanceId"]), "w", encoding='utf-8') as f:
8282
f.write(json.dumps(pgcr))
8383

84-
stepsize = pagesize
85-
START_PAGE = 0
86-
8784
if len(self.activities) == 0:
8885
print("No activities to grab")
8986
return self
9087

91-
for steps in range(START_PAGE, (len(self.activities) + stepsize - 1) // stepsize):
92-
try:
93-
with Timer("Get PGCRs %d through %d" % (steps * stepsize + 1, min(len(self.activities), (steps + 1) * stepsize))):
94-
# self.processPool.restart(True)
95-
self.processPool.amap(downloadPGCR, self.activities[steps * stepsize:(steps + 1) * stepsize]).get()
96-
except Exception as e:
97-
print(e)
88+
from tqdm.auto import tqdm
89+
list(tqdm(self.processPool.imap(downloadPGCR, self.activities), total=len(self.activities), desc="Downloading PGCRs"))
9890
return self
9991

10092
def combineAllPgcrs(self):

main.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from app.reports.WeaponRaceReport import WeaponRaceReport
2020
from app.reports.WeaponReport import WeaponReport
2121
from app.reports.WeekdayReport import WeekdayReport
22-
# from app.DiscordSender import DiscordSender
2322

2423
###############################################################################
2524
#
@@ -31,49 +30,50 @@
3130

3231
# build argument parsing
3332
descriptionString = """Get and compile stats for a Destiny 2 user.
34-
example: main.py 3 4611686018482684809"""
33+
example: main.py -p 3 -id 4611686018482684809"""
3534
platformString = """ Xbox 1
3635
Psn 2
3736
Steam 3
3837
Blizzard 4
3938
Stadia 5
4039
Egs 6"""
4140
parser = argparse.ArgumentParser(prog='main.py', description=f'{descriptionString}', formatter_class=argparse.RawTextHelpFormatter)
42-
parser.add_argument('-p', type=int, required=False, dest='platform', help=f'{platformString}')
43-
parser.add_argument('-id', type=int, required=False, help='bungie ID')
41+
parser.add_argument('--platform', '-p', type=int, required=False, help=f'{platformString}')
42+
parser.add_argument('--membership_id', '-id', type=int, required=False, help='Bungie ID')
4443
args = vars(parser.parse_args())
4544
platform = args['platform']
46-
id = args['id']
45+
id = args['membership_id']
4746

4847
if platform != None and id != None:
4948
USED_MEMBERSHIP = (platform, id)
5049
else:
5150
MIJAGO = (3, 4611686018482684809)
52-
SUPERQ = (3, 4611686018472661350)
53-
SHTGUNWEDDING = (2, 4611686018428655241)
54-
EURO = (3, 4611686018471254627)
55-
DREDGENQ = (3, 4611686018534347056)
56-
SPRQMAN = (2, 4611686018436271063)
57-
USED_MEMBERSHIP = DREDGENQ
51+
# You can easily set your own ID here:
52+
MYCOOLID = (3, 1234567890123456789)
53+
USED_MEMBERSHIP = MIJAGO
5854

59-
from pathos.multiprocessing import ProcessPool
55+
from pathos.multiprocessing import ProcessPool, ThreadPool, ThreadingPool
6056
pathos.helpers.freeze_support() # required for windows
6157
pool = ProcessPool()
62-
# You could also specify the amount of threads. Not that this DRASTICALLY speeds up the process but takes serious computation power.
63-
# pool = ProcessPool(60)
58+
# You could also specify the amount of threads. Note that this DRASTICALLY speeds up the process but takes serious computation power.
59+
# pool = ProcessPool(40)
6460

6561
# check manifest
6662
manifest = DestinyManifest().update()
6763

68-
api = BungieApi(os.getenv('BUNGIE_API_KEY'))
64+
# You can also set an api key manually, if you do not want to use environment variables.
65+
API_KEY = os.getenv('BUNGIE_API_KEY')
66+
# API_KEY = "123456789"
67+
68+
api = BungieApi(API_KEY)
6969
# "gif by default, "mp4" if you installed ffmpeg which you should; see README.d
7070
VIDEO_TYPE = "mp4"
7171

7272
Director.CreateDirectoriesForUser(*USED_MEMBERSHIP)
7373
Director.ClearResultDirectory(*USED_MEMBERSHIP)
7474
Director.CreateDirectoriesForUser(*USED_MEMBERSHIP)
7575
pc = PGCRCollector(*USED_MEMBERSHIP, api, pool)
76-
pc.getCharacters().getActivities(limit=None).getPGCRs(pagesize=1000) # .combineAllPgcrs()
76+
pc.getCharacters().getActivities(limit=None).getPGCRs() # .combineAllPgcrs()
7777
data = pc.getAllPgcrs()
7878

7979
pool.close()
@@ -101,6 +101,3 @@
101101

102102
Zipper.zip_directory(Director.GetResultDirectory(*USED_MEMBERSHIP), Director.GetZipPath(*USED_MEMBERSHIP))
103103
print("Generated ZIP:", Director.GetZipPath(*USED_MEMBERSHIP))
104-
105-
# DiscordSender.send(Director.GetZipPath(*USED_MEMBERSHIP), *USED_MEMBERSHIP)
106-
# print("Sent ZIP:", Director.GetZipPath(*USED_MEMBERSHIP))

0 commit comments

Comments
 (0)