Beispiel #1
0
def select_device():
    session['status'] = None
    session['device_id'] = None
    if not session['username']:
        username = request.form.getlist('username')[0]
        session['username'] = username
        password = request.form.getlist('password')[0]
        session['password'] = password
    else:
        username = session['username']
        password = session['password']
    try:
        api_client = api.MygPodderClient(username, password)
        devices = api_client.get_devices()
        title = "Devices"
        if len(devices) == 0:
            session['device_id'] = username + "s-device" #no device. Made one for ya. No subs tho :(
            return redirect(url_for('dashboard'))
        if len(devices) == 1:
            session['device_id'] = devices[0].device_id #only one device. Defaults to that. Easy peasysession.
            return redirect(url_for('dashboard'))
        return render_template('select-devices.html', devices = devices, title = title)
    except:
        login()
        title = "login"
        status = "attempt"
        return render_template('login.html', title = title, status = status)
Beispiel #2
0
 def on_config_changed(self, name=None, old_value=None, new_value=None):
     if name in ('mygpo.username', 'mygpo.password', 'mygpo.server') \
             or self._client is None:
         self._client = api.MygPodderClient(self._config.mygpo.username,
                 self._config.mygpo.password, self._config.mygpo.server)
         logger.info('Reloading settings.')
     elif name.startswith('mygpo.device.'):
         # Update or create the device
         self.create_device()
Beispiel #3
0
    def __init__(self, hass, username, password, device, name):
        """Initialize."""
        self.hass = hass
        self.name = name
        self.api = api.MygPodderClient(username, password)
        self.device = device

        super().__init__(hass,
                         _LOGGER,
                         name=DOMAIN,
                         update_interval=UPDATE_INTERVAL)
Beispiel #4
0
def account():
    username = session['username']
    password = session['password']
    device_id = session['device_id']
    api_client = api.MygPodderClient(username, password)
    devices = api_client.get_devices()
    for dev in devices:
        if dev.device_id == device_id:
            num_subs = dev.subscriptions
            break
    return render_template('account.html', device_id = device_id, username = username, num_subs = num_subs)
Beispiel #5
0
def login(request):
    if request.method=="POST":
        try:
            username = request.POST.get('user')
            password = request.POST.get('pass')
            user = api.MygPodderClient(username, password)
            
        except :
            print("invalid!")
            return render_to_response('podcast/login.html', {"error" : "Invalid Username or Password!"})
    response = render_to_response("template.html", {})
    response['Cache-Control'] = 'no-cache'
    return response

    
async def async_setup(hass, config):
    """Set up this component."""
    from mygpoclient import api
    # Print startup message
    startup = STARTUP.format(name=DOMAIN, version=VERSION, issueurl=ISSUE_URL)
    _LOGGER.info(startup)

    # Check that all required files are present
    file_check = await check_files(hass)
    if not file_check:
        return False

    # Create DATA dict
    hass.data[DOMAIN_DATA] = {}
    hass.data[DOMAIN] = {}
    component_config = config[DOMAIN]

    # Create gPodder client
    hass.data[DOMAIN]["client"] = api.MygPodderClient(
        component_config[CONF_USERNAME], component_config[CONF_PASSWORD])

    # Load platforms
    for platform in PLATFORMS:
        # Get platform specific configuration
        platform_config = component_config.get(platform, {})

        if not platform_config:
            continue

        for entry in platform_config:
            entry_config = entry

            # If entry is not enabled, skip.
            if not entry_config[CONF_ENABLED]:
                continue

            hass.async_create_task(
                discovery.async_load_platform(hass, platform, DOMAIN,
                                              entry_config, config))
    return True
Beispiel #7
0
def login_view(request):
    if request.method == 'POST':
        form = AuthenticationForm(data=request.POST)

        if form.is_valid():
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password')
            user = authenticate(username=username, password=raw_password)
            login(request, user)

            form2 = ProfileForm(data=request.POST,
                                instance=request.user.profile)
            form2.save()
            if form2.is_valid():
                global client
                client = api.MygPodderClient(username, raw_password)

                return redirect('newsfeed')
        else:
            return render(request, 'login.html', {'form': form})
    else:
        form = AuthenticationForm()
        form2 = ProfileForm()
    return render(request, 'login.html', {'form': form, 'form2': form2})
Beispiel #8
0
 def setUp(self):
     self.fake_client = testing.FakeJsonClient()
     self.client = api.MygPodderClient(self.USERNAME,
                                       self.PASSWORD,
                                       client_class=self.fake_client)
def get_client_subs(username, password, device_id):
    my_client = api.MygPodderClient(username, password, 'gpodder.net')
    subs = []
    for url in my_client.get_subscriptions(device_id):
        subs.append(public_client.get_podcast_data(url))
    return subs
# SORTING CONSTANTS

NONE = 0
BY_POP = 1
BY_MONTHLY_AVG = 2
BY_LAST_3MONTHS = 3
BY_SUBS_GAINED = 4

# CLIENT FUNCTIONS

username = ""  # aditer
password = ""  # 7424
device_id = ""  # aditi

my_client = api.MygPodderClient(username, password, 'gpodder.net')

num = 15


def get_client_subs(username, password, device_id):
    my_client = api.MygPodderClient(username, password, 'gpodder.net')
    subs = []
    for url in my_client.get_subscriptions(device_id):
        subs.append(public_client.get_podcast_data(url))
    return subs


def get_subscriptions(username, password, device_id, order=NONE):
    subs = get_client_subs(username, password, device_id)
    subs = subs[0:num]
Beispiel #11
0
import feedparser
from operator import itemgetter
import time
from dateutil.parser import parse

# Create your views here.
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from django.template.defaulttags import register
...

client = public.PublicClient()
username = "******"
password = "******"

user = api.MygPodderClient(username, password)
toplist = client.get_toplist()
top_tags_list = client.get_toptags()
list = []
subscriptions = []
subscriptions_url = []
device = api.PodcastDevice('top25', 'mydevice', 'desktop', 0)

for i in range(25):
    list.append(toplist[i].__dict__)
    subscriptions.append(toplist[i].__dict__)
    subscriptions_url.append(toplist[i].url)

user.put_subscriptions(device.device_id, subscriptions_url)