Swift API for downloading Billboard charts
Switch branches/tags
Nothing to show
Clone or download
Latest commit 56797c8 Nov 22, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example Support for Swift Package Manager Nov 19, 2018
Sources Support for Swift Package Manager Nov 19, 2018
.gitignore Deletion of Build Files Nov 22, 2018
.travis.yml Initial commit Nov 15, 2018
BillboardSwiftLibrary.podspec Code Cleanup Nov 20, 2018
LICENSE Initial commit Nov 15, 2018
Package.resolved Code Cleanup Nov 20, 2018
Package.swift SPM Builds for BillboardBot Nov 21, 2018
README.md Support for Swift Package Manager Nov 19, 2018
_Pods.xcodeproj Initial commit Nov 15, 2018

README.md

BillboardSwiftLibrary

CI Status Version License Platform

Basic Usage

To download a Billboard chart, we use the BillboardManager constructor.

Let's fetch the current Hot 100 chart and for a particular date.

Dont forget to set Allow Arbitrary Loads under App Transport Security Settings in your info.plist to YES

import BillboardSwiftLibrary

let manager = BillboardManager()
manager.getChart(chartType: ChartType.hot100) { (entries, error) in
	if error != nil{
		print(error!.localizedDescription)
		return
	}

	print(entries!) //Array of ChartEntry
}



//FOR A PARTICULAR DATE (always remember date is in the form YYYY-MM-DD)
manager.getChart(chartType: ChartType.hot100, date: "2018-11-18") { (entries, error) in
	if error != nil{
		print(error!.localizedDescription)
		return
	}

	print(entries!) //Array of ChartEntry
}



//FOR A PARTICULAR DATE (with individual date components)
manager.getChart(chartType: ChartType.hot100, day: 18, month: 11, year: 2018) { (entries, error) in
	if error != nil{
		print(error!.localizedDescription)
		return
	}

	print(entries!) //Array of ChartEntry
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 9.0+ / OSX 10.10+
  • Swift 4.0+

Installation

Cocoa Pods

To install, simply add the following line to your Podfile:

pod 'BillboardSwiftLibrary'

Swift Package Manager

Add BillboardSwiftLibrary to your Package.swift

import PackageDescription

let package = Package(
dependencies: [
	package(url: "https://github.com/FitzAfful/BillboardSwiftLibrary.git", "0.1.2")
])

Chart entry attributes

A chart entry (typically a single track) is of type ChartEntry. A ChartEntry instance has the following attributes:

  • title – The title of the track.
  • artist – The name of the artist, as formatted on Billboard.com.
  • peakPos – The track's peak position on the chart at any point in time, including future dates, as an int (or None if the chart does not include this information).
  • lastPos – The track's position on the previous week's chart, as an int (or None if the chart does not include this information). This value is 0 if the track was not on the previous week's chart.
  • weeks – The number of weeks the track has been or was on the chart, including future dates (up until the present time).
  • rank – The track's current position on the chart.
  • isNew – Whether the track is new to the chart.

Contributing

Pull requests are welcome!

Think you found a bug? Create an issue here.

Based on Billboard.py by Allen Guo

Author

Fitzafful, fitzafful@gmail.com

License

BillboardSwiftLibrary is available under the MIT license. See the LICENSE file for more info.