Skip to content

Commit

Permalink
main: delete file/directory support
Browse files Browse the repository at this point in the history
  • Loading branch information
igungor committed Apr 21, 2016
1 parent 401fdd5 commit 3a4cb91
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Put.io Kodi addon.
- Subtitle support
- Refresh directory
- Sort files by name
- Delete file/directory
- Localization

## Planned Features

- Delete file/directory
- Download file
- Show video files as watch/unwatched
- Sort by filesize
Expand Down
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</extension>
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<summary lang="en">put.io for Kodi</summary>
<summary lang="en">Put.io for Kodi</summary>
<description lang="en">Put.io is a service that combines cloud storage and bittorrent. You need an account to use this plug-in. Get one from https://put.io</description>
<language></language>
<license>GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007</license>
Expand Down
24 changes: 14 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,28 @@ def populate_dir(files):
list_items = []
for item in files:
thumbnail = item.screenshot or get_resource_path('mid-folder.png')
is_folder = item.content_type == 'application/x-directory'
if is_folder:
url = build_url(action='list', item=item.id)
else:
url = build_url(action='play', item=item.id)

delete_ctx_url = build_url(action='delete', item=item.id)

li = xbmcgui.ListItem(label=item.name,
label2=item.name,
iconImage=thumbnail,
thumbnailImage=thumbnail)


# http://kodi.wiki/view/InfoLabels
# I think they don't have any effect at all.
li.setInfo(type=item.content_type, infoLabels={'size': item.size, 'title': item.name, })
li.addContextMenuItems([
(__lang__(32040), 'Container.Refresh'), # refresh
(__lang__(32041), 'Action(ParentDir)'), # go-up
(__lang__(32042), 'XBMC.RunPlugin(%s)' % delete_ctx_url), # delete
])

is_folder = item.content_type == 'application/x-directory'
if is_folder:
url = build_url(action='list', item=item.id)
else:
url = build_url(action='play', item=item.id)

list_items.append((url, li, is_folder))

xbmcplugin.addDirectoryItems(handle=__handle__, items=list_items, totalItems=len(list_items))
Expand Down Expand Up @@ -177,9 +179,11 @@ def play(item):


def delete(item):
"""Deletes the given item."""
xbmc.log('***** in delete. item_id: %s' % item.id)
return
"""Deletes the given item and refreshes the current directory."""
if item.id == 0:
return
item.delete()
xbmc.executebuiltin('Container.Refresh')


def main():
Expand Down

0 comments on commit 3a4cb91

Please sign in to comment.