Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit ec55668

Browse files
author
totokaka
committed
Implemented the identify command.
All features implemented!
1 parent 52139a5 commit ec55668

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

mcman/servers.py

+26-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Imports from dependencies:
66
import spacegdn
77
# Imports from mcman:
8-
from mcman.utils import list_names, download, ask
8+
from mcman.utils import list_names, download, ask, checksum_file
99

1010

1111
class Servers(object):
@@ -193,5 +193,28 @@ def download(self):
193193

194194
def identify(self):
195195
""" Identify what server a jar is. """
196-
self.prnt('The SpaceGDN API currently have no way to search.',
197-
prefix=False)
196+
self.prnt('Calculating checksum of `{}`'.format(self.args.jar.name))
197+
198+
checksum = checksum_file(self.args.jar)
199+
200+
self.prnt('Finding build on SpaceGDN')
201+
202+
builds = spacegdn.builds(where='build.checksum.eq.{}'.format(checksum))
203+
204+
if len(builds) < 1:
205+
self.prnt('Found no build on SpaceGDN with matching checksum')
206+
return
207+
208+
build = builds[0]
209+
server = spacegdn.jars(build['jar_id'])[0]['name']
210+
channel = spacegdn.channels(build['jar_id'],
211+
build['channel_id'])[0]['name']
212+
version = spacegdn.versions(build['jar_id'], build['channel_id'],
213+
build['version_id'])[0]['version']
214+
build = build['build']
215+
216+
self.prnt('Found build:')
217+
self.prnt('', False, False)
218+
self.prnt('{} {} {} {}'.format(server, channel, version, build),
219+
filled_prefix=False)
220+
self.prnt('', False, False)

0 commit comments

Comments
 (0)