Skip to content

Commit 9567b0a

Browse files
committed
2022.9.13.0
Added video duration to the feed Added skipping of pinned Instagram posts if they are already downloaded
1 parent c28c0e1 commit 9567b0a

File tree

10 files changed

+66
-27
lines changed

10 files changed

+66
-27
lines changed

Changelog.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 2022.9.13.0
2+
3+
*2022-09-13*
4+
5+
- Added
6+
- Video duration to the feed
7+
- Fixed
8+
- (Issue #70) Instagram posts not downloading if there are pinned posts that have already been downloaded
9+
- Minor bugs
10+
111
# 2022.9.10.0
212

313
*2022-09-10*

SCrawler/API/Base/UserDataBase.vb

+5-2
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ BlockNullPicture:
830830
Else
831831
'ReparseMissing(Token)
832832
End If
833-
_TempMediaList.ListAddList(ContentMissing, LNC)
833+
'_TempMediaList.ListAddList(ContentMissing, LNC)
834834

835835
If _TempMediaList.Count > 0 Then
836836
If Not DownloadImages Then _TempMediaList.RemoveAll(Function(m) m.Type = UTypes.GIF Or m.Type = UTypes.Picture)
@@ -845,9 +845,12 @@ BlockNullPicture:
845845
_ContentNew.ListAddList(_TempMediaList, LAP.ClearBeforeAdd)
846846
DownloadContent(Token)
847847
ThrowIfDisposed()
848+
848849
LatestData.ListAddList(_ContentNew.Where(_downContent), LNC)
850+
Dim mcb& = If(ContentMissingExists, _ContentList.LongCount(Function(c) MissingFinder(c)), 0)
849851
_ContentList.ListAddList(_ContentNew.Where(Function(c) _downContent(c) Or MissingFinder(c)), LNC)
850-
If DownloadedTotal(False) > 0 Or EnvirChanged.Invoke Or _ContentList.Exists(MissingFinder) Then
852+
Dim mca& = If(ContentMissingExists, _ContentList.LongCount(Function(c) MissingFinder(c)), 0)
853+
If DownloadedTotal(False) > 0 Or EnvirChanged.Invoke Or Not mcb = mca Then
851854
If __SaveData Then
852855
LastUpdated = Now
853856
RunScript()

SCrawler/API/Instagram/UserData.vb

+5-3
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ Namespace API.Instagram
247247
Try
248248
Dim n As EContainer, nn As EContainer, node As EContainer
249249
Dim HasNextPage As Boolean = False
250+
Dim Pinned As Boolean
250251
Dim EndCursor$ = String.Empty
251252
Dim PostID$ = String.Empty, PostDate$ = String.Empty, SpecFolder$ = String.Empty
252253
Dim TaggedCount%
@@ -296,7 +297,7 @@ Namespace API.Instagram
296297
RequestsCount += 1
297298
ThrowAny(Token)
298299

299-
'Data
300+
'Parsing
300301
If Not r.IsEmptyString Then
301302
Using j As EContainer = JsonDocument.Parse(r).XmlIfNothing
302303
n = j.ItemF(ENode).XmlIfNothing
@@ -321,13 +322,14 @@ Namespace API.Instagram
321322
End If
322323
End If
323324
PostID = node.Value("id")
324-
If Not PostID.IsEmptyString And _TempPostsList.Contains(PostID) Then Throw New ExitException(_DownloadComplete)
325+
Pinned = CBool(If(node("pinned_for_users")?.Count, 0))
326+
If Not PostID.IsEmptyString And _TempPostsList.Contains(PostID) And Not Pinned Then Throw New ExitException(_DownloadComplete)
325327
_TempPostsList.Add(PostID)
326328
PostDate = node.Value("taken_at_timestamp")
327329
If IsSavedPosts Then
328330
_SavedPostsIDs.Add(PostID)
329331
Else
330-
If Not CheckDatesLimit(PostDate, DateProvider) Then Throw New ExitException(_DownloadComplete)
332+
If Not CheckDatesLimit(PostDate, DateProvider) And Not Pinned Then Throw New ExitException(_DownloadComplete)
331333
ObtainMedia(node, PostID, PostDate, SpecFolder)
332334
End If
333335
Next

SCrawler/Download/FeedMedia.vb

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ Namespace DownloadObjects
131131
End With
132132
End If
133133

134+
If Not MyVideo Is Nothing Then info &= $" ({MyVideo.VideoLength})"
134135
LBL_INFO.Text = info
135136
'TT_MAIN.SetToolTip(LBL_INFO, Information)
136137
s = New Size(Width, h + TP_MAIN.RowStyles(0).Height + PaddingE.GetOf({TP_MAIN}).Vertical(2))

SCrawler/Download/FeedVideo.Designer.vb

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SCrawler/Download/FeedVideo.vb

+9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ Namespace DownloadObjects
1818
Dim v# = DivideWithZeroChecking(MediaPlayer.Time, MediaPlayer.Length) * 10
1919
If v > 10 Then TR_POSITION.Value = 10 Else TR_POSITION.Value = v
2020
End Sub
21+
Private ReadOnly TimeChangeLabel As Action = Sub()
22+
If MediaPlayer.Time >= 0 Then
23+
Dim t As TimeSpan = TimeSpan.FromMilliseconds(MediaPlayer.Time)
24+
LBL_TIME.Text = $"{VideoLength}/{t}"
25+
End If
26+
End Sub
2127
Private ReadOnly MyImage As ImageRenderer
28+
Friend ReadOnly VideoLength As TimeSpan
2229
Public Sub New()
2330
InitializeComponent()
2431
End Sub
@@ -31,6 +38,7 @@ Namespace DownloadObjects
3138
MediaPlayer = New [Shared].MediaPlayer(New [Shared].Media(New [Shared].LibVLC(enableDebugLogs:=debugLogs), New Uri(File.ToString)))
3239
MyVideo.MediaPlayer = MediaPlayer
3340
TR_VOLUME.Value = MediaPlayer.Volume / 10
41+
If MediaPlayer.Length >= 0 Then VideoLength = TimeSpan.FromMilliseconds(MediaPlayer.Length)
3442
If Settings.UseM3U8 Then
3543
Dim f As SFile = $"{Settings.CachePath.PathWithSeparator}FeedSnapshots\{File.GetHashCode}.png"
3644
If Not f.Exists Then f = FFMPEG.TakeSnapshot(File, f, Settings.FfmpegFile, TimeSpan.FromSeconds(1))
@@ -58,6 +66,7 @@ Namespace DownloadObjects
5866
End Sub
5967
Private Sub MediaPlayer_TimeChanged(sender As Object, e As [Shared].MediaPlayerTimeChangedEventArgs) Handles MediaPlayer.TimeChanged
6068
If TR_POSITION.InvokeRequired Then TR_POSITION.Invoke(TimeChange) Else TimeChange.Invoke
69+
If LBL_TIME.InvokeRequired Then LBL_TIME.Invoke(TimeChangeLabel) Else TimeChangeLabel.Invoke
6170
End Sub
6271
Private Sub TR_POSITION_MouseUp(sender As Object, e As MouseEventArgs) Handles TR_POSITION.MouseUp
6372
Try : MediaPlayer.Time = (MediaPlayer.Length / 100) * (TR_POSITION.Value * 10) : Catch : End Try

SCrawler/MainFrame.Designer.vb

+13-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SCrawler/MainFrame.vb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1171,10 +1171,10 @@ ResumeDownloadingOperation:
11711171
Dim a As Action = Sub()
11721172
Dim i% = LIST_PROFILES.Items.IndexOfKey(Key)
11731173
If i < 0 Then
1174-
i = Settings.Users.FindIndex(Function(u) u.Key = Key)
1175-
If i >= 0 Then
1176-
UserListUpdate(Settings.Users(i), True)
1177-
i = LIST_PROFILES.Items.IndexOfKey(Key)
1174+
Dim u As IUserData = Settings.GetUser(Key, True)
1175+
If Not u Is Nothing Then
1176+
UserListUpdate(u, True)
1177+
i = LIST_PROFILES.Items.IndexOfKey(u.Key)
11781178
End If
11791179
End If
11801180
If i >= 0 Then

SCrawler/My Project/AssemblyInfo.vb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices
3232
' by using the '*' as shown below:
3333
' <Assembly: AssemblyVersion("1.0.*")>
3434

35-
<Assembly: AssemblyVersion("2022.9.10.0")>
36-
<Assembly: AssemblyFileVersion("2022.9.10.0")>
35+
<Assembly: AssemblyVersion("2022.9.13.0")>
36+
<Assembly: AssemblyFileVersion("2022.9.13.0")>
3737
<Assembly: NeutralResourcesLanguage("en")>

SCrawler/SettingsCLS.vb

+4-4
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ Friend Class SettingsCLS : Implements IDisposable
343343
_UserListUpdateRequired = True
344344
End Try
345345
End Sub
346-
Friend Overloads Function GetUser(ByVal User As IUserData) As IUserData
346+
Friend Overloads Function GetUser(ByVal User As IUserData, Optional ByVal GetCollection As Boolean = False) As IUserData
347347
If Users.Count > 0 Then
348348
Dim uSimple As Predicate(Of IUserData) = Function(u) u.Equals(DirectCast(User, UserDataBase))
349349
Dim uCol As Predicate(Of IUserData) = Function(ByVal u As IUserData) As Boolean
@@ -360,7 +360,7 @@ Friend Class SettingsCLS : Implements IDisposable
360360
If Users(i).IsCollection Then
361361
With DirectCast(Users(i), UserDataBind)
362362
i = .Collections.FindIndex(uSimple)
363-
If i >= 0 Then Return .Collections(i)
363+
If i >= 0 Then Return If(GetCollection, Users(i), .Collections(i))
364364
End With
365365
Else
366366
Return Users(i)
@@ -369,7 +369,7 @@ Friend Class SettingsCLS : Implements IDisposable
369369
End If
370370
Return Nothing
371371
End Function
372-
Friend Overloads Function GetUser(ByVal UserKey As String) As IUserData
372+
Friend Overloads Function GetUser(ByVal UserKey As String, Optional ByVal GetCollection As Boolean = False) As IUserData
373373
If Users.Count > 0 Then
374374
Dim finder As Predicate(Of IUserData) = Function(u) u.Key = UserKey
375375
Dim i%, ii%
@@ -379,7 +379,7 @@ Friend Class SettingsCLS : Implements IDisposable
379379
With DirectCast(.Self, UserDataBind)
380380
If .Count > 0 Then
381381
ii = .Collections.FindIndex(finder)
382-
If ii >= 0 Then Return .Collections(ii)
382+
If ii >= 0 Then Return If(GetCollection, .Self, .Collections(ii))
383383
End If
384384
End With
385385
Else

0 commit comments

Comments
 (0)