InstagramPharo/Instagram/InstagramDownloader.class.st

67 lines
1.7 KiB
Smalltalk

Class {
#name : #InstagramDownloader,
#superclass : #Object,
#instVars : [
'bin',
'profiles'
],
#category : #Instagram
}
{ #category : #accessing }
InstagramDownloader >> asInstagramLocal [
^ InstagramLocal new profiles: self profiles;
rootDir: self profiles values first parent
]
{ #category : #'as yet unclassified' }
InstagramDownloader >> downloadProfile: anInstProfileName [
| tempProfiles |
tempProfiles := (FileLocator documents / 'InstagramDownloader' / 'Profiles')
ensureCreateDirectory.
^ GtSubprocessWithInMemoryOutput new
workingDirectory: tempProfiles;
command: bin fullName;
arguments: {anInstProfileName.
'--no-videos'.
'--no-compress-json'.
'--filename-pattern'.
'{profile}-{date_utc}-UTC-code:{shortcode}'};
runAndWait;
stdout
]
{ #category : #'as yet unclassified' }
InstagramDownloader >> initialize [
super initialize.
]
{ #category : #'as yet unclassified' }
InstagramDownloader >> installDefault [
| py doc location |
doc := FileLocator documents.
location := (doc / 'InstagramDownloader') ensureCreateDirectory.
py := PyEnv new.
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') children
collect: [ :dir | dir basename -> dir ]) asDictionary
]
{ #category : #'as yet unclassified' }
InstagramDownloader >> profiles [
| location |
profiles
ifNil: [ location := bin parent parent / 'Profiles'.
location exists ifFalse: [ ^ profiles := location ensureCreateDirectory ] ].
^ profiles
]