From 09df2285f789f01c110cd33ef2bceb0c2b37758e Mon Sep 17 00:00:00 2001 From: ruidajo Date: Sun, 15 Sep 2024 18:51:49 -0500 Subject: [PATCH] Creating a download profile and load default method, Improving install default. --- Instagram/InstagramDownloader.class.st | 43 ++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/Instagram/InstagramDownloader.class.st b/Instagram/InstagramDownloader.class.st index 1056431..f0fda2c 100644 --- a/Instagram/InstagramDownloader.class.st +++ b/Instagram/InstagramDownloader.class.st @@ -1,9 +1,27 @@ Class { #name : #InstagramDownloader, #superclass : #Object, + #instVars : [ + 'bin', + 'profiles' + ], #category : #Instagram } +{ #category : #'as yet unclassified' } +InstagramDownloader >> downloadProfile: anInstProfileName [ + | profiles | + profiles := (FileLocator documents / 'InstagramDownloader' / 'Profiles') ensureCreateDirectory. + ^ GtSubprocessWithInMemoryOutput new + workingDirectory: profiles; + command: bin fullName; + arguments: {anInstProfileName. + '--no-videos'. + '--no-compress-json'}; + runAndWait; + stdout +] + { #category : #'as yet unclassified' } InstagramDownloader >> initialize [ super initialize. @@ -11,7 +29,28 @@ InstagramDownloader >> initialize [ { #category : #'as yet unclassified' } InstagramDownloader >> installDefault [ - | py | + | py doc location | + doc := FileLocator documents. + location := (doc / 'InstagramDownloader') ensureCreateDirectory. py := PyEnv new. - py createEnv: 'InstagramDownloader' in: FileLocator documents + py createEnv: 'InstagramDownloader' in: doc. + py install: 'instaloader' in: 'InstagramDownloader'. + bin := location / 'bin' / 'instaloader'. +] + +{ #category : #accessing } +InstagramDownloader >> loadDefault [ + | temp | + temp := FileLocator documents / 'InstagramDownloader'. + bin := temp / 'bin' / 'instaloader'. + profiles := temp / 'Profiles' +] + +{ #category : #'as yet unclassified' } +InstagramDownloader >> profiles [ + | location | + profiles + ifNil: [ location := bin parent parent / 'Profiles'. + location exists ifFalse: [ ^ profiles := location ensureCreateDirectory ] ]. + ^ profiles ]