public void cb2(JToken obj, string graph_path, fbdump_params p) { try { string n = graph_path.Trim('/').Replace('/', '.'); System.IO.Directory.CreateDirectory(saveto + "/" + n); } catch { } }
public void process_fb_obj(JToken obj, string graph_path, fbdump_params p) { p.objs++; p.cb(obj, graph_path, p); if (obj.Type == JTokenType.Object) { JObject obj1 = (JObject)obj; foreach (JProperty pr in obj1.Properties()) { if (p.expand.Contains(pr.Name)) { if (graph_path.Trim('/') != pr.Value.Value <string> ().Trim('/')) { dump_fb_object(graph_base + pr.Value.Value <string> (), p); } } } } }
public void cb1(JToken obj, string graph_path, fbdump_params p) { if (obj.Type == JTokenType.Object) { JObject obj1 = (JObject)obj; string id = obj1 ["id"].Value <string> (); try { string fn = saveto + "/" + id; if (System.IO.File.Exists(fn)) { p.exists++; } System.IO.FileStream fs = new System.IO.FileStream(fn, p.stop_on_existing ? FileMode.CreateNew : FileMode.Create); JsonWriter w = new JsonTextWriter(new StreamWriter(fs)); obj.WriteTo(w); w.CloseOutput = true; w.Close(); if (graph_path != null) { string n = graph_path.Trim('/').Replace('/', '.'); Mono.Unix.UnixSymbolicLinkInfo inf = new Mono.Unix.UnixSymbolicLinkInfo(saveto + "/" + n + "/" + id); inf.CreateSymbolicLinkTo("../" + id); } foreach (JProperty pr in obj1.Properties()) { if (p.saveurl.Contains(pr.Name)) { saveurl(pr.Value.Value <string> (), id + "." + pr.Name); } } } catch (Exception ex) { Console.WriteLine(ex.Message); if (p.stop_on_existing) { stop(); } } } }
void thr1() { string url = graph_base + t_path.Text.TrimStart('/'); Gdk.Threads.Enter(); p = new fbdump_params(); try { update_labels(); p.atoken = t_atoken.Text; saveto = t_saveto.Text.TrimEnd('/', '\\'); p.stop_on_existing = c_stop.Active; p.timeout = int.Parse(t_timeout.Text); if (r_dontfollow.Active) { p.f = followmode.none; } else if (r_followprev.Active) { p.f = followmode.prev; } else if (r_follownext.Active) { p.f = followmode.next; } if (c_expand.Active) { p.expand = new SortedSet <string> (t_expand.Text.Split(' ')); } else { p.expand = new SortedSet <string> (); } if (c_save.Active) { p.saveurl = new SortedSet <string> (t_save.Text.Split(' ')); } else { p.saveurl = new SortedSet <string> (); } if (c_param.Active && t_param.Text.Length > 0) { string tmp = "&" + t_param.Text; if (url.IndexOf('?') < 0) { url += "?" + tmp; } else { url += "&" + tmp; } } disable_start(); } finally { Gdk.Threads.Leave(); } p.cb = cb1; p.list_cb = cb2; try { dump_fb_object(url, p); } finally { Gdk.Threads.Enter(); try { update_labels(); enable_start(); } finally { Gdk.Threads.Leave(); } } }
public void dump_fb_object(string url, fbdump_params p, bool raw_url = false) { Gdk.Threads.Enter(); try { /*Gtk.Label l = new Gtk.Label ("dumping "+url); * vbox1.Add (l); * l.Show ();*/ Console.WriteLine("dumping " + url); } finally { Gdk.Threads.Leave(); } if (!raw_url) { string tmp = "access_token=" + p.atoken; if (url.IndexOf('?') < 0) { url += "?" + tmp; } else { url += "&" + tmp; } } try { fb_response r = get_object(url, p.timeout); p.pages++; if (r.is_array) { string graph_path = get_graph_path(url); if (p.list_cb != null) { p.list_cb(r.data, graph_path, p); } JArray a = (JArray)r.data; int i; for (i = 0; i < a.Count; i++) { process_fb_obj(a [i], graph_path, p); } } else { process_fb_obj(r.data, null, p); } Gdk.Threads.Enter(); try { update_labels(); } finally { Gdk.Threads.Leave(); } if (p.f == followmode.prev && r.prev_url != null && r.prev_url.Length > 0) { dump_fb_object(r.prev_url, p, true); } else if (p.f == followmode.next && r.next_url != null && r.next_url.Length > 0) { dump_fb_object(r.next_url, p, true); } } catch (Exception ex) { Gdk.Threads.Enter(); try { if (ex.GetType() != typeof(System.Threading.ThreadAbortException)) { p.errors++; perror(ex); update_labels(); } } finally { Gdk.Threads.Leave(); } } }
void thr1 () { string url = graph_base + t_path.Text.TrimStart ('/'); Gdk.Threads.Enter (); p = new fbdump_params (); try { update_labels (); p.atoken = t_atoken.Text; saveto = t_saveto.Text.TrimEnd ('/', '\\'); p.stop_on_existing = c_stop.Active; p.timeout = int.Parse (t_timeout.Text); if (r_dontfollow.Active) p.f = followmode.none; else if (r_followprev.Active) p.f = followmode.prev; else if (r_follownext.Active) p.f = followmode.next; if (c_expand.Active) p.expand = new SortedSet<string> (t_expand.Text.Split (' ')); else p.expand = new SortedSet<string> (); if (c_save.Active) p.saveurl = new SortedSet<string> (t_save.Text.Split (' ')); else p.saveurl = new SortedSet<string> (); if (c_param.Active && t_param.Text.Length > 0) { string tmp = "&" + t_param.Text; if (url.IndexOf ('?') < 0) url += "?" + tmp; else url += "&" + tmp; } disable_start (); } finally { Gdk.Threads.Leave (); } p.cb = cb1; p.list_cb = cb2; try { dump_fb_object (url, p); } finally { Gdk.Threads.Enter (); try { update_labels (); enable_start (); } finally { Gdk.Threads.Leave (); } } }
public void cb2 (JToken obj, string graph_path, fbdump_params p) { try { string n = graph_path.Trim ('/').Replace ('/', '.'); System.IO.Directory.CreateDirectory (saveto + "/" + n); } catch { } }
public void cb1 (JToken obj, string graph_path, fbdump_params p) { if (obj.Type == JTokenType.Object) { JObject obj1 = (JObject)obj; string id = obj1 ["id"].Value<string> (); try { string fn = saveto + "/" + id; if (System.IO.File.Exists (fn)) p.exists++; System.IO.FileStream fs = new System.IO.FileStream (fn, p.stop_on_existing ? FileMode.CreateNew : FileMode.Create); JsonWriter w = new JsonTextWriter (new StreamWriter (fs)); obj.WriteTo (w); w.CloseOutput = true; w.Close (); if (graph_path != null) { string n = graph_path.Trim ('/').Replace ('/', '.'); Mono.Unix.UnixSymbolicLinkInfo inf = new Mono.Unix.UnixSymbolicLinkInfo (saveto + "/" + n + "/" + id); inf.CreateSymbolicLinkTo ("../" + id); } foreach (JProperty pr in obj1.Properties()) { if (p.saveurl.Contains (pr.Name)) { saveurl (pr.Value.Value<string> (), id + "." + pr.Name); } } } catch (Exception ex) { Console.WriteLine (ex.Message); if (p.stop_on_existing) { stop (); } } } }
public void dump_fb_object (string url, fbdump_params p, bool raw_url=false) { Gdk.Threads.Enter (); try { /*Gtk.Label l = new Gtk.Label ("dumping "+url); vbox1.Add (l); l.Show ();*/ Console.WriteLine ("dumping " + url); } finally { Gdk.Threads.Leave (); } if (!raw_url) { string tmp = "access_token=" + p.atoken; if (url.IndexOf ('?') < 0) url += "?" + tmp; else url += "&" + tmp; } try { fb_response r = get_object (url, p.timeout); p.pages++; if (r.is_array) { string graph_path = get_graph_path (url); if (p.list_cb != null) p.list_cb (r.data, graph_path, p); JArray a = (JArray)r.data; int i; for (i=0; i<a.Count; i++) { process_fb_obj (a [i], graph_path, p); } } else process_fb_obj (r.data, null, p); Gdk.Threads.Enter (); try { update_labels (); } finally { Gdk.Threads.Leave (); } if (p.f == followmode.prev && r.prev_url != null && r.prev_url.Length > 0) dump_fb_object (r.prev_url, p, true); else if (p.f == followmode.next && r.next_url != null && r.next_url.Length > 0) dump_fb_object (r.next_url, p, true); } catch (Exception ex) { Gdk.Threads.Enter (); try { if (ex.GetType () != typeof(System.Threading.ThreadAbortException)) { p.errors++; perror (ex); update_labels (); } } finally { Gdk.Threads.Leave (); } } }
public void process_fb_obj (JToken obj, string graph_path, fbdump_params p) { p.objs++; p.cb (obj, graph_path, p); if (obj.Type == JTokenType.Object) { JObject obj1 = (JObject)obj; foreach (JProperty pr in obj1.Properties()) { if (p.expand.Contains (pr.Name)) { if(graph_path.Trim ('/')!=pr.Value.Value<string> ().Trim ('/')) dump_fb_object (graph_base + pr.Value.Value<string> (), p); } } } }