Skip to content

Commit

Permalink
Refined YouTube chained requests to use Search API (to allow for chan…
Browse files Browse the repository at this point in the history
…nels that last action wasn't to post a video)

Dealt with possibility of Twitter & YouTube channels disabling comments on their last video
  • Loading branch information
DarraghRogan committed Jul 20, 2020
1 parent 5689e0d commit a756979
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 131 deletions.
10 changes: 7 additions & 3 deletions Per mille.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
02B3528524B59C0B0040A23E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02B3528324B59C0B0040A23E /* Main.storyboard */; };
02B3528724B59C160040A23E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 02B3528624B59C160040A23E /* Assets.xcassets */; };
02B3528A24B59C160040A23E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02B3528824B59C160040A23E /* LaunchScreen.storyboard */; };
02B44A5924C4FDC6001083C9 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02B44A5724C4F6B7001083C9 /* Extensions.swift */; };
02B44A5A24C4FDCD001083C9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02E9E8D4248CE7160086352A /* ViewController.swift */; };
02B7EEF82491899800738B62 /* DataLoaderYouTube.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02B7EEF72491899800738B62 /* DataLoaderYouTube.swift */; };
02B7EEFA2491995400738B62 /* DataLoaderInstagram.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02B7EEF92491995400738B62 /* DataLoaderInstagram.swift */; };
02DDA4A824A7751E00F163A9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02DDA4A724A7751E00F163A9 /* AppDelegate.swift */; };
Expand All @@ -28,7 +30,6 @@
02DDA4BA24A7BD6400F163A9 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02DDA4B924A7BD6400F163A9 /* ServiceManagement.framework */; };
02DDA4BB24A7BD7800F163A9 /* LauncherApplication.app in Resources */ = {isa = PBXBuildFile; fileRef = 02DDA4A524A7751E00F163A9 /* LauncherApplication.app */; };
02E9E8D3248CE7160086352A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02E9E8D2248CE7160086352A /* AppDelegate.swift */; };
02E9E8D5248CE7160086352A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02E9E8D4248CE7160086352A /* ViewController.swift */; };
02E9E8D7248CE71D0086352A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 02E9E8D6248CE71D0086352A /* Assets.xcassets */; };
02E9E8DA248CE71D0086352A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02E9E8D8248CE71D0086352A /* Main.storyboard */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -124,6 +125,7 @@
02B3528924B59C160040A23E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
02B3528B24B59C160040A23E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
02B3528F24B59C910040A23E /* Per mille iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Per mille iOS.entitlements"; sourceTree = "<group>"; };
02B44A5724C4F6B7001083C9 /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
02B7EEF72491899800738B62 /* DataLoaderYouTube.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataLoaderYouTube.swift; sourceTree = "<group>"; };
02B7EEF92491995400738B62 /* DataLoaderInstagram.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataLoaderInstagram.swift; sourceTree = "<group>"; };
02DDA49D24A774E700F163A9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -236,9 +238,10 @@
02E9E8D2248CE7160086352A /* AppDelegate.swift */,
02E9E8D6248CE71D0086352A /* Assets.xcassets */,
02B7EEF92491995400738B62 /* DataLoaderInstagram.swift */,
0224C85824963AD400EEC521 /* DataLoaderTwitter.swift */,
027D73A624AFBF8800031CE0 /* DataLoaderTikTok.swift */,
0224C85824963AD400EEC521 /* DataLoaderTwitter.swift */,
02B7EEF72491899800738B62 /* DataLoaderYouTube.swift */,
02B44A5724C4F6B7001083C9 /* Extensions.swift */,
025B3EB424A8A2DE000D0E2B /* Graphics */,
02E9E8DB248CE71D0086352A /* Info.plist */,
02E9E8D8248CE71D0086352A /* Main.storyboard */,
Expand Down Expand Up @@ -411,11 +414,12 @@
buildActionMask = 2147483647;
files = (
02B7EEF82491899800738B62 /* DataLoaderYouTube.swift in Sources */,
02E9E8D5248CE7160086352A /* ViewController.swift in Sources */,
0288C5A22496544E0074E25F /* APIKeys.swift in Sources */,
02B44A5924C4FDC6001083C9 /* Extensions.swift in Sources */,
02E9E8D3248CE7160086352A /* AppDelegate.swift in Sources */,
027D73A724AFBF8800031CE0 /* DataLoaderTikTok.swift in Sources */,
02B7EEFA2491995400738B62 /* DataLoaderInstagram.swift in Sources */,
02B44A5A24C4FDCD001083C9 /* ViewController.swift in Sources */,
0224C85924963AD400EEC521 /* DataLoaderTwitter.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
filePath = "Per mille/ViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "53"
endingLineNumber = "53"
startingLineNumber = "66"
endingLineNumber = "66"
landmarkName = "viewDidLoad()"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -30,8 +30,8 @@
filePath = "Per mille/ViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "83"
endingLineNumber = "83"
startingLineNumber = "96"
endingLineNumber = "96"
landmarkName = "instagramSlider(_:)"
landmarkType = "7">
</BreakpointContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<key>LauncherApplication.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>1</integer>
</dict>
<key>Per mille Launcher Application.xcscheme_^#shared#^_</key>
<dict>
Expand All @@ -27,7 +27,7 @@
<key>Per mille iOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>2</integer>
</dict>
<key>Per mille.xcscheme_^#shared#^_</key>
<dict>
Expand Down
6 changes: 3 additions & 3 deletions Per mille/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
DataLoaderYouTube().loadYouTubeDataChannel()

DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: {
DataLoaderYouTube().loadYouTubeDataActivities()
DataLoaderYouTube().loadYouTubeDataSearch()
})

DispatchQueue.main.asyncAfter(deadline: .now() + 4.0, execute: {
Expand Down Expand Up @@ -328,7 +328,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

if twitterData.includes?.tweets[0].publicMetrics.likeCount != nil {
self.twitterPinnedTweet.title = "Pinned Tweet: ♺ \(String(format: "%U", locale: Locale.current, (twitterData.includes?.tweets[0].publicMetrics.retweetCount as! Int))), ❝❞ \(String(format: "%U", locale: Locale.current, (twitterData.includes?.tweets[0].publicMetrics.quoteCount as! Int))), ♥ \(String(format: "%U", locale: Locale.current, (twitterData.includes?.tweets[0].publicMetrics.likeCount as! Int))), 🗨 \(String(format: "%U", locale: Locale.current, (twitterData.includes?.tweets[0].publicMetrics.replyCount as! Int)))"
self.twitterPinnedTweet.title = "Pinned Tweet: ♺ \(String(format: "%U", locale: Locale.current, (twitterData.includes?.tweets[0].publicMetrics.retweetCount as! Int))), ❝❞ \(String(format: "%U", locale: Locale.current, (twitterData.includes?.tweets[0].publicMetrics.quoteCount as! Int))), ♥ \(String(format: "%U", locale: Locale.current, (twitterData.includes?.tweets[0].publicMetrics.likeCount as! Int))), 🗨 \(String(format: "%U", locale: Locale.current, (twitterData.includes?.tweets[0].publicMetrics.replyCount as? Int ?? 0)))"
}
else {
self.twitterPinnedTweet.title = "Pinned Tweet: None"
Expand Down Expand Up @@ -366,7 +366,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if youTubeDataVideos.pageInfo?.resultsPerPage == 1 {
let youTubeLastVideoViews = youTubeDataVideos.items?[0].statistics.viewCount as! String
let youTubeLastVideoLikes = youTubeDataVideos.items?[0].statistics.likeCount as! String
let youTubeLastVideoComments = youTubeDataVideos.items?[0].statistics.commentCount as! String
let youTubeLastVideoComments = youTubeDataVideos.items?[0].statistics.commentCount as? String ?? "0"
self.youTubeLastVideo.title = "Last Video: ▶ \(youTubeLastVideoViews), ♥ \(youTubeLastVideoLikes), 🗨 \(youTubeLastVideoComments)"
} else {
self.youTubeLastVideo.title = "Error; if internet connectivity & Channel ID okay, problem is with YouTube API. Try later"
Expand Down
Loading

0 comments on commit a756979

Please sign in to comment.