Meeskond "Juutuub": Difference between revisions
No edit summary |
No edit summary |
||
(7 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
Meeskonna nimeks on Juutuub ja kasutame youtube.com, et teha veebis asuv videode playlist. | Meeskonna nimeks on Juutuub ja kasutame youtube.com, et teha veebis asuv videode playlist. | ||
sourcecode | |||
http://enos.itcollege.ee/~mlausmaa/c%23/Youtube.zip | |||
---- | ---- | ||
Line 20: | Line 24: | ||
http://youtube.myfolderburg.com/search.xml | http://youtube.myfolderburg.com/search.xml | ||
autocomplete teenus on tehtud "Ajax Control Toolkit" abil | autocomplete teenus on tehtud "Ajax Control Toolkit" abil | ||
'''XML-i ülesehitus''' | |||
<source lang="xml"> | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<?xml-stylesheet type="text/xsl" href="XSLT.xsl"?> | |||
<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd"> | |||
<searchWord> | |||
<name>tere</name> | |||
<count>3</count> | |||
</searchWord> | |||
<searchWord> | |||
<name>tele</name> | |||
<count>3</count> | |||
</searchWord> | |||
<searchWord> | |||
<name>teflon</name> | |||
<count>26</count> | |||
</searchWord> | |||
</info> | |||
</source> | |||
---- | |||
XSLT | |||
<source lang="xml"> | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |||
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" | |||
> | |||
<xsl:template match="/"> | |||
<html> | |||
<body> | |||
<h2>Otsinguks kasutatud sõnad</h2> | |||
<table border="1"> | |||
<tr bgcolor="#9acd32"> | |||
<th>Sõna</th> | |||
<th>Kordade arv</th> | |||
</tr> | |||
<xsl:for-each select="info/searchWord"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="name"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="count"/> | |||
</td> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
<p>Klikke kokku: <xsl:value-of select="sum(info/searchWord/count)" /></p> | |||
</body> | |||
</html> | |||
</xsl:template> | |||
</xsl:stylesheet> | |||
</source> | |||
---- | |||
'''autocompleteri kood''' | |||
<source lang="csharp"> | |||
using System; | |||
using System.Collections; | using System.Collections; | ||
using System.ComponentModel; | using System.ComponentModel; | ||
using System.Data; | using System.Data; | ||
using System.Linq; | using System.Linq; | ||
using System.Web; | using System.Web; | ||
using System.Web.Services; | using System.Web.Services; | ||
using System.Web.Services.Protocols; | using System.Web.Services.Protocols; | ||
using System.Xml.Linq; | using System.Xml.Linq; | ||
using System.Collections.Generic; | using System.Collections.Generic; | ||
Line 72: | Line 142: | ||
} | } | ||
} | } | ||
} | } | ||
</source> | |||
---- | ---- | ||
Line 80: | Line 149: | ||
Saab otsida videosid, mis on üleval youtubes ja neid maha mängida. | Saab otsida videosid, mis on üleval youtubes ja neid maha mängida. | ||
Saab otsida playliste, mis on üleval youtubes ja seda maha mängima panna. | Saab otsida playliste, mis on üleval youtubes ja seda maha mängima panna. | ||
Saab vaadata enda playlistis olevaid videosid ja neid maha mängida. | Saab vaadata enda playlistis olevaid videosid ja neid maha mängida. | ||
Line 88: | Line 159: | ||
Kuna kasutame youtube API-t, siis kasutame ühte kasutajat, mis on kirjeldatud koodis. | Kuna kasutame youtube API-t, siis kasutame ühte kasutajat, mis on kirjeldatud koodis. | ||
Videosid saab lisada oma playlisti | Videosid saab lisada oma playlisti | ||
Saab teha samale kasutajale uue playlisti | Saab teha samale kasutajale uue playlisti | ||
'''rakenduse üldloogika''' | |||
<source lang="csharp">using System; | |||
using System.Collections; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Linq; | |||
using System.Web; | |||
using System.Web.Security; | |||
using System.Web.UI; | |||
using System.Web.UI.HtmlControls; | |||
using System.Web.UI.WebControls; | |||
using System.Web.UI.WebControls.WebParts; | |||
using System.Xml.Linq; | |||
using Google.GData.Client; | |||
using Google.GData.Extensions; | |||
using Google.GData.Extensions.MediaRss; | |||
using Google.YouTube; | |||
using Google.GData.YouTube; | |||
using System.Collections.Generic; | |||
namespace Youtube | |||
{ | |||
public partial class _Default : System.Web.UI.Page | |||
{ | |||
protected void Page_Load(object sender, EventArgs e) | |||
{ | |||
TextBox1.Attributes.Add("autocomplete", "off"); // turn off default autocomplete for all browsers | |||
sessionStart(); // check sessions and initialize | |||
Panel2.Visible = false; | |||
if (showPanel) Panel2.Visible = true; | |||
if (searchQuery.Length > 1 && searchMode) findVideo(); | |||
else if (searchQuery.Length > 1) requestPlaylist(); | |||
addedLists(); // retrieve entries from default playlist | |||
foreach (Playlist p in retrievedPlaylists) | |||
{ | |||
if (!(DropDownList1.Items.Contains(new ListItem(p.Title)))) DropDownList1.Items.Add(new ListItem(p.Title)); | |||
} | |||
} | |||
// event handler | |||
protected void buttonClicked(Object sender, CommandEventArgs e) | |||
{ | |||
YouTubeMovieID = Convert.ToString(e.CommandArgument); | |||
Session["YouTubeMovieID"] = YouTubeMovieID; | |||
} | |||
// find playlists for specified user | |||
protected void Button1_Click(object sender, EventArgs e) | |||
{ | |||
searchQuery = TextBox1.Text; | |||
Session["searchQuery"] = searchQuery; | |||
Session["searchMode"] = null; | |||
saveQuery(sender, e); | |||
Session["showPanel"] = true; | |||
Response.Redirect(Request.RawUrl); | |||
} | |||
// show all entries under "My playlists" | |||
protected void Button2_Click(object sender, EventArgs e) | |||
{ | |||
searchQuery = "juutuub888"; | |||
Session["searchQuery"] = searchQuery; | |||
Session["searchMode"] = null; | |||
Session["showPanel"] = true; | |||
Response.Redirect(Request.RawUrl); | |||
} | |||
// adding a new playlist | |||
protected void Button3_Click(object sender, EventArgs e) | |||
{ | |||
YouTubeRequestSettings settings = new YouTubeRequestSettings(applicationName, developerKey, username, password); | |||
YouTubeRequest request = new YouTubeRequest(settings); | |||
Playlist pl = new Playlist(); | |||
pl.Title = TextBox2.Text; | |||
Playlist createdPlaylist = request.Insert( | |||
new Uri("http://gdata.youtube.com/feeds/api/users/juutuub888/playlists"), pl); | |||
} | |||
// adding a video to the playlist | |||
protected void Button4_Click(object sender, EventArgs e) | |||
{ | |||
YouTubeRequestSettings settings = new YouTubeRequestSettings(applicationName, developerKey, username, password); | |||
YouTubeRequest request = new YouTubeRequest(settings); | |||
PlayListMember pm = new PlayListMember(); | |||
pm.Id = YouTubeMovieID; | |||
request.AddToPlaylist(retrievedPlaylists[DropDownList1.SelectedIndex], pm); | |||
} | |||
// find video | |||
protected void Button5_Click(object sender, EventArgs e) | |||
{ | |||
searchQuery = TextBox1.Text; | |||
Session["searchQuery"] = searchQuery; | |||
Session["searchMode"] = true; | |||
saveQuery(sender, e); | |||
Session["showPanel"] = true; | |||
Response.Redirect(Request.RawUrl); | |||
} | |||
} | |||
} | |||
</source> | |||
---- | |||
'''Töödejaotus''' | |||
Markus - idee, wikipedia, funktsionaalsus | |||
Marko - idee, kood | |||
Jaagup - XSL,XML | |||
Valdar - projekti üldplaani koostamine, wiki | |||
Margus - XML, projekti üldplaani koostamine | |||
---- | |||
'''Meeskonna käekäik''' | |||
18.mai | |||
XML ja XSL lisamine ülejäänud projektile | |||
17.mai | 17.mai | ||
http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog | http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog | ||
10.mai | |||
Marko näitab esialgset koodi ja kuidas asi hakkab toimima | |||
3.mai | 3.mai | ||
Line 130: | Line 329: | ||
---- | ---- | ||
'''Hinnang tööle''' | |||
Olenemata esialgsest tähtajast, mis oli 12 mai, saime oma projekti valmis 10 päeva hiljem. Esialgne funktsionaalsus, mille planeerisime, saime ka tehtud. Jätsime ära kasutajate segmenteerimise, sest youtube api, mis on osa google apist, nõuab registreerimist ja koodis saab kasutada ainult registreeritud kasutajat. | |||
Oleme tehtud tööga rahul ja näeme, et c# on mõistlik keel. |
Latest revision as of 21:43, 28 May 2010
Meeskonna nimeks on Juutuub ja kasutame youtube.com, et teha veebis asuv videode playlist.
sourcecode
http://enos.itcollege.ee/~mlausmaa/c%23/Youtube.zip
Idee
Idee oli teha videode mahamängimise teenus ja rakendus, mis kasutab youtube.com-i. Mõeldud, tehtud.
Teostus
Markus ja Marko mõtlesid umbes välja, kuidas süsteem peaks töötama. Suhtlemiseks kasutasime Win Live Messenger teenust. Meeskonda võtsime veel juurde Valdari, Marguse ja Jaagupi. Jagasime omavahel ülesanded, mida kirjeldame allpool
XML andmefail
XML andmefaili kasutame autocompleteri jaoks ja XSL faili, et genereerida autocompleteri kohta statistika. http://youtube.myfolderburg.com/search.xml autocomplete teenus on tehtud "Ajax Control Toolkit" abil XML-i ülesehitus
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="XSLT.xsl"?>
<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
<searchWord>
<name>tere</name>
<count>3</count>
</searchWord>
<searchWord>
<name>tele</name>
<count>3</count>
</searchWord>
<searchWord>
<name>teflon</name>
<count>26</count>
</searchWord>
</info>
XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:template match="/">
<html>
<body>
<h2>Otsinguks kasutatud sõnad</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Sõna</th>
<th>Kordade arv</th>
</tr>
<xsl:for-each select="info/searchWord">
<tr>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="count"/>
</td>
</tr>
</xsl:for-each>
</table>
<p>Klikke kokku: <xsl:value-of select="sum(info/searchWord/count)" /></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
autocompleteri kood
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;
namespace Youtube
{
/// <summary>
/// Google searchbox like autocomplete service
/// </summary>
[WebService(Namespace = "http://youtube.myfolderburg.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class AutocompleteService : System.Web.Services.WebService
{
[WebMethod]
public string[] GetSuggestions(string prefixText, int count)
{
List<string> responses = new List<string>();
XDocument xD = XDocument.Load(Server.MapPath("search.xml"));
var result = (from x in xD.Descendants("searchWord")
where isEqual(x.Element("name").Value, prefixText)
orderby System.Convert.ToInt32(x.Element("count").Value) descending
select new
{
name = x.Element("name").Value
}).Take(count);
foreach (var v in result)
{
responses.Add(v.name);
}
return responses.ToArray();
}
static bool isEqual(string A, string B)
{
if (A.Length < B.Length) return false;
if (A.Substring(0, B.Length).Equals(B)) return true;
return false;
}
}
}
Veebiteenus
Saab otsida videosid, mis on üleval youtubes ja neid maha mängida.
Saab otsida playliste, mis on üleval youtubes ja seda maha mängima panna.
Saab vaadata enda playlistis olevaid videosid ja neid maha mängida.
Klientrakendus
Kuna kasutame youtube API-t, siis kasutame ühte kasutajat, mis on kirjeldatud koodis.
Videosid saab lisada oma playlisti
Saab teha samale kasutajale uue playlisti
rakenduse üldloogika
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Extensions.MediaRss;
using Google.YouTube;
using Google.GData.YouTube;
using System.Collections.Generic;
namespace Youtube
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Attributes.Add("autocomplete", "off"); // turn off default autocomplete for all browsers
sessionStart(); // check sessions and initialize
Panel2.Visible = false;
if (showPanel) Panel2.Visible = true;
if (searchQuery.Length > 1 && searchMode) findVideo();
else if (searchQuery.Length > 1) requestPlaylist();
addedLists(); // retrieve entries from default playlist
foreach (Playlist p in retrievedPlaylists)
{
if (!(DropDownList1.Items.Contains(new ListItem(p.Title)))) DropDownList1.Items.Add(new ListItem(p.Title));
}
}
// event handler
protected void buttonClicked(Object sender, CommandEventArgs e)
{
YouTubeMovieID = Convert.ToString(e.CommandArgument);
Session["YouTubeMovieID"] = YouTubeMovieID;
}
// find playlists for specified user
protected void Button1_Click(object sender, EventArgs e)
{
searchQuery = TextBox1.Text;
Session["searchQuery"] = searchQuery;
Session["searchMode"] = null;
saveQuery(sender, e);
Session["showPanel"] = true;
Response.Redirect(Request.RawUrl);
}
// show all entries under "My playlists"
protected void Button2_Click(object sender, EventArgs e)
{
searchQuery = "juutuub888";
Session["searchQuery"] = searchQuery;
Session["searchMode"] = null;
Session["showPanel"] = true;
Response.Redirect(Request.RawUrl);
}
// adding a new playlist
protected void Button3_Click(object sender, EventArgs e)
{
YouTubeRequestSettings settings = new YouTubeRequestSettings(applicationName, developerKey, username, password);
YouTubeRequest request = new YouTubeRequest(settings);
Playlist pl = new Playlist();
pl.Title = TextBox2.Text;
Playlist createdPlaylist = request.Insert(
new Uri("http://gdata.youtube.com/feeds/api/users/juutuub888/playlists"), pl);
}
// adding a video to the playlist
protected void Button4_Click(object sender, EventArgs e)
{
YouTubeRequestSettings settings = new YouTubeRequestSettings(applicationName, developerKey, username, password);
YouTubeRequest request = new YouTubeRequest(settings);
PlayListMember pm = new PlayListMember();
pm.Id = YouTubeMovieID;
request.AddToPlaylist(retrievedPlaylists[DropDownList1.SelectedIndex], pm);
}
// find video
protected void Button5_Click(object sender, EventArgs e)
{
searchQuery = TextBox1.Text;
Session["searchQuery"] = searchQuery;
Session["searchMode"] = true;
saveQuery(sender, e);
Session["showPanel"] = true;
Response.Redirect(Request.RawUrl);
}
}
}
Töödejaotus
Markus - idee, wikipedia, funktsionaalsus
Marko - idee, kood
Jaagup - XSL,XML
Valdar - projekti üldplaani koostamine, wiki
Margus - XML, projekti üldplaani koostamine
Meeskonna käekäik
18.mai XML ja XSL lisamine ülejäänud projektile
17.mai
http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog
10.mai
Marko näitab esialgset koodi ja kuidas asi hakkab toimima
3.mai
uus hosting
Kuna aspspider pole just kõige töökindlam, siis sai asi ümber kolitud folderburgi.
Aadress: http://youtube.myfolderburg.com/
29. aprill
asp.net hosting
asp.net leht on ka nüüd üleval - http://aspspider.info/juutuub/
control panel – http://www.aspspider.com/cp/
29. aprill
Youtube API
Paar head linki, et asjaga sinapeale saada:
http://code.google.com/apis/gdata/articles/dotnet_client_lib.html
http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html
http://code.google.com/apis/youtube/2.0/developers_guide_dotnet.html
Hinnang tööle
Olenemata esialgsest tähtajast, mis oli 12 mai, saime oma projekti valmis 10 päeva hiljem. Esialgne funktsionaalsus, mille planeerisime, saime ka tehtud. Jätsime ära kasutajate segmenteerimise, sest youtube api, mis on osa google apist, nõuab registreerimist ja koodis saab kasutada ainult registreeritud kasutajat.
Oleme tehtud tööga rahul ja näeme, et c# on mõistlik keel.