Creating Instagram local class and improving instagram downloader.
This commit is contained in:
parent
09df2285f7
commit
3315efd807
@ -8,16 +8,25 @@ Class {
|
||||
#category : #Instagram
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
InstagramDownloader >> asInstagramLocal [
|
||||
^ InstagramLocal new profiles: self profiles;
|
||||
rootDir: self profiles values first parent
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
InstagramDownloader >> downloadProfile: anInstProfileName [
|
||||
| profiles |
|
||||
profiles := (FileLocator documents / 'InstagramDownloader' / 'Profiles') ensureCreateDirectory.
|
||||
| tempProfiles |
|
||||
tempProfiles := (FileLocator documents / 'InstagramDownloader' / 'Profiles')
|
||||
ensureCreateDirectory.
|
||||
^ GtSubprocessWithInMemoryOutput new
|
||||
workingDirectory: profiles;
|
||||
workingDirectory: tempProfiles;
|
||||
command: bin fullName;
|
||||
arguments: {anInstProfileName.
|
||||
'--no-videos'.
|
||||
'--no-compress-json'};
|
||||
'--no-compress-json'.
|
||||
'--filename-pattern'.
|
||||
'{profile}-{date_utc}-UTC-code:{shortcode}'};
|
||||
runAndWait;
|
||||
stdout
|
||||
]
|
||||
@ -43,7 +52,8 @@ InstagramDownloader >> loadDefault [
|
||||
| temp |
|
||||
temp := FileLocator documents / 'InstagramDownloader'.
|
||||
bin := temp / 'bin' / 'instaloader'.
|
||||
profiles := temp / 'Profiles'
|
||||
profiles := ((temp / 'Profiles') children
|
||||
collect: [ :dir | dir basename -> dir ]) asDictionary
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
|
63
Instagram/InstagramLocal.class.st
Normal file
63
Instagram/InstagramLocal.class.st
Normal file
@ -0,0 +1,63 @@
|
||||
Class {
|
||||
#name : #InstagramLocal,
|
||||
#superclass : #Object,
|
||||
#instVars : [
|
||||
'profiles',
|
||||
'rootDir',
|
||||
'posts'
|
||||
],
|
||||
#category : #Instagram
|
||||
}
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
InstagramLocal >> postsProcessed [
|
||||
| temp shortcodes |
|
||||
temp := Dictionary new.
|
||||
shortcodes := OrderedCollection new.
|
||||
self profiles
|
||||
keysAndValuesDo: [ :k :v |
|
||||
| sel col |
|
||||
sel := v children
|
||||
select: [ :file | file extension = 'json' and: [ file basename includesSubstring: 'code:' ] ].
|
||||
col := sel
|
||||
collect: [ :file | | tempShortcode |
|
||||
tempShortcode := ('code:' split: file basenameWithoutExtension) second.
|
||||
shortcodes add: tempShortcode.
|
||||
(v / ('Post-' , tempShortcode ))
|
||||
ensureCreateDirectory ].
|
||||
temp at: k put: col. ].
|
||||
^ { temp . shortcodes }
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
InstagramLocal >> postsTiddlers [
|
||||
| temp jsons|
|
||||
temp := OrderedCollection new.
|
||||
self profiles
|
||||
valuesDo: [ :v |
|
||||
temp
|
||||
add: (v children
|
||||
select: [ :file | file extension = 'json' and: [ file basename includesSubstring: 'code:' ] ]) ].
|
||||
jsons := temp flatten collect: [ :post | STONJSON fromString: post contents ].
|
||||
^ jsons collect: [:json | Tiddler nowLocal ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
InstagramLocal >> profiles [
|
||||
^ profiles
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
InstagramLocal >> profiles: aCollectionProfiles [
|
||||
profiles := aCollectionProfiles
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
InstagramLocal >> rootDir [
|
||||
^ rootDir
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
InstagramLocal >> rootDir: anObject [
|
||||
rootDir := anObject
|
||||
]
|
Loading…
Reference in New Issue
Block a user