Skip to content

Instantly share code, notes, and snippets.

@jorupp
Created May 27, 2015 23:24
Show Gist options
  • Save jorupp/6fcd97f8ad633eeb54c3 to your computer and use it in GitHub Desktop.
Save jorupp/6fcd97f8ad633eeb54c3 to your computer and use it in GitHub Desktop.
Wander around MSDN downloads
void Main()
{
GetFilesForProduct(546).Result.Dump();
return;
var letters = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
var allTasks = letters.Select(i => GetProductsFor(i.ToString())).ToArray();
Task.WaitAll(allTasks);
var allData = allTasks.SelectMany (t => t.Result).ToList();
allData.Dump();
}
async Task<Product[]> GetProductsFor(string letter)
{
var c = new HttpClient();
var content = new StringContent(@"{""brand"":""MSDN"",""alphabet"":""" + letter + @"""}", Encoding.UTF8, "application/json");
var result = await c.PostAsync(new Uri("https://msdn.microsoft.com/en-us/subscriptions/json/GetProductsInAlphabeticalOrder"), content);
return JsonConvert.DeserializeObject<Product[]>(await result.Content.ReadAsStringAsync());
}
async Task<FileSearchResult> GetFilesForProduct(int productFamilyId) {
var c = new HttpClient();
var content = new StringContent(@"{""Languages"":""en"",""Architectures"":"""",""ProductFamilyIds"":"""",""FileExtensions"":"""",""MyProducts"":false,""ProductFamilyId"":"+ productFamilyId + @",""SearchTerm"":"""",""Brand"":""MSDN"",""PageIndex"":0,""PageSize"":1000,""FileId"":0}", Encoding.UTF8, "application/json");
var result = await c.PostAsync(new Uri("https://msdn.microsoft.com/en-us/subscriptions/json/GetFileSearchResult"), content);
return JsonConvert.DeserializeObject<FileSearchResult>(await result.Content.ReadAsStringAsync());
}
class Product {
public int ProductFamilyId { get; set; }
public string Title { get; set; }
public int ProductGroupId { get; set; }
}
class FileSearchResult {
public FileResult[] Files { get; set; }
public int TotalResults { get; set; }
}
class FileResult {
public string BenefitLevels { get; set; }
public string Description { get; set; }
public string FileName { get; set; }
public bool IsAuthorization { get; set; }
public bool IsProductKeyRequired { get; set; }
public string Sha1Hash { get; set; }
}
// Define other methods and classes here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment