@@ -0,0 +1,1747 @@
+#!/usr/bin/env python%0A%0Afrom __future__ import unicode_literals%0Aimport time%0A%0Afrom django.core.management.base import BaseCommand%0A%0Aimport requests%0A%0Afrom WhatManager2.utils import wm_unicode%0A%0Afrom home.models import get_what_client%0Afrom what_transcode.tasks import TranscodeSingleJob%0A%0A%0Adef _add_to_wm_transcode(what_id):%0A    print 'Adding %7B0%7D to wm'.format(what_id)%0A    post_data = %7B%0A        'what_id': what_id,%0A    %7D%0A    response = requests.post('https://karamanolev.com/wm/transcode/request', data=post_data,%0A                             auth=('ivailo', 'Heman3f5'))%0A    response_json = response.json()%0A    if response_json%5B'message'%5D != 'Request added.':%0A        raise Exception('Cannot add %7B0%7D to wm: %7B1%7D'.format(what_id, response_json%5B'message'%5D))%0A%0A%0Adef add_to_wm_transcode(what_id):%0A    for i in range(2):%0A        try:%0A            _add_to_wm_transcode(what_id)%0A            return%0A        except Exception:%0A            print 'Error adding to wm, trying again in 2 sec...'%0A            time.sleep(3)%0A    _add_to_wm_transcode(what_id)%0A%0A%0Adef report_progress(msg):%0A    print msg%0A%0A%0Aclass Command(BaseCommand):%0A    help = 'Help you create a torrent and add it to WM'%0A%0A    def handle(self, *args, **options):%0A        if len(args) != 1:%0A            print u'Pass only the source directory.'%0A            return 1%0A        source_dir = wm_unicode(args%5B0%5D)%0A        if source_dir.endswith('/'):%0A            source_dir = source_dir%5B:-1%5D%0A%0A        what = get_what_client(lambda: None)%0A        job = TranscodeSingleJob(what, None, report_progress, None, None, source_dir)%0A        job.create_torrent()%0A        raw_input('Please upload the torrent and press enter...')%0A        job.move_torrent_to_dest()%0A        add_to_wm_transcode(job.new_torrent%5B'torrent'%5D%5B'id'%5D)%0A

Add upload_manual_flac management command.