Commit d879c9ce authored by supriya sawant's avatar supriya sawant

script written to fetch wetube videos using crontab

parent 1d75233a
''' imports from installed packages '''
from django.core.management.base import BaseCommand, CommandError
from django_mongokit import get_database
try:
from bson import ObjectId
except ImportError: # old pymongo
from pymongo.objectid import ObjectId
''' imports from application folders/files '''
from gnowsys_ndf.ndf.models import Node
import ox
db =get_database()
collection = db['Nodes']
####################################################################################################################
class Command(BaseCommand):
"""This script save wetube.gnowledge.org videos data in GSystem
"""
help = "\tThis script save wetube.gnowledge.org videos data in GSystem "
def handle(self, *args, **options):
main()
# --- End of handle() ---
def main():
api=ox.api.API("http://wetube.gnowledge.org/api")
countVideo = api.find({"query":{"operator":"&","conditions":[{"operator":"==","key":"project","value":"NROER"}]}})
totalVideoNo=countVideo['data']['items']
allVideo = api.find({"keys":["id","title","director","id","posterRatio","year","user"],"query":{"conditions":[{"oper\
ator":"==","key":"project","value":"NROER"}],"operator":"&"},"range":[0,totalVideoNo],"sort":[{"operator":"+","key":"title"}]})
allVideosData=allVideo['data']['items']
pandora_video_st=collection.Node.one({'$and':[{'name':'Pandora_video'},{'_type':'GSystemType'}]})
source_id_at=collection.Node.one({'$and':[{'name':'source_id'},{'_type':'AttributeType'}]})
pandora_video_id=[]
source_id_set=[]
for each in allVideosData[:1000]:
gattribute=collection.Node.one({'$and':[{'object_value':each['id']},{'_type':'GAttribute'},{'attribute_type.$id':source_id_at._id}]})
if gattribute is None:
#gs=collection.GSystem()
gs=collection.File()
gs.mime_type="video"
gs.member_of=[pandora_video_st._id]
gs.name=each['title'].lower()
gs.created_by=1
gs.modified_by = 1
if 1 not in gs.contributors:
gs.contributors.append(1)
gs.save()
at=collection.GAttribute()
at.attribute_type=source_id_at
at.object_value=each['id']
at.subject=gs._id
at.save()
get_member_set=collection.Node.find({'$and':[{'member_of': {'$all': [ObjectId(pandora_video_st._id)]}},{'_type':'File'}]})
print list(get_member_set)[0]
{% extends "ndf/base.html" %}
{% load ndf_tags %}
{% load pagination_tags %}
......@@ -167,11 +166,6 @@ background-repeat:no-repeat; background-size: 48px 48px
Edit&nbsp;&nbsp;<i class="fi-plus"></i>
</a>
</td>
<td>
<a class="button medium" href="{% url 'adminDesignerDashboardClassEdit' class_name each.Id %}?translate=True">
Translate
</td>
</tr>
{% endfor %}
......@@ -436,3 +430,4 @@ $(document).on('focus',".member_of input",function(){
});
{% endif %}
{% endblock %}
......@@ -10,7 +10,6 @@
{% endblock %}
{% block body_content %}
<link rel="stylesheet" type="text/css" href="/static/ndf/orgitdown/skins/gstudio/style.css" />
<form method="post" action="" name="{{class_name}}">
{% csrf_token %}
......@@ -33,13 +32,6 @@
<font size="3" color="red"> * </font><font id="{{list}}_required" style="display:none" color="red">This field required</font>
</div>
{% endif %}
{% if translate %}
<div style="display:table-cell;">
<font size="3"> {{list}}</font>
</div>
{% get_input_fields class_structure|get_dict_item:list list translate %}
{% endif %}
</div>
{% endfor %}
</div>
......@@ -53,12 +45,7 @@
{% for list in contentlist %}
<div class="medium-12 columns">
{% include "ndf/add_editor.html" with var_name="content_org" var_placeholder="Enter the content here" var_value=node.content_org|default_if_none:"" node_id=node.pk %}
{% if translate %}
{% include "ndf/add_editor.html" with var_name="content_org" var_placeholder="Enter the content here" var_value="" %}
{% endif %}
</div>
{% endfor %}
<script type="text/javascript">
......@@ -88,17 +75,9 @@ $(".orgitdown .orgitdownButton9 a").css({"background-image":'url("/static/ndf/or
<div style="display:table-cell;">
<font size="3"> {{list}}</font>
</div>
{% get_input_fields class_structure|get_dict_item:list list translate %}
{% if translate %}
<div style="display:table-cell;">
<font size="3"> {{list}}</font>
</div>
{% get_input_fields class_structure|get_dict_item:list list translate %}
{% endif %}
</div>
{% get_input_fields class_structure|get_dict_item:list list %}
</div>
{% endfor %}
</div>
</dd>
</dl>
......@@ -111,16 +90,7 @@ $(".orgitdown .orgitdownButton9 a").css({"background-image":'url("/static/ndf/or
<div style="display:table-cell;">
<font size="3"> {{list}}</font>
</div>
{% get_input_fields class_structure|get_dict_item:list list translate %}
{% if translate%}
<div style="display:table-cell;">
<font size="3"> {{list}}</font>
</div>
{% get_input_fields class_structure|get_dict_item:list list translate %}
{% endif %}
{% get_input_fields class_structure|get_dict_item:list list %}
</div>
{% endfor %}
......@@ -131,9 +101,6 @@ $(".orgitdown .orgitdownButton9 a").css({"background-image":'url("/static/ndf/or
</div>
<input type="submit" name="submit" class="button" id="save-node-type" value="Submit">
</form>
{% endblock %}
{% block script %}
......@@ -169,3 +136,4 @@ event.preventDefault();
var type_list = []
</script>
{% endblock %}
......@@ -37,7 +37,6 @@
{% endif %}
</div>
{% elif fields_type == "bool" %}
<select id="id_auto_now_add" name="{{fields_name}}" style="width:50%">
<option value="0">Unknown</option>
......@@ -94,3 +93,4 @@
</div>
{% endif %}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment