Skip to content

Commit

Permalink
3.0.0.8
Browse files Browse the repository at this point in the history
Script mode command
Disabled Instagram error 403
Fixed script does not run
  • Loading branch information
AAndyProgram committed Apr 19, 2022
1 parent a5fa935 commit 0594e77
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 73 deletions.
10 changes: 9 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# 3.0.0.8

- Added
- Script mode ```command```
- Disabled Instagram error 403 (Forbidden) logging for downloading tagged data
- Fixed
- The script does not run after the user download is complete

# 3.0.0.7

- Added
- Ability to run a script after the user download if complete
- Ability to run a script after the user download is complete
- Hotkey ```F2``` for additional options in the user creation form
- Fixed
- (Issue #32) In some cases, Date and Time are still not added for Stories and Tagged Photos
Expand Down
Binary file modified ProgramScreenshots/SettingsBasis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Social networks crawler

[![GitHub release (latest by date)](https://img.shields.io/github/v/release/AAndyProgram/SCrawler)](https://github.com/AAndyProgram/SCrawler/releases/latest)
[![GitHub](https://img.shields.io/github/license/AAndyProgram/SCrawler)](https://github.com/AAndyProgram/SCrawler/)
[![GitHub license](https://img.shields.io/github/license/AAndyProgram/SCrawler)](https://github.com/AAndyProgram/SCrawler/blob/main/LICENSE)
[![FAQ](https://img.shields.io/badge/FAQ-green)](FAQ.md)
[![GUIDE](https://img.shields.io/badge/GUIDE-green)](https://github.com/AAndyProgram/SCrawler/wiki)
[![How to support](https://img.shields.io/badge/HowToSupport-green)](HowToSupport.md)
Expand Down
52 changes: 15 additions & 37 deletions SCrawler/API/Base/UserDataBase.vb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Namespace API.Base
Private Const Name_LastUpdated As String = "LastUpdated"

Private Const Name_ScriptUse As String = "ScriptUse"
Private Const Name_ScriptFile As String = "ScriptFile"
Private Const Name_ScriptData As String = "ScriptData"

Private Const Name_DataMerging As String = "DataMerging"
#Region "Downloaded data"
Expand Down Expand Up @@ -411,7 +411,7 @@ BlockNullPicture:
#End Region
#Region "Script"
Friend Overridable Property ScriptUse As Boolean = False Implements IUserData.ScriptUse
Friend Overridable Property ScriptFile As SFile Implements IUserData.ScriptFile
Friend Overridable Property ScriptData As String Implements IUserData.ScriptData
#End Region
#End Region
#Region "Plugins Support"
Expand Down Expand Up @@ -585,16 +585,7 @@ BlockNullPicture:
DownloadedPictures(True) = x.Value(Name_PicturesCount).FromXML(Of Integer)(0)
LastUpdated = AConvert(Of Date)(x.Value(Name_LastUpdated), ADateTime.Formats.BaseDateTime, Nothing)
ScriptUse = x.Value(Name_ScriptUse).FromXML(Of Boolean)(False)
Dim s$ = x.Value(Name_ScriptFile)
If Not s.IsEmptyString Then
If SFile.IsDirectory(s) Then
ScriptFile = s
Else
ScriptFile = New SFile(s) With {.Path = MyFile.Path}
End If
Else
ScriptFile = Nothing
End If
ScriptData = x.Value(Name_ScriptData)
DataMerging = x.Value(Name_DataMerging).FromXML(Of Boolean)(False)
ChangeCollectionName(x.Value(Name_CollectionName), False)
Labels.ListAddList(x.Value(Name_LabelsName).StringToList(Of String, List(Of String))("|", EDP.ReturnValue), LAP.NotContainsOnly, LAP.ClearBeforeAdd)
Expand Down Expand Up @@ -635,15 +626,7 @@ BlockNullPicture:
x.Add(Name_PicturesCount, DownloadedPictures(True))
x.Add(Name_LastUpdated, AConvert(Of String)(LastUpdated, ADateTime.Formats.BaseDateTime, String.Empty))
x.Add(Name_ScriptUse, ScriptUse.BoolToInteger)
If Not ScriptFile.IsEmptyString Then
If ScriptFile.Path = MyFile.Path Then
x.Add(Name_ScriptFile, ScriptFile.File)
Else
x.Add(Name_ScriptFile, ScriptFile)
End If
Else
x.Add(Name_ScriptFile, String.Empty)
End If
x.Add(Name_ScriptData, ScriptData)
x.Add(Name_CollectionName, CollectionName)
x.Add(Name_LabelsName, Labels.ListToString(, "|", EDP.ReturnValue))
x.Add(Name_DataMerging, DataMerging.BoolToInteger)
Expand Down Expand Up @@ -964,17 +947,18 @@ BlockNullPicture:
End Function
Private Sub RunScript()
Try
Const spa$ = "{0}"
If ScriptUse Then
Dim ScriptPattern$
If Not ScriptFile.IsEmptyString Then
ScriptPattern = ScriptFile
If Not ScriptData.IsEmptyString Then
ScriptPattern = ScriptData
Else
ScriptPattern = Settings.ScriptFile.Value
ScriptPattern = Settings.ScriptData.Value
End If
If Not ScriptPattern.IsEmptyString Then
ScriptPattern &= " {0}"
If Not ScriptPattern.Contains(spa) Then ScriptPattern &= $" ""{spa}"""
Using b As New BatchExecutor With {.RedirectStandardError = True}
b.Execute({String.Format(ScriptPattern, MyFile.CutPath(1).ToString)}, EDP.SendInLog + EDP.ThrowException)
b.Execute({String.Format(ScriptPattern, MyFile.CutPath(1).PathNoSeparator)}, EDP.SendInLog + EDP.ThrowException)
If b.HasError Or Not b.ErrorOutput.IsEmptyString Then Throw New Exception(b.ErrorOutput, b.ErrorException)
End Using
End If
Expand Down Expand Up @@ -1035,11 +1019,8 @@ BlockNullPicture:
End If
f.CutPath.Exists(SFO.Path)
Directory.Move(UserBefore.File.CutPath(, EDP.ThrowException).Path, f.Path)
If Not ScriptFile.IsEmptyString AndAlso ScriptFile.Path = UserBefore.File.Path Then
Dim ff As SFile = ScriptFile
f.Path = MyFile.Path
ScriptFile = ff
End If
If Not ScriptData.IsEmptyString AndAlso ScriptData.Contains(UserBefore.File.PathNoSeparator) Then _
ScriptData = ScriptData.Replace(UserBefore.File.PathNoSeparator, MyFile.PathNoSeparator)
Settings.UsersList.Remove(UserBefore)
Settings.UpdateUsersList(User)
UpdateUserInformation()
Expand Down Expand Up @@ -1093,11 +1074,8 @@ BlockNullPicture:
New ErrorsDescriber(False, False, False, New List(Of SFile))).Count = 0 Then
UserBefore.File.CutPath.Delete(SFO.Path, Settings.DeleteMode, EDP.SendInLog)
End If
If Not ScriptFile.IsEmptyString AndAlso ScriptFile.Path = UserBefore.File.Path Then
Dim f As SFile = ScriptFile
f.Path = MyFile.Path
ScriptFile = f
End If
If Not ScriptData.IsEmptyString AndAlso ScriptData.Contains(UserBefore.File.PathNoSeparator) Then _
ScriptData = ScriptData.Replace(UserBefore.File.PathNoSeparator, MyFile.PathNoSeparator)
UpdateUserInformation()
End If
Catch ioex As InvalidOperationException When ioex.HelpLink = 1
Expand Down Expand Up @@ -1263,7 +1241,7 @@ BlockNullPicture:
Property DownloadImages As Boolean
Property DownloadVideos As Boolean
Property ScriptUse As Boolean
Property ScriptFile As SFile
Property ScriptData As String
Function GetLVI(ByVal Destination As ListView) As ListViewItem
Function GetLVIGroup(ByVal Destination As ListView) As ListViewGroup
Sub LoadUserInformation()
Expand Down
11 changes: 8 additions & 3 deletions SCrawler/API/Instagram/UserData.vb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ Namespace API.Instagram
Catch dex As ObjectDisposedException When Disposed
Exit Do
Catch ex As Exception
If DownloadingException(ex, $"data downloading error [{URL}]") = 1 Then Continue Do Else Exit Do
If DownloadingException(ex, $"data downloading error [{URL}]", Section, False) = 1 Then Continue Do Else Exit Do
End Try
Loop
Catch eex2 As ExitException
Expand Down Expand Up @@ -538,7 +538,7 @@ Namespace API.Instagram
End If
Return Nothing
Catch ex As Exception
DownloadingException(ex, "API.Instagram.GetStoriesList")
DownloadingException(ex, "API.Instagram.GetStoriesList", Sections.Stories, False)
Return Nothing
End Try
End Function
Expand All @@ -552,13 +552,18 @@ Namespace API.Instagram
''' <inheritdoc cref="UserDataBase.DownloadingException(Exception, String)"/><br/>
''' 1 - continue
''' </summary>
Protected Overrides Function DownloadingException(ByVal ex As Exception, ByVal Message As String, Optional ByVal FromPE As Boolean = False) As Integer
Protected Overloads Overrides Function DownloadingException(ByVal ex As Exception, ByVal Message As String, Optional ByVal FromPE As Boolean = False) As Integer
Return DownloadingException(ex, Message, Sections.Timeline, FromPE)
End Function
Private Overloads Function DownloadingException(ByVal ex As Exception, ByVal Message As String, ByVal s As Sections, ByVal FromPE As Boolean) As Integer
If Responser.StatusCode = HttpStatusCode.NotFound Then
UserExists = False
ElseIf Responser.StatusCode = HttpStatusCode.BadRequest Then
HasError = True
MyMainLOG = "Instagram credentials have expired"
MySiteSettings.HashUpdateRequired.Value = True
ElseIf Responser.StatusCode = HttpStatusCode.Forbidden And s = Sections.Tagged Then
Return 3
ElseIf Responser.StatusCode = 429 Then
With MySiteSettings
Dim WaiterExists As Boolean = .LastApplyingValue.HasValue
Expand Down
8 changes: 4 additions & 4 deletions SCrawler/Editors/GlobalSettingsForm.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions SCrawler/Editors/GlobalSettingsForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Namespace Editors
TXT_FOLDER_CMD.Text = .OpenFolderInOtherProgram
TXT_FOLDER_CMD.Checked = .OpenFolderInOtherProgram.Attribute
CH_RECYCLE_DEL.Checked = .DeleteToRecycleBin
TXT_SCRIPT.Checked = .ScriptFile.Attribute
TXT_SCRIPT.Text = .ScriptFile.Value
TXT_SCRIPT.Checked = .ScriptData.Attribute
TXT_SCRIPT.Text = .ScriptData.Value
'Defaults
CH_SEPARATE_VIDEO_FOLDER.Checked = .SeparateVideoFolder.Value
CH_DEF_TEMP.Checked = .DefaultTemporary
Expand Down Expand Up @@ -125,8 +125,8 @@ Namespace Editors
.OpenFolderInOtherProgram.Value = TXT_FOLDER_CMD.Text
.OpenFolderInOtherProgram.Attribute.Value = TXT_FOLDER_CMD.Checked
.DeleteToRecycleBin.Value = CH_RECYCLE_DEL.Checked
.ScriptFile.Value = TXT_SCRIPT.Text
.ScriptFile.Attribute.Value = TXT_SCRIPT.Checked
.ScriptData.Value = TXT_SCRIPT.Text
.ScriptData.Attribute.Value = TXT_SCRIPT.Checked
'Defaults
.SeparateVideoFolder.Value = CH_SEPARATE_VIDEO_FOLDER.Checked
.DefaultTemporary.Value = CH_DEF_TEMP.Checked
Expand Down Expand Up @@ -200,10 +200,7 @@ Namespace Editors
ChangePositionControlsEnabling()
End Sub
Private Sub TXT_SCRIPT_ActionOnButtonClick(ByVal Sender As ActionButton) Handles TXT_SCRIPT.ActionOnButtonClick
If Sender.DefaultButton = ActionButton.DefaultButtons.Open Then
Dim f As SFile = SFile.SelectFiles(TXT_SCRIPT.Text, False, "Select script file",, EDP.None).FirstOrDefault
If Not f.IsEmptyString Then TXT_SCRIPT.Text = f
End If
SettingsCLS.ScriptTextBoxButtonClick(TXT_SCRIPT, Sender)
End Sub
Private Sub CH_COPY_CHANNEL_USER_IMAGE_CheckedChanged(sender As Object, e As EventArgs) Handles CH_COPY_CHANNEL_USER_IMAGE.CheckedChanged
CH_COPY_CHANNEL_USER_IMAGE_ALL.Enabled = CH_COPY_CHANNEL_USER_IMAGE.Checked
Expand Down
8 changes: 4 additions & 4 deletions SCrawler/Editors/UserCreatorForm.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions SCrawler/Editors/UserCreatorForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Imports SCrawler.Plugin.Hosts
Imports ADB = PersonalUtilities.Forms.Controls.Base.ActionButton.DefaultButtons
Namespace Editors
Friend Class UserCreatorForm : Implements IOkCancelToolbar

Private ReadOnly MyDef As DefaultFormProps(Of FieldsChecker)
Friend Property User As UserInfo
Friend Property UserInstance As IUserData
Expand Down Expand Up @@ -71,7 +72,7 @@ Namespace Editors
Return TXT_SCRIPT.Checked
End Get
End Property
Friend ReadOnly Property ScriptFile As SFile
Friend ReadOnly Property ScriptData As String
Get
Return TXT_SCRIPT.Text
End Get
Expand Down Expand Up @@ -122,7 +123,7 @@ Namespace Editors
CH_TEMP.Checked = Settings.DefaultTemporary
CH_DOWN_IMAGES.Checked = Settings.DefaultDownloadImages
CH_DOWN_VIDEOS.Checked = Settings.DefaultDownloadVideos
TXT_SCRIPT.Checked = Settings.ScriptFile.Attribute
TXT_SCRIPT.Checked = Settings.ScriptData.Attribute
SetParamsBySite()
Else
TP_ADD_BY_LIST.Enabled = False
Expand All @@ -148,7 +149,7 @@ Namespace Editors
CH_DOWN_IMAGES.Checked = .DownloadImages
CH_DOWN_VIDEOS.Checked = .DownloadVideos
TXT_SCRIPT.Checked = .ScriptUse
TXT_SCRIPT.Text = .ScriptFile
TXT_SCRIPT.Text = .ScriptData
TXT_DESCR.Text = .Description
UserLabels.ListAddList(.Labels)
If UserLabels.ListExists Then TXT_LABELS.Text = UserLabels.ListToString
Expand Down Expand Up @@ -237,7 +238,7 @@ Namespace Editors
End If
.ParseUserMediaOnly = CH_PARSE_USER_MEDIA.Checked
.ScriptUse = TXT_SCRIPT.Checked
.ScriptFile = TXT_SCRIPT.Text
.ScriptData = TXT_SCRIPT.Text
.UpdateUserInformation()
End With
End If
Expand Down Expand Up @@ -488,10 +489,7 @@ CloseForm:
End Using
End Sub
Private Sub TXT_SCRIPT_ActionOnButtonClick(ByVal Sender As ActionButton) Handles TXT_SCRIPT.ActionOnButtonClick
If Sender.DefaultButton = ADB.Open Then
Dim f As SFile = SFile.SelectFiles(TXT_SCRIPT.Text, False, "Select script file").FirstOrDefault
If Not f.IsEmptyString Then TXT_SCRIPT.Text = f
End If
SettingsCLS.ScriptTextBoxButtonClick(TXT_SCRIPT, Sender)
End Sub
End Class
End Namespace
Loading

0 comments on commit 0594e77

Please sign in to comment.