lou5

Members
  • Posts

    31
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by lou5

  1. Hope everyone is doing well! The BitTorrent team will be at Empire Garage (at SXSW) talking about Sync. Come down to hang out, learn more about the awesome stuff you can do with the app, and demo the API. Stay for the free drinks and live music. (Of course.)

     

    Join the group here --> http://www.meetup.com/BitTorrent-Sync-User-Group/

     

    Event --> http://www.meetup.com/BitTorrent-Sync-User-Group/events/168108862/

  2. Hey everyone, 

     

    We have some sample code in case anyone finds this helpful. 

     

     filename: api_sample.py 

    import httplibimport urllibimport jsonimport osimport subprocessimport base64import shutilimport timeimport platformAPI_KEY = 'XXX' # INSERT YOUR API KEY HERE!btsyncbin_mac = 'BitTorrent Sync.app/Contents/MacOS/BitTorrent Sync'btsyncbin_win = 'BTSync.exe'btsyncbin_linux = 'btsync'config_param_posix = '--config'config_param_win = '/config'class SyncInstance:    def __init__(self, configName, storagePath, port):        self.port = port        self.configPath = os.path.join(os.getcwd(), configName)        self.storagePath = os.path.join(os.getcwd(), storagePath)         shutil.rmtree(self.storagePath, True)         os.mkdir(self.storagePath)         config = {}         config['storage_path'] = self.storagePath         config['use_gui'] = False        webuiConfig = {}        webuiConfig['login'] = 'apitest'        webuiConfig['password'] = 'apipass'        webuiConfig['listen'] = '127.0.0.1:%d' % port        webuiConfig['api_key'] = API_KEY        config['webui'] = webuiConfig        configFile = open(self.configPath, 'w')        json.dump(config, configFile)        configFile.close()    def launch(self):        if platform.system() == 'Windows':            btsyncbin = btsyncbin_win            configParam = config_param_win        elif platform.system() == 'Darwin':            btsyncbin = btsyncbin_mac            configParam = config_param_posix        else:            btsyncbin = btsyncbin_linux            configParam = config_param_posix           binaryPath = os.path.join(os.getcwd(), btsyncbin)         subprocess.Popen([binaryPath, configParam, self.configPath])    def request(self, request):        try:            conn = httplib.HTTPConnection('localhost:%d' % self.port)            headers = {'Authorization': 'Basic ' + base64.b64encode('apitest:apipass')}            params = urllib.urlencode(request)            conn.request('GET', '/api?' + params, '', headers)            resp = conn.getresponse()            if resp.status == 200:                return json.load(resp)            else:                return None        except:            return Nonedef writeFile(folder, filename, count):    f = open(os.path.join(folder, filename), 'w+')    for i in range(1, count):        f.write('%d' % i )    f.close()def main():    if API_KEY == 'XXX':        print 'In order to run this sample code please insert a valid API key!'        return 1    instance1 = SyncInstance('sync1.conf', 'storagepath1', 8888)    instance2 = SyncInstance('sync2.conf', 'storagepath2', 8889)    instance1.launch()    instance2.launch()    print 'Waiting for the BitTorrent Sync instances to start...'    while True:        version1 = instance1.request({'method' : 'get_version'})        version2 = instance2.request({'method' : 'get_version'})        if version1 is not None and version2 is not None:            break        time.sleep(0.2)    print 'Generating secrets on the first instance...'    secret = instance1.request({'method' : 'get_secrets', 'type' : 'encryption'})    print secret    syncFolderPath1 = os.path.join(os.getcwd(), 'path1')    shutil.rmtree(syncFolderPath1, True)    os.mkdir(syncFolderPath1)    writeFile(syncFolderPath1, 'file1', 300)    writeFile(syncFolderPath1, 'file2', 500)    print 'Adding a folder on the first instance via read-write secret...'    addFolderRes = instance1.request({'method' : 'add_folder', 'dir' : syncFolderPath1, 'secret' : secret['read_write']})    if 'error' in addFolderRes and addFolderRes['error'] != 0:        print 'Error %d while adding folder' % addFolderRes['error']    folders = instance1.request({'method' : 'get_folders', 'secret' : secret['read_write']})    print folders    print 'Waiting while the files are being indexed...'    while True:        folders = instance1.request({'method' : 'get_folders', 'secret' : secret['read_write']})        if folders and folders[0]['indexing'] == 0 and folders[0]['files'] == 2:            break        time.sleep(0.2)    print folders    print 'Getting a file list on the first instance...'    files = instance1.request({'method' : 'get_files', 'secret' : secret['read_write']})    print files    syncFolderPath2 = os.path.join(os.getcwd(), 'path2')    shutil.rmtree(syncFolderPath2, True)    os.mkdir(syncFolderPath2)    print 'Adding a folder to the second instance via read-only secret...'    addFolderRes = instance2.request({'method' : 'add_folder', 'dir' : syncFolderPath2, 'secret' : secret['read_only'], 'selective_sync' : 1})    if 'error' in addFolderRes and addFolderRes['error'] != 0:        print 'Error %d while adding folder' % addFolderRes['error']    print 'Receiving the file list on the second instance...'    while True:        files = instance2.request({'method' : 'get_files', 'secret' : secret['read_only']})        if files:            break        time.sleep(0.2)        print 'Selecting "file2" for download on the second instance...'    fileRes = instance2.request({'method' : 'set_file_prefs', 'secret' : secret['read_only'], 'path' : 'file2', 'download' : 1})    print fileRes        print 'Downloading "file2"...'    while True:        fileRes = instance2.request({'method' : 'get_files', 'secret' : secret['read_only'], 'path' : 'file2'})        if fileRes and fileRes[0]['have_pieces'] == fileRes[0]['total_pieces']:            break        time.sleep(0.2)     print fileRes    print 'Download finished'    print 'Shutting down the BitTorrent Sync instances...'    instance1.request({'method' : 'shutdown'})    instance2.request({'method' : 'shutdown'})main()
  3. Hi everyone, 

     

    We're pretty excited about the API and what everyone can potentially create using it. If you have something you want to share and showcase, let us know by posting here. This would probably be the best place to get feedback also. 

     

    Lou

  4. Encrypted peers seem like a feature that many end users would like to use for backing up data to an untrusted location.

    Is there a reason why you decided to "hide" this behind a developer-only API ? 

     

    We did this for a few reasons actually. First, we wanted to try to keep the user experience as simple as possible and we thought that adding this might be confusing for many new users. Second, there was a technical reason also. When we update our releases, we typically add all the features across platforms (for feature consistency) - we found that adding Encrypted Peers to the mobile apps didn't produce the best experience so until we find a better way to do it, we elected to leave it out... for now. Its definitely something we plan to add but we're trying to do it in a effective way. 

     

    Hope that answers your question. 

  5. Hi everyone,
     
    We're really excited to release the API and the newest version of Sync. We've been working incredibly hard for the last several months and we know that we still have lots more to do. Feedback from our Beta users has been invaluable to building the best possible tool to date and we hope our API community will be no different.
     
    This will be the forum to tell tell us what you think about the API. The dev team will be very active in addressing your questions, listening to feedback and keeping an eye out for the cool apps and tools built with the API. 
     
    We also hope this is a forum for the API community to collaborate, share, and work together to spark the next wave of Internet innovation. 
     
    Thank you for all your support and we're excited to see what's next. 
     
    Lou

     

  6. Sorry for the delay. We won't have anything for you guys in the near-term. We're still working out some details but I'm hoping we can start putting something together soon. We'll be updating the forum with more info as soon as we can lock it down.

  7. Great, thank you!

    It would be nice to have a way to share the secrets in an easier way while avoiding e-mail transmission.

    QR code?

    or at least format the secret in blocks of 4 or five character?

    Hi, the app does support QR codes. If you right click on a folder and select "Connect mobile" it will display a QR code.

  8. I'd been hitting the storage limit on my dropbox so I looked in to setting up my own cloud storage.

    I share a music folder with ~8 people for DJing, with music files whose metadata is constantly being updated.

    I looked into ownCloud and it seemed up to snuff. Purchased a domain and shared hosting from dreamhost -- setup was simple enough. But damn, the Windows client was buggy and borderline unusable. The only way to tell if you were uploading was from the taskbar icon changing color. There was no way to see what files you were uploading, how much data you were using, etc. I looked on github and this issue has been open for 6 months...

    So I gave BTSync and try and holy shit it's exactly what we need. I'm looking forward to more of the fubctionalities dropbox has, but this program seems to be pretty stable for the ~1200 files we have.

    I'm not too technically inclined, so I don't know if this is already possible or just imfeasible, but it'd be cool I'd you could add a server (shared hosting) and there was a web gui to access your files from anywhere, share links to files, versioning, etc.

    BTsync is the dropbox killer app... Inherently free and scalable. Good work!

    With our last release there is a SyncArchive that holds previous versions of your files. In case you need it, it is there - just hidden. Also, we are working on a new GUI to address your needs.